-
Notifications
You must be signed in to change notification settings - Fork 37
Closed
Labels
Description
CRef: JuliaImages/Images.jl#992
The following patch fixes the performance issue, but I'm lost in the memory orders...
diff --git a/src/ImageMagick.jl b/src/ImageMagick.jl
index db26f64..b0c36fb 100755
--- a/src/ImageMagick.jl
+++ b/src/ImageMagick.jl
@@ -149,13 +149,14 @@ function load_(file::Union{AbstractString,IO,Vector{UInt8}}, permute_horizontal=
sz, T, cs, channelorder = _metadata(wand)
# Allocate the buffer and get the pixel data
- buf = Array{T}(undef, sz)
- exportimagepixels!(rawview(channelview(buf)), wand, cs, channelorder)
+ buf = Array{UInt8}(undef, (length(T), sz...))
+ exportimagepixels!(buf, wand, cs, channelorder)
orient = getimageproperty(wand, "exif:Orientation", false)
default = (A,ph) -> ph ? vertical_major(A) : identity(A)
oriented_buf = get(orientation_dict, orient, default)(buf, permute_horizontal)
- view ? oriented_buf : collect(oriented_buf)
+ colorful_buf = length(T) == 1 ? reinterpret(T, reshape(buf, sz)) : reinterpretc(T, buf)
+ view ? colorful_buf : collect(colorful_buf)
endcc: @etibarg