-
Notifications
You must be signed in to change notification settings - Fork 37
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
save an array as png through ImageMagick generate broken image. #184
Comments
The broken images have 2-bit or 4-bit depth, curiously. When the bit depth is specified directly as below, the lattice pattern is preserved. save("png8:sample.png", img) By the way, I knew this method from twitter (Japanese, though). |
Oh, that's very interesting, thanks for sharing! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This issue was originally reported to Images.jl: JuliaImages/Images.jl#909
When I saved an image which has values of multiples of 1/3, the saved image shrank along horizontal axis by factor of 1/4 and rest of the image was filled with random vertical pattern.
Examples of generating broken images
What I tried was as follow.
An expected image from above snippet is a lattice pattern with vertical and horizontal lines.
But actual was those. These outputs were obtained by repeating
save(...)
function in the snippet. While the sameimg
was passed tosave
, different vertical pattern appears in right 3/4 in images every time.A curious point is that when some different value was assigned to the array, the
save
function works as expected.Another examples
Here, 1/5 was assigned instead of 1/3.
This time, shrinking ratio seems to be about 1/2, though
save with ImageIO worked as expected
The above examples were generated without ImageIO package. When you see FileIO package and search png format, it tries to use ImageIO if installed. So I added ImageIO and then re-run the above snipped. That condition created an expected lattice pattern image. So the main cause might be ImageMagick module.
https://github.com/JuliaIO/FileIO.jl/blob/c55ffe1439dbef1f9a2b44852dda52e89beb530a/src/registry.jl#L90-L98
Other info.
Following is my environment.
Brief debug info
Following is @timholy's reply to original post.
I inserted some debugging code in ImageMagick.jl:
and then did this:
and got this:
So, the image is fine up to the point where Julia hands the data off to the imagemagick C library. Consequently, fixing this bug requires that it be reported to the ImageMagick developers.
Originally posted by @timholy in JuliaImages/Images.jl#909 (comment)
The text was updated successfully, but these errors were encountered: