-type bilevel fails on some PNG - IM 6.8.7-4

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
Uma
Posts: 2
Joined: 2013-11-05T11:32:29-07:00
Authentication code: 6789

-type bilevel fails on some PNG - IM 6.8.7-4

Post by Uma »

Hello,
I've noticed a quite annoying bug as it took me some time to know where it came from.
When you try to convert a png image with -type bilevel, it fails sometimes.
By fail I mean the result is a fully black image.
Note that on the version 6.6.9-7 it works normally.
Here's one image that fails for you to test.
Image
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: -type bilevel fails on some PNG - IM 6.8.7-4

Post by fmw42 »

I can duplicate the bug on IM 6.8.7.4 Q16 Mac OSX

convert 4d0y.png -type bilevel show:
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: -type bilevel fails on some PNG - IM 6.8.7-4

Post by glennrp »

I'm seeing the problem as well. Something's wrong when using -type bilevel to reduce the image to 2-colors,
without telling the PNG encoder how to do the reduction.

These work, with or without -type bilevel as the final option:

Code: Select all

convert 4d0y.png -colorspace gray -ordered-dither 2x2 4d0y-od2x2.png

convert 4d0y.png -colorspace gray -threshold 50% 4d0y-threshold50.png
Also, the "-colorspace gray" can be omitted from the one using -threshold (but it is
required with the -ordered-dither).
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: -type bilevel fails on some PNG - IM 6.8.7-4

Post by glennrp »

Apparently 4d0y.png was originally a JPEG, converted by ImageMagick,
because it contains these text chunks, according to "pngcrush -n -v 4d0y.png":
  • Handling 4 tEXt/zTXt/iTXt chunks after IDAT
    0 date:create: 2013-10-31T16:26:29+01:00
    1 date:modify: 2013-10-31T16:26:29+01:00
    2 jpeg:colorspace: 2
    3 jpeg:sampling-factor: 2x2,1x1,1x1
I tried removing them just in case the jpeg properties were causing trouble somehow,
but that didn't change the behavior.
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: -type bilevel fails on some PNG - IM 6.8.7-4

Post by glennrp »

converting to PPM results in the same full-color image.
converting to PPM with -type bilevel results in an all-black image.

It appears that the reduction to black happens somewhere other than
in coders/png.c.

The error does not occur with IM-6.8.7-3 so it's a new bug.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: -type bilevel fails on some PNG - IM 6.8.7-4

Post by magick »

We can reproduce the problem you posted and have a patch in ImageMagick 6.8.7-5 Beta available by sometime tomorrow. Thanks.
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: -type bilevel fails on some PNG - IM 6.8.7-4

Post by glennrp »

Svn revision 13682 (tomorrow's 6.8.7-5) works for me. Thanks.
Uma
Posts: 2
Joined: 2013-11-05T11:32:29-07:00
Authentication code: 6789

Re: -type bilevel fails on some PNG - IM 6.8.7-4

Post by Uma »

Thanks for the fix guys !
It worked for all of my images !
Another question though : are you in charge of imagemagick-common libmagickcore5 and libmagickwand5 ?
Because I'm actually using wand as an api for python and it's still the same problem over here.
Do you have to update the libraries or they do not belong to you ?
Post Reply