Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6d2acbd

Browse files
committedJun 6, 2017
Modify libversion logicand add functions for initalization
1 parent 764e7f6 commit 6d2acbd

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed
 

‎deps/build.jl

+7-7
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ if is_windows()
4949
innounp_url = "https://bintray.com/artifact/download/julialang/generic/innounp.exe"
5050
preloads =
5151
"""
52-
init_envs["MAGICK_CONFIGURE_PATH"] = \"$(escape_string(magick_libdir))\"
53-
init_envs["MAGICK_CODER_MODULE_PATH"] = \"$(escape_string(joinpath(magick_libdir, "modules", "coders")))\"
54-
init_envs["MAGICK_FILTER_MODULE_PATH"] = \"$(escape_string(joinpath(magick_libdir, "modules", "filters")))\"
55-
init_envs["PATH"] = \"$(escape_string(magick_libdir * ";"))\" * ENV["PATH"]\
52+
init_envs["MAGICK_CONFIGURE_PATH"] = "$(escape_string(magick_libdir))"
53+
init_envs["MAGICK_CODER_MODULE_PATH"] = "$(escape_string(joinpath(magick_libdir, "modules", "coders")))"
54+
init_envs["MAGICK_FILTER_MODULE_PATH"] = "$(escape_string(joinpath(magick_libdir, "modules", "filters")))"
55+
init_envs["PATH"] = "$(escape_string(magick_libdir * ";"))" * ENV["PATH"]
5656
"""
5757

5858
provides(BuildProcess,
@@ -73,9 +73,9 @@ if is_apple()
7373
homebrew_prefix = Homebrew.prefix()
7474
preloads =
7575
"""
76-
init_envs["MAGICK_CONFIGURE_PATH"] = \"$(escape_string(joinpath(homebrew_prefix, "lib", "ImageMagick", "config-Q16")))\"
77-
init_envs["MAGICK_CODER_MODULE_PATH"] = \"$(escape_string(joinpath(homebrew_prefix, "lib", "ImageMagick", "modules-Q16", "coders")))\"
78-
init_envs["MAGICK_FILTER_MODULE_PATH"] = \"$(escape_string(joinpath(homebrew_prefix, "lib", "ImageMagick", "modules-Q16", "filters")))\"
76+
init_envs["MAGICK_CONFIGURE_PATH"] = "$(escape_string(joinpath(homebrew_prefix, "lib", "ImageMagick", "config-Q16")))"
77+
init_envs["MAGICK_CODER_MODULE_PATH"] = "$(escape_string(joinpath(homebrew_prefix, "lib", "ImageMagick", "modules-Q16", "coders")))"
78+
init_envs["MAGICK_FILTER_MODULE_PATH"] = "$(escape_string(joinpath(homebrew_prefix, "lib", "ImageMagick", "modules-Q16", "filters")))"
7979
"""
8080
provides(Homebrew.HB, "homebrew/core/imagemagick@6", libwand, os = :Darwin, preload = preloads)
8181
end

‎src/ImageMagick.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ function image2wand(img, mapi=identity, quality=nothing, permute_horizontal=true
152152
T = eltype(imgw)
153153
channelorder = T<:Real ? "Gray" : ColorTypes.colorant_string(T)
154154
if T <: Union{RGB,RGBA,ARGB,BGRA,ABGR}
155-
cs = libversionref[] > v"6.7.5" ? "sRGB" : "RGB"
155+
cs = getlibversion() > v"6.7.5" ? "sRGB" : "RGB"
156156
else
157157
cs = channelorder
158158
end

‎src/libmagickwand.jl

+13-9
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ export MagickWand,
2020

2121
const init_envs = Dict{String,String}()
2222

23-
# Find the library
24-
const depsfile = joinpath(dirname(@__FILE__), "..", "deps", "deps.jl")
23+
const depsfile = joinpath(dirname(@__DIR__), "deps", "deps.jl")
2524
if isfile(depsfile)
2625
include(depsfile)
2726
else
2827
error("ImageMagick not properly installed. Please run Pkg.build(\"ImageMagick\") then restart Julia.")
2928
end
3029

31-
const libmagic = Ref{Ptr{Void}}()
30+
const libmagick = Ref{Ptr{Void}}()
3231

3332
const MagickWandGenesis = Ref{Ptr{Void}}()
33+
const MagickWandTerminus = Ref{Ptr{Void}}()
3434
const NewMagickWand = Ref{Ptr{Void}}()
3535
const DestroyMagickWand = Ref{Ptr{Void}}()
3636
const NewPixelWand = Ref{Ptr{Void}}()
@@ -75,18 +75,23 @@ const MagickRelinquishMemory = Ref{Ptr{Void}}()
7575
const MagickQueryConfigureOption = Ref{Ptr{Void}}()
7676
const MagickQueryConfigureOptions = Ref{Ptr{Void}}()
7777

78-
const libversionref = Ref{VersionNumber}()
7978

80-
loadsym(fun::Symbol) = Libdl.dlsym(libmagic[], fun)
79+
initialize() = ccall(MagickWandGenesis[], Void, ())
80+
destroy() = ccall(MagickWandTerminus[], Void, ())
81+
82+
loadsym(fun::Symbol) = Libdl.dlsym(libmagick[], fun)
83+
84+
getlibversion() = VersionNumber(join(split(queryoption("LIB_VERSION_NUMBER"), ',')[1:3], '.'))
8185

8286
function __init__()
8387
for (key, value) in init_envs
8488
ENV[key] = value
8589
end
8690

87-
libmagic[] = Libdl.dlopen(libwand, Libdl.RTLD_GLOBAL)
91+
libmagick[] = Libdl.dlopen(libwand, Libdl.RTLD_GLOBAL)
8892

8993
MagickWandGenesis[] = loadsym(:MagickWandGenesis)
94+
MagickWandTerminus[] = loadsym(:MagickWandTerminus)
9095
NewMagickWand[] = loadsym(:NewMagickWand)
9196
DestroyMagickWand[] = loadsym(:DestroyMagickWand)
9297
NewPixelWand[] = loadsym(:NewPixelWand)
@@ -131,10 +136,9 @@ function __init__()
131136
MagickQueryConfigureOptions[] = loadsym(:MagickQueryConfigureOptions)
132137
MagickQueryConfigureOption[] = loadsym(:MagickQueryConfigureOption)
133138

134-
ccall(MagickWandGenesis[], Void, ())
139+
initialize()
135140

136-
libversionref[] = VersionNumber(join(split(queryoption("LIB_VERSION_NUMBER"), ',')[1:3], '.'))
137-
global libversion = libversionref[]
141+
global libversion = getlibversion()
138142
end
139143

140144
# Constants

0 commit comments

Comments
 (0)
Please sign in to comment.