commonsmachinery / blockhash

blockhash.io
MIT License
86 stars 28 forks source link

Error opening image file. -- Please improve Exception handling. #27

Closed cytodev closed 6 years ago

cytodev commented 6 years ago

After downloading all required packages that are needed to run blockhash on my system I kept encountering the message "Error opening image file «image»." I thought this was rather odd seeing how the images are not broken, and the program seems to report this for every image I tried to open.

After spending some time with gdb I came to the conclusion that an exception was being raised by ImageMagick, but this exception was completely ignored in the script's output. The exception I was a MissingDelegateError with the message "no decode delegate for this image format: JPG"

After a quick search the cause of this seems to be that some Linux distributions that offer ImageMagick and the dev packages don't include the delegates that ImageMagick provides when you build from source. -- I resolved the "Error opening image file «image»." issue by compiling the ImageMagick package (from here) again and verifying that it now did have the necessary delegates.

blockhash is now working as expected, but the error could really use some improvement! I spent close to two hours on resolving this issue, and a more detailed error message could really save other people this headache! (also see this page)

Steps I took to compile the delegates, for anyone who happens to stumble across this:

$ wget https://www.imagemagick.org/download/releases/ImageMagick-7.0.8-8.tar.gz
$ extract ImageMagick-7.0.8-8.tar.gz
$ cd ImageMagick-7.0.8-8
$ ./configure
$ make
$ buildpkg
artfwo commented 6 years ago

Thanks for reporting, error messages improved in https://github.com/commonsmachinery/blockhash/commit/6854d7ab065d5f49a4f6abb8090d18b5fcdc2bde