Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ImageMagick dependency? #36

Closed
Cody-G opened this issue Jan 15, 2019 · 11 comments
Closed

add ImageMagick dependency? #36

Cody-G opened this issue Jan 15, 2019 · 11 comments

Comments

@Cody-G
Copy link

Cody-G commented Jan 15, 2019

It seems ImageMagick is a test dependency but not a project dependency, leading to this failure on Julia 0.7:

julia> using TestImages; testimage("cameraman")
Error encountered while loading "/home/cody/.julia/packages/TestImages/6bT9D/images/cameraman.tif".
Fatal error:
ERROR: ArgumentError: Package ImageMagick not found in current path:
- Run `Pkg.add("ImageMagick")` to install the ImageMagick package.

Stacktrace:
 [1] handle_error(::ArgumentError, ::FileIO.File{FileIO.DataFormat{:TIFF}}) at /home/cody/.julia/packages/FileIO/Y0Lre/src/error_handling.jl:80
 [2] handle_exceptions(::Array{Any,1}, ::String) at /home/cody/.julia/packages/FileIO/Y0Lre/src/error_handling.jl:75
 [3] #load#27(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::FileIO.File{FileIO.DataFormat{:TIFF}}) at /home/cody/.julia/packages/FileIO/Y0Lre/src/loadsave.jl:193
 [4] load(::FileIO.File{FileIO.DataFormat{:TIFF}}) at /home/cody/.julia/packages/FileIO/Y0Lre/src/loadsave.jl:172
 [5] #load#13(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::String) at /home/cody/.julia/packages/FileIO/Y0Lre/src/loadsave.jl:118
 [6] load at /home/cody/.julia/packages/FileIO/Y0Lre/src/loadsave.jl:118 [inlined]
 [7] macro expansion at ./logging.jl:317 [inlined]
 [8] testimage(::String) at /home/cody/.julia/packages/TestImages/6bT9D/src/TestImages.jl:75
 [9] top-level scope at none:0

I think we just need to add ImageMagick to REQUIRE, I'll ready a PR.

@timholy
Copy link
Member

timholy commented Jan 22, 2019

QuartzImageIO is used by default on OSX, so making it part of the required packages is not without issues.

FileIO used to offer to install ImageMagick for you, but that was deemed too magical. (I can understand why.)

@Cody-G
Copy link
Author

Cody-G commented Feb 6, 2019

Ah I see. I ran into this when testing using TestImages on Travis. It sounds like rather than adding ImageMagick as a test dependency it will be better to add a build script that checks whether the user is running linux / mac / windows in order to decide which library to install?

@timholy
Copy link
Member

timholy commented Feb 17, 2019

Given that it shows an informative error about how to fix the problem, do we actually need to do anything? Yes I'm being lazy, but it's laziness with a purpose 😄. If we do nothing then FileIO is in charge of deciding who should load images; if a new package comes on line (e.g., https://github.com/c42f/OpenImageIO.jl) then FileIO is the one-and-only thing that needs updating. If we add things to the build script here then there is more stuff to change.

@Cody-G
Copy link
Author

Cody-G commented Feb 18, 2019

If we add things to the build script here then there is more stuff to change.

This makes sense. I wasn't very clear in my post, I was trying to decide on the best practice when testing a package that depends on TestImages. Because currently adding TestImages as a dependency will cause a failure on Travis unless ImageMagick is also a dependency. Since we wouldn't just want to install ImageMagick unconditionally, I thought to edit the build script to install it conditionally in this dependent package I'm working on. Does that sound reasonable?

@timholy
Copy link
Member

timholy commented Feb 18, 2019

Got it, sorry, you were pretty clear and I was just being dense. How about this:

  • For a package that has a Project.toml file, you can add it to the "extras" section and "test" target (or I think it's now possible to add a Project.toml file to the test/ directory, and if present it will be used).
  • Otherwise, add it to test/REQUIRE.

@musm
Copy link

musm commented Apr 1, 2019

bump. I just installed this package and tried

julia>  using Images, TestImages, ImageInTerminal
[ Info: Precompiling Images [916415d5-f1e6-5110-898d-aaa5f9f070e0]
[ Info: Precompiling TestImages [5e47fb64-e119-507b-a336-dd2b206d9990]
[ Info: Precompiling ImageInTerminal [d8c32880-2388-543b-8c61-d9f865259254]

julia> testimage("cameraman")
Error encountered while loading "C:\\Users\\Mus\\.julia\\packages\\TestImages\\6bT9D\\images\\cameraman.tif".
Fatal error:
ERROR: ArgumentError: Package ImageMagick not found in current path:
- Run `import Pkg; Pkg.add("ImageMagick")` to install the ImageMagick package.

@Cody-G
Copy link
Author

Cody-G commented Apr 1, 2019

Given the cross-platform difficulties described above I was convinced not to add ImageMagick as a dependency. My followup question (how to add TestImages as test dependency of another package) was also answered, though I never got the chance to test whether that solution works on all platforms. I probably should have closed the issue, but if others are still unsatisfied I'll leave it open.

@johnnychen94
Copy link
Member

johnnychen94 commented Apr 21, 2019

I think it's now possible to add a Project.toml file to the test/ directory, and if present it will be used

@timholy can you find any reference to this?

Also I've drafted a related PR in FileIO JuliaIO/FileIO.jl#226. But I'm not sure if we really need this one.

@timholy
Copy link
Member

timholy commented Apr 21, 2019

https://julialang.github.io/Pkg.jl/dev/creating-packages/#Test-specific-dependencies-in-Julia-1.2-and-above-1

@johnnychen94
Copy link
Member

johnnychen94 commented Apr 21, 2019

🤔 Looks like we still can't solve the platform-dependent package deps using the new Project.toml even with this test/Project.toml

My current workaround is to add both ImageMagick and QuartzImageIO into test target. - The CI result says ok.

@timholy
Copy link
Member

timholy commented Dec 12, 2019

This has been fixed if you use Julia 1.3 or higher.

@timholy timholy closed this as completed Dec 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants