JuliaIO / ImageMagick.jl

Thin Wrapper for the library ImageMagick
Other
53 stars 37 forks source link

Loading image fails on windows #183

Open jonathanBieler opened 4 years ago

jonathanBieler commented 4 years ago

Installing the package and using work but when I try to load an image (FileIO.load) I get :

Fatal error:
ERROR: UnableToOpenBlob `C:/Users/User/AppData/Local/Temp/magick-8592hIzemuw0tD2h.ppm': No such file or directory @ error/blob.c/OpenBlob/2873
Stacktrace:
 [1] handle_error(::ErrorException, ::File{DataFormat{:TIFF}}) at C:\Users\Billou.asd-PC\.julia\packages\FileIO\zL0JE\src\error_handling.jl:82
 [2] handle_exceptions(::Array{Any,1}, ::String) at C:\Users\Billou.asd-PC\.julia\packages\FileIO\zL0JE\src\error_handling.jl:77
 [3] #load#27(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::typeof(load), ::Formatted) at C:\Users\Billou.asd-PC\.julia\packages\FileIO\zL0JE\src\loadsave.jl:189
 [4] load at C:\Users\Billou.asd-PC\.julia\packages\FileIO\zL0JE\src\loadsave.jl:166 [inlined]
 [5] #load#13 at C:\Users\Billou.asd-PC\.julia\packages\FileIO\zL0JE\src\loadsave.jl:118 [inlined]
 [6] load(::String) at C:\Users\Billou.asd-PC\.julia\packages\FileIO\zL0JE\src\loadsave.jl:118
 [7] top-level scope at REPL[47]:1

Why is it looking for files in my temp folder, that seems a bit fishy ?

Julia 1.3, ImageMagick v1.1.5, I had previous versions that worked in the past.

johnnychen94 commented 4 years ago

Would you mind providing more details about this? How do you load that image, and is it a particular image or image format that causes this issue?

It might be unrelated to this, but there's a new FileIO release v1.4.0 recently, probably you could take a try with an older version of FileIO?

jonathanBieler commented 4 years ago

Sure, I'm trying to load CR2 files (raw pictures), using FileIO.load(files[1]). It actually works if I first convert the image to tif (I assume imagemagick is used for tif ?) so it's maybe specific to that file format.

mfalt commented 4 years ago

I get a very similar error trying to load raw DNG files on windows:

using Images
img = load("myfile.dng")

Error encountered while loading "C:\\Users\\Mattias\\Documents\\imgtest\\myfile.dng".

Fatal error:
ERROR: UnableToOpenBlob `C:/Users/Mattias/AppData/Local/Temp/magick-12116GB_CM677xccI.ppm': No such file or directory @ error/blob.c/OpenBlob/2873
Stacktrace:
 [1] handle_error(::ErrorException, ::FileIO.File{FileIO.DataFormat{:TIFF}}) at C:\Users\Mattias\.julia\packages\FileIO\zL0JE\src\error_handling.jl:82
 [2] handle_exceptions(::Array{Any,1}, ::String) at C:\Users\Mattias\.julia\packages\FileIO\zL0JE\src\error_handling.jl:77
 [3] load(::FileIO.Formatted; options::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at C:\Users\Mattias\.julia\packages\FileIO\zL0JE\src\loadsave.jl:189
 [4] load at C:\Users\Mattias\.julia\packages\FileIO\zL0JE\src\loadsave.jl:166 [inlined]
 [5] #load#13 at C:\Users\Mattias\.julia\packages\FileIO\zL0JE\src\loadsave.jl:118 [inlined]
 [6] load(::String) at C:\Users\Mattias\.julia\packages\FileIO\zL0JE\src\loadsave.jl:118
 [7] top-level scope at REPL[17]:1

Edit: It doesn't help to downgrade FileIO.jl or ImageMagick.jl

ordicker commented 4 years ago

Got the same error on Linux too

timholy commented 4 years ago

This may be an ImageMagick bug rather than a Julia bug, but until someone either dives in to the Julia code and tells us what they've found, or posts an image that others can use to reproduce the bug, there's precious little chance of doing anything about this.

ordicker commented 4 years ago

I downloaded DNG file from google's hdrplusdata. Any way for convenient I uploaded one image here, hope that isn't license violation.

jonathanBieler commented 4 years ago

If I understand the code here correctly it's just doing a ccall into ImageMagick library :

https://github.com/JuliaIO/ImageMagick.jl/blob/master/src/libmagickwand.jl#L272

And it looks like people get this kind of issues with the standalone tool :

https://www.imagemagick.org/discourse-server/viewtopic.php?t=12881 https://www.imagemagick.org/discourse-server/viewtopic.php?t=32222

mfalt commented 4 years ago

TL DR: Missing ufraw-batch on the system results in this error.

Ok, so after some digging, I can verify that the problem occus using the c interface to the downloaded files (ImageMagick 6.9.10-12). And it is easy to reproduce using the binaries.

However, the problem occurs because of the missing dependency ufraw-batch. You can see this by running

~/.julia/packages/ImageMagick/vMfoS/deps/usr/bin/identify -list delegate which states dng:decode => "ufraw-batch' --silent --create-id=also --out-type=png --out-depth=16 '--output=%u.png' '%i"

or by printing the complete error message when trying to convert the image

~/.julia/packages/ImageMagick/vMfoS/deps/usr/bin/convert ~/imgtest/test.dng ~/imgtest/test.png
convert: DelegateFailed `'ufraw-batch' --silent --create-id=also --out-type=png --out-depth=16 '--output=%u.png' '%i'' @ error/delegate.c/InvokeDelegate/1919.
convert: UnableToOpenBlob `/tmp/magick-8759PY04LKTGS9ek.ppm': No such file or directory @ error/blob.c/OpenBlob/2873.
convert: NoImagesDefined `/home/mattias/imgtest/Bias.png' @ error/convert.c/ConvertImageCommand/3258.

On linux I was able to solve it by installing ufraw-batch, after which ImageMagick.load("test.dng") works fine. I notice that ufraw-batch does not seem to be one of the binary dependencies listed for ImageMagick.jl, however it is mentioned on https://imagemagick.org/script/resources.php It seems like the configuration for ImageMagick could be changed to libraw instead, see https://github.com/ImageMagick/ImageMagick/issues/1617

I don't completely understand the delagation in ImageMagick, so I dont know if this is the right approach.

timholy commented 4 years ago

I've cross-posted to https://github.com/JuliaPackaging/Yggdrasil/issues/1421, where the build-script for ImageMagick appears to be stored: https://github.com/JuliaPackaging/Yggdrasil/blob/master/I/ImageMagick/build_tarballs.jl

giordano commented 4 years ago

It isn't clear to me what's the problem exactly. My understanding is that ufraw-batch isn't a dependency of ImageMagick, does it need to be only present at runtime? Also, what software is ufraw-batch exactly? On the Internet I found different stuff.

NaNotia commented 3 years ago

I've got the same issue, it isn't fixed.