Is it possible to check that a picture that I downloaded is readable, if a picture viewer is going to tell me it cannot open it for some reason.
Example:
"invalid byte sequence in conversion input" when mousepad is used because Ephoto could not open it on Linux ) in Ruby
I download my picture with OpenURI and then output it in a file. Is there a function/gem that would allow to do that?
pic_buffer = open(my_link, "User-Agent" => "Ruby/#{RUBY_VERSION}")
if function_to_check_if_the_picture_is_readable(pic_buffer) == false
abort("file is unreadable")
end
if pic_buffer != nil
File.open(name_buffer + ".jpg", 'wb') do |pic|
pic << pic_buffer.read
end
end
I am downloading JPEG pictures only.