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

Problem load() - libwand not defined #229

Closed
Entropathe opened this issue Jun 20, 2019 · 17 comments
Closed

Problem load() - libwand not defined #229

Entropathe opened this issue Jun 20, 2019 · 17 comments

Comments

@Entropathe
Copy link

Hi,
I'm running on Debian Stretch. I installed Julia 1.0.4 to process images. However, there is a problem with ImageMagick which I can't solve.

The error occurs when I'm using load().

julia> img = testimage("mandrill")
[ Info: Recompiling stale cache file /home/jean/.julia/compiled/v1.0/ImageMagick/0LbNX.ji for ImageMagick [6218d12a-5da1-5696-b52f-db25d2ecc6d1]
Error encountered while loading "/home/jean/.julia/packages/TestImages/Aoq3X/images/mandrill.tiff".
Fatal error:
ERROR: InitError: UndefVarError: libwand not defined
Stacktrace:
[1] handle_error(::InitError, ::File{DataFormat{:TIFF}}) at /home/jean/.julia/packages/FileIO/JAtC1/src/error_handling.jl:80
[2] handle_exceptions(::Array{Any,1}, ::String) at /home/jean/.julia/packages/FileIO/JAtC1/src/error_handling.jl:75
[3] #load#27(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::File{DataFormat{:TIFF}}) at /home/jean/.julia/packages/FileIO/JAtC1/src/loadsave.jl:193
[4] load(::File{DataFormat{:TIFF}}) at /home/jean/.julia/packages/FileIO/JAtC1/src/loadsave.jl:172
[5] #load#13(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::String) at /home/jean/.julia/packages/FileIO/JAtC1/src/loadsave.jl:118
[6] load at /home/jean/.julia/packages/FileIO/JAtC1/src/loadsave.jl:118 [inlined]
[7] testimage(::String) at /home/jean/.julia/packages/TestImages/Aoq3X/src/TestImages.jl:89
[8] top-level scope at none:0
during initialization of module ImageMagick

@SimonDanisch
Copy link
Member

I think I just fixed this issue in ImageMagick.
Try this branch in the julia REPL:

]add ImageMagick#sd-update_deps

@Entropathe
Copy link
Author

Thank you but I have a new error now:

julia> img=testimage("mandrill")
[ Info: Recompiling stale cache file /home/jean/.julia/compiled/v1.0/ImageMagick/0LbNX.ji for ImageMagick [6218d12a-5da1-5696-b52f-db25d2ecc6d1]
Error encountered while loading "/home/jean/.julia/packages/TestImages/Aoq3X/images/mandrill.tiff".
Fatal error:
ERROR: InitError: /home/jean/.julia/packages/ImageMagick/zWFWP/deps/usr/lib/libpng16.so cannot be opened, Please re-run Pkg.build("ImageMagick"), and restart Julia.
Stacktrace:
[1] handle_error(::InitError, ::File{DataFormat{:TIFF}}) at /home/jean/.julia/packages/FileIO/JAtC1/src/error_handling.jl:80
[2] handle_exceptions(::Array{Any,1}, ::String) at /home/jean/.julia/packages/FileIO/JAtC1/src/error_handling.jl:75
[3] #load#27(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::File{DataFormat{:TIFF}}) at /home/jean/.julia/packages/FileIO/JAtC1/src/loadsave.jl:193
[4] load(::File{DataFormat{:TIFF}}) at /home/jean/.julia/packages/FileIO/JAtC1/src/loadsave.jl:172
[5] #load#13(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::String) at /home/jean/.julia/packages/FileIO/JAtC1/src/loadsave.jl:118
[6] load at /home/jean/.julia/packages/FileIO/JAtC1/src/loadsave.jl:118 [inlined]
[7] testimage(::String) at /home/jean/.julia/packages/TestImages/Aoq3X/src/TestImages.jl:89
[8] top-level scope at none:0
during initialization of module ImageMagick

I tried to build ImageMagick like said but no change.

@SimonDanisch
Copy link
Member

Oh, well, glad you tested that PR :D
Damn, that means this is truly broken.
Try:

]add ImageMagick@0.7.3

@SimonDanisch
Copy link
Member

And would be nice to get the output of:

using Libdl
Libdl.dlopen("/home/jean/.julia/packages/ImageMagick/zWFWP/deps/usr/lib/libpng16.so")

So I can fix that PR ;)

@SimonDanisch
Copy link
Member

That dlopen needs to be done after building ImageMagick#sd-update_deps

@Entropathe
Copy link
Author

Here we go:

(v1.0) pkg> status
Status ~/.julia/environments/v1.0/Project.toml
[c52e3926] Atom v0.8.7
[39de3d68] AxisArrays v0.3.0
[9e28174c] BinDeps v0.8.10
[b99e7846] BinaryProvider v0.5.4
[5ae59095] Colors v0.9.5
[0c46a032] DifferentialEquations v6.3.0
[5789e2e9] FileIO v1.0.7
[53c48c17] FixedPointNumbers v0.6.1
[d9be37ee] Homebrew v0.7.1
[6218d12a] ImageMagick v0.7.4 #sd-update_deps (https://github.com/JuliaIO/ImageMagick.jl.git)
[86fae568] ImageView v0.9.0
[916415d5] Images v0.18.0
[9b13fd28] IndirectArrays v0.5.0
[e5e0dc1b] Juno v0.7.0
[b964fa9f] LaTeXStrings v1.0.3
[2fda8390] LsqFit v0.8.1
[dbb5928d] MappedArrays v0.2.1
[91a5bcdd] Plots v0.25.1
[438e738f] PyCall v1.91.2
[d330b81b] PyPlot v2.8.1
[276daf66] SpecialFunctions v0.7.2
[5e47fb64] TestImages v0.5.1
[1986cc42] Unitful v0.15.0
[8bb1440f] DelimitedFiles

(v1.0) pkg> build ImageMagick
Building Conda ──────→ ~/.julia/packages/Conda/kLXeC/deps/build.log
Building FFTW ───────→ ~/.julia/packages/FFTW/p7sLQ/deps/build.log
Building ImageMagick → ~/.julia/packages/ImageMagick/zWFWP/deps/build.log

julia> using Libdl

julia> Libdl.dlopen("/home/jean/.julia/packages/ImageMagick/zWFWP/deps/usr/lib/libpng16.so")
ERROR: could not load library "/home/jean/.julia/packages/ImageMagick/zWFWP/deps/usr/lib/libpng16.so"
/lib/x86_64-linux-gnu/libz.so.1: version `ZLIB_1.2.9' not found (required by /home/jean/.julia/packages/ImageMagick/zWFWP/deps/usr/lib/libpng16.so)
Stacktrace:
[1] dlopen(::String, ::UInt32) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Libdl/src/Libdl.jl:97 (repeats 2 times)
[2] top-level scope at none:0

@hhaensel
Copy link

hhaensel commented Jun 20, 2019

Have you tried to delete the binaries from the package before running build ImageMagick?

@Entropathe
Copy link
Author

No. My bad!!! Here we go again:
(v1.0) pkg> add ImageMagick#sd-update_deps
Updating git-repo https://github.com/JuliaIO/ImageMagick.jl.git
Resolving package versions...
Updating ~/.julia/environments/v1.0/Project.toml
[6218d12a] + ImageMagick v0.7.4 #sd-update_deps (https://github.com/JuliaIO/ImageMagick.jl.git)
Updating ~/.julia/environments/v1.0/Manifest.toml
[621f4979] + AbstractFFTs v0.4.1
[7a1cc6ca] + FFTW v0.2.4
[5789e2e9] + FileIO v1.0.7
[a2bd30eb] + Graphics v0.4.0
[a09fc81d] + ImageCore v0.8.4
[6218d12a] + ImageMagick v0.7.4 #sd-update_deps (https://github.com/JuliaIO/ImageMagick.jl.git)
[6fe1bfb0] + OffsetArrays v0.11.0
[5432bcbf] + PaddedViews v0.4.2

(v1.0) pkg> status
Status ~/.julia/environments/v1.0/Project.toml
[c52e3926] Atom v0.8.7
[39de3d68] AxisArrays v0.3.0
[9e28174c] BinDeps v0.8.10
[b99e7846] BinaryProvider v0.5.4
[5ae59095] Colors v0.9.5
[0c46a032] DifferentialEquations v6.3.0
[53c48c17] FixedPointNumbers v0.6.1
[d9be37ee] Homebrew v0.7.1
[6218d12a] ImageMagick v0.7.4 #sd-update_deps (https://github.com/JuliaIO/ImageMagick.jl.git)
[9b13fd28] IndirectArrays v0.5.0
[e5e0dc1b] Juno v0.7.0
[b964fa9f] LaTeXStrings v1.0.3
[2fda8390] LsqFit v0.8.1
[dbb5928d] MappedArrays v0.2.1
[91a5bcdd] Plots v0.25.1
[438e738f] PyCall v1.91.2
[d330b81b] PyPlot v2.8.1
[276daf66] SpecialFunctions v0.7.2
[1986cc42] Unitful v0.15.0
[8bb1440f] DelimitedFiles

(v1.0) pkg> build ImageMagick
Building Conda ──────→ ~/.julia/packages/Conda/kLXeC/deps/build.log
Building FFTW ───────→ ~/.julia/packages/FFTW/p7sLQ/deps/build.log
Building ImageMagick → ~/.julia/packages/ImageMagick/zWFWP/deps/build.log

julia> using Libdl

julia> Libdl.dlopen("/home/jean/.julia/packages/ImageMagick/zWFWP/deps/usr/lib/libpng16.so")
Ptr{Nothing} @0x0000000002273490

@SimonDanisch
Copy link
Member

Oh... but the users shouldn't need to delete them right? Hmmm, but do tests on my branch pass for you now after removing them?

@Entropathe
Copy link
Author

Yes, the tests pass but they also did before. Let me try to load an image again.

Test:

(v1.0) pkg> test ImageMagick
Testing ImageMagick
Resolving package versions...
Status /tmp/tmpDwMvNf/Manifest.toml
[621f4979] AbstractFFTs v0.4.1
[13072b0f] AxisAlgorithms v1.0.0
[39de3d68] AxisArrays v0.3.0
[9e28174c] BinDeps v0.8.10
[b99e7846] BinaryProvider v0.5.4
[00ebfdb7] CSTParser v0.6.0
[3da002f7] ColorTypes v0.8.0
[c3611d14] ColorVectorSpace v0.7.0
[5ae59095] Colors v0.9.5
[34da2185] Compat v2.1.0
[8f4d0f93] Conda v1.3.0
[150eb455] CoordinateTransformations v0.5.0
[864edb3b] DataStructures v0.15.0
[7a1cc6ca] FFTW v0.2.4
[5789e2e9] FileIO v1.0.7
[53c48c17] FixedPointNumbers v0.6.1
[a2bd30eb] Graphics v0.4.0
[bbac6d45] IdentityRanges v0.3.0
[2803e5a7] ImageAxes v0.6.0
[a09fc81d] ImageCore v0.8.4
[6218d12a] ImageMagick v0.7.4 #sd-update_deps (https://github.com/JuliaIO/ImageMagick.jl.git)
[bc367c6b] ImageMetadata v0.7.1
[4e3cecfd] ImageShow v0.2.0
[02fcd773] ImageTransformations v0.8.0
[9b13fd28] IndirectArrays v0.5.0
[a98d9a8b] Interpolations v0.12.2
[8197267c] IntervalSets v0.3.1
[c8e1da08] IterTools v1.1.1
[682c06a0] JSON v0.20.0
[1914dd2f] MacroTools v0.5.0
[dbb5928d] MappedArrays v0.2.1
[e1d29d7a] Missings v0.4.1
[77ba4419] NaNMath v0.3.2
[6fe1bfb0] OffsetArrays v0.11.0
[bac558e1] OrderedCollections v1.1.0
[5432bcbf] PaddedViews v0.4.2
[b3c3ace0] RangeArrays v0.3.1
[c84ed2f1] Ratios v0.3.1
[189a3867] Reexport v0.2.0
[ae029012] Requires v0.5.2
[6038ab10] Rotations v0.11.1
[699a6c99] SimpleTraits v0.8.0
[a2af1166] SortingAlgorithms v0.3.1
[276daf66] SpecialFunctions v0.7.2
[90137ffa] StaticArrays v0.11.0
[2913bbd2] StatsBase v0.30.0
[0796e94c] Tokenize v0.5.4
[30578b45] URIParser v0.4.0
[81def892] VersionParsing v1.1.3
[efce3f68] WoodburyMatrices v0.4.1
[a5390f91] ZipFile v0.8.3
[2a0f44e3] Base64 [@stdlib/Base64]
[ade2ca70] Dates [@stdlib/Dates]
[8bb1440f] DelimitedFiles [@stdlib/DelimitedFiles]
[8ba89e20] Distributed [@stdlib/Distributed]
[b77e0a4c] InteractiveUtils [@stdlib/InteractiveUtils]
[76f85450] LibGit2 [@stdlib/LibGit2]
[8f399da3] Libdl [@stdlib/Libdl]
[37e2e46d] LinearAlgebra [@stdlib/LinearAlgebra]
[56ddb016] Logging [@stdlib/Logging]
[d6f4376e] Markdown [@stdlib/Markdown]
[a63ad114] Mmap [@stdlib/Mmap]
[44cfe95a] Pkg [@stdlib/Pkg]
[de0858da] Printf [@stdlib/Printf]
[3fa0cd96] REPL [@stdlib/REPL]
[9a3f8284] Random [@stdlib/Random]
[ea8e919c] SHA [@stdlib/SHA]
[9e88b42a] Serialization [@stdlib/Serialization]
[1a1011a3] SharedArrays [@stdlib/SharedArrays]
[6462fe0b] Sockets [@stdlib/Sockets]
[2f01184e] SparseArrays [@stdlib/SparseArrays]
[10745b16] Statistics [@stdlib/Statistics]
[8dfed614] Test [@stdlib/Test]
[cf7118a7] UUIDs [@stdlib/UUIDs]
[4ec0a83e] Unicode [@stdlib/Unicode]
[ Info: ("ImageMagick version ", v"6.9.10-12")
┌ Warning: Mapping to the storage type failed; perhaps your data had out-of-range values?
│ Try map(clamp01nan, img) to clamp values to a valid range.
└ @ ImageMagick ~/.julia/packages/ImageMagick/zWFWP/src/ImageMagick.jl:167
Test Summary: | Pass Total
IO | 38 38
--2019-06-20 14:57:10-- http://www.imagemagick.org/Usage/images/jigsaw_tmpl.png
Resolving www.imagemagick.org (www.imagemagick.org)... 198.72.81.86
Connecting to www.imagemagick.org (www.imagemagick.org)|198.72.81.86|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 654 [image/png]
Saving to: ‘/tmp/Images/jigsaw_tmpl.png’

/tmp/Images/jigsaw_tmpl.png 100%[============================================================================>] 654 --.-KB/s in 0s

2019-06-20 14:57:10 (47.0 MB/s) - ‘/tmp/Images/jigsaw_tmpl.png’ saved [654/654]

--2019-06-20 14:57:11-- http://www.imagemagick.org/Usage/images/wmark_image.png
Resolving www.imagemagick.org (www.imagemagick.org)... 198.72.81.86
Connecting to www.imagemagick.org (www.imagemagick.org)|198.72.81.86|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8020 (7.8K) [image/png]
Saving to: ‘/tmp/Images/wmark_image.png’

/tmp/Images/wmark_image.png 100%[============================================================================>] 7.83K --.-KB/s in 0s

2019-06-20 14:57:11 (18.7 MB/s) - ‘/tmp/Images/wmark_image.png’ saved [8020/8020]

--2019-06-20 14:57:12-- http://www.imagemagick.org/Usage/images/rose.png
Resolving www.imagemagick.org (www.imagemagick.org)... 198.72.81.86
Connecting to www.imagemagick.org (www.imagemagick.org)|198.72.81.86|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 6939 (6.8K) [image/png]
Saving to: ‘/tmp/Images/rose.png’

/tmp/Images/rose.png 100%[============================================================================>] 6.78K --.-KB/s in 0s

2019-06-20 14:57:13 (338 MB/s) - ‘/tmp/Images/rose.png’ saved [6939/6939]

--2019-06-20 14:57:13-- http://www.imagemagick.org/Usage/images/autumn_leaves.png
Resolving www.imagemagick.org (www.imagemagick.org)... 198.72.81.86
Connecting to www.imagemagick.org (www.imagemagick.org)|198.72.81.86|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 56562 (55K) [image/png]
Saving to: ‘/tmp/Images/autumn_leaves.png’

/tmp/Images/autumn_leaves.png 100%[============================================================================>] 55.24K 203KB/s in 0.3s

2019-06-20 14:57:14 (203 KB/s) - ‘/tmp/Images/autumn_leaves.png’ saved [56562/56562]

--2019-06-20 14:57:15-- http://www.imagemagick.org/Usage/images/present.gif
Resolving www.imagemagick.org (www.imagemagick.org)... 198.72.81.86
Connecting to www.imagemagick.org (www.imagemagick.org)|198.72.81.86|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 315 [image/gif]
Saving to: ‘/tmp/Images/present.gif’

/tmp/Images/present.gif 100%[============================================================================>] 315 --.-KB/s in 0s

2019-06-20 14:57:15 (76.6 MB/s) - ‘/tmp/Images/present.gif’ saved [315/315]

--2019-06-20 14:57:15-- http://www.imagemagick.org/Usage/images/swirl_video.gif
Resolving www.imagemagick.org (www.imagemagick.org)... 198.72.81.86
Connecting to www.imagemagick.org (www.imagemagick.org)|198.72.81.86|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 556617 (544K) [image/gif]
Saving to: ‘/tmp/Images/swirl_video.gif’

/tmp/Images/swirl_video.gif 100%[============================================================================>] 543.57K 795KB/s in 0.7s

2019-06-20 14:57:17 (795 KB/s) - ‘/tmp/Images/swirl_video.gif’ saved [556617/556617]

extraProps = ["create-date", "date:create", "date:modify", "modify-date", "png:bKGD", "png:cHRM", "png:gAMA", "png:IHDR.bit-depth-orig", "png:IHDR.bit_depth", "png:IHDR.color-type-orig", "png:IHDR.color_type", "png:IHDR.interlace_method", "png:IHDR.width,height", "png:pHYs", "png:sRGB", "png:text"]
┌ Warning: Undefined property, possible names are "create-date","date:create","date:modify","modify-date","png:bKGD","png:cHRM","png:gAMA","png:IHDR.bit-depth-orig","png:IHDR.bit_depth","png:IHDR.color-type-orig","png:IHDR.color_type","png:IHDR.interlace_method","png:IHDR.width,height","png:pHYs","png:sRGB","png:text"
└ @ ImageMagick ~/.julia/packages/ImageMagick/zWFWP/src/libmagickwand.jl:342
Test Summary: | Pass Total
Read remote | 67 67
--2019-06-20 14:57:18-- http://magnushoff.com/assets/test-exiforientation.zip
Resolving magnushoff.com (magnushoff.com)... 37.139.16.16
Connecting to magnushoff.com (magnushoff.com)|37.139.16.16|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://magnushoff.com/assets/test-exiforientation.zip [following]
--2019-06-20 14:57:18-- https://magnushoff.com/assets/test-exiforientation.zip
Connecting to magnushoff.com (magnushoff.com)|37.139.16.16|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4391 (4.3K) [application/zip]
Saving to: ‘/tmp/Images/test-exiforientation.zip’

/tmp/Images/test-exiforientation.zip 100%[============================================================================>] 4.29K --.-KB/s in 0s

2019-06-20 14:57:18 (66.1 MB/s) - ‘/tmp/Images/test-exiforientation.zip’ saved [4391/4391]

Test Summary: | Pass Total
EXIF orientation | 7 7
Testing ImageMagick tests passed

@Entropathe
Copy link
Author

Now it works!!!! Ho man, I love you! Lost a few hairs past two days.
Thank you!!

@Entropathe
Copy link
Author

I close the topic

@hhaensel
Copy link

I think the current logic is to install the binaries only if no ones are installed. Probably one should check the version or just force a remove at the beginning.

@hhaensel
Copy link

hhaensel commented Jun 24, 2019

I am not sure whether this should really be closed

@SimonDanisch
Just in case you are thinking in the same direction

import Libdl; ccall(Libdl.dlsym(Libdl.dlopen("bin\\libpng16.dll"), :png_access_version_number), Int32, ()) gives you the version number of the installed library

[EDIT] or to make it more concrete for the isolated case

parse(Int32, read(`julia -E "import Libdl; ccall(Libdl.dlsym(Libdl.dlopen(\"$(dl_esc_path)\"), :png_access_version_number), Int32, ())"`, String))

@SimonDanisch SimonDanisch reopened this Jun 24, 2019
@hhaensel
Copy link

or shorter:

parse(Int32, read(`julia -E "ccall( (:png_access_version_number, \"$(dl_esc_path)\"), Int32, ())"`, String))

for the isolated case and

eval(:(ccall( (:png_access_version_number, $(dl_path)), Int32, ())) )

for the internal case

@keyianpai
Copy link

keyianpai commented Oct 3, 2019

i have the same problem on win10,here is the code reproducing the problem:

using Images, FileIO
img = load(download("https://upload.wikimedia.org/wikipedia/en/thumb/b/b9/Flag_of_Australia.svg/320px-Flag_of_Australia.svg.png"))

(v1.2) pkg> status
Status C:\Users\H\.julia\environments\v1.2\Project.toml
[c52e3926] Atom v0.10.1
[ba4760a4] BayesNets v3.2.0
[336ed68f] CSV v0.5.12
[8f4d0f93] Conda v1.3.0
[a93c6f00] DataFrames v0.19.4
[31c24e10] Distributions v0.21.3
[7876af07] Example v0.5.4 #master (https://github.com/JuliaLang/Example.jl)
[5789e2e9] FileIO v1.0.7
[f67ccb44] HDF5 v0.12.3
[7073ff75] IJulia v1.20.0
[6218d12a] ImageMagick v0.7.5
[916415d5] Images v0.18.0
[a98d9a8b] Interpolations v0.12.2
[e5e0dc1b] Juno v0.7.2
[5ab0869b] KernelDensity v0.5.1
[9bbee03b] NaiveBayes v0.4.0
[438e738f] PyCall v1.91.2
[2913bbd2] StatsBase v0.32.0
[37e2e46d] LinearAlgebra

@timholy
Copy link
Member

timholy commented Mar 3, 2021

This is unlikely to be fixed on Julia 1.0. It may work on Julia 1.3 or higher. But in general, anyone running Julia 1.3 or higher should install ImageIO and use it in preference to ImageMagick for the file types it supports.

Marking this as likely to be closed by #290

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

6 participants