JuliaImages/TestImages.jl

Cannot load and use image inside same function

alberttxu opened this issue · 1 comments

I was recommeded to repost this issue from the relevant discourse thread - https://discourse.julialang.org/t/cannot-load-image-and-do-fftshift-inside-the-same-function/59663

Loading and accessing the test image inside a function only fails the first time.

`
julia> using TestImages

julia> function f()
img = testimage("mandrill")
size(img)
end
f (generic function with 1 method)

julia> f()
ERROR: MethodError: no method matching size(::TiffImages.DenseTaggedImage{ColorTypes.RGB{FixedPointNumbers.N0f8}, 2, UInt32, Matrix{ColorTypes.RGB{FixedPointNumbers.N0f8}}})
The applicable method may be too new: running in world age 29639, while current world is 29646.
Closest candidates are:
size(::TiffImages.DenseTaggedImage) at /Users/albertxu/.julia/packages/TiffImages/10dKE/src/types/dense.jl:24 (method too new to be called from this world context.)
size(::AbstractArray{T, N}, ::Any) where {T, N} at abstractarray.jl:38
size(::Union{LinearAlgebra.Adjoint{T, var"#s832"}, LinearAlgebra.Transpose{T, var"#s832"}} where {T, var"#s832"<:(AbstractVector{T} where T)}) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/LinearAlgebra/src/adjtrans.jl:196
...
Stacktrace:
[1] f()
@ Main ./REPL[2]:3
[2] top-level scope
@ REPL[3]:1

julia> f()
(512, 512)
`

This is expected behavior from FileIO lazy loading design and I believe there's nothing we can do to fix it.

See also JuliaIO/FileIO.jl#283