Page 1 of 1

convert resize png8,but the image is not clear

Posted: 2015-02-26T23:07:48-07:00
by sohuaurong
hello,I need to generate thumbnails png8 format , but the image is not clear.if i remove png8:* format, then the picture is too big.

Code: Select all

convert -resize 100x100 soure.png png8:dst.png
source png url:http://img.wdjimg.com/mms/icon/v1/5/81/ ... 56_256.png

Re: convert resize png8,but the image is not clear

Posted: 2015-02-26T23:45:40-07:00
by fmw42
Always best to provide your IM version and platform and also examples of the good and bad results and exact code for each.

I tried your code (putting the input image in correct location right after convert).

Code: Select all

convert d7f58f0909da3081f9bd8e67abd34815_256_256.png -resize 100x100 png8:result8.png

Code: Select all

convert d7f58f0909da3081f9bd8e67abd34815_256_256.png -resize 100x100 result32.png
These both work as expected. The png8 result will be smaller is file size due to the use of a colortable 8-bits per pixel, but will have striped artifacts due to the fact that the colors are reduce to 256. The png32 result will have no artifacts, but will be a larger file size since it is not limited to 256 colors and has 32-bits per pixel.

I do not see a solution off the top of my head. You must chose one or the other. If you did not have transparency, the obvious solution would be to use jpg compression. You can flatten your transparency over some background color and save to compressed jpg. That is the only other option I see.

Re: convert resize png8,but the image is not clear

Posted: 2015-02-27T00:02:28-07:00
by sohuaurong
there is the result png.
i want to create png like this.
http://img.wdjimg.com/mms/icon/v1/5/81/ ... 00_100.png

Version: ImageMagick 6.9.0-5 Q8 x64 2015-01-31 http://www.imagemagick.org

Re: convert resize png8,but the image is not clear

Posted: 2015-02-27T11:09:37-07:00
by fmw42
How did you create this? With Imagemagick? If not, then there could be a bug in the PNG8 writer. The PNG developer may need to look into this. Perhaps you should post this on the bugs forum and clarify how you managed to make this result without the artifact banding that IM seems to be creating when writing to PNG8.

Re: convert resize png8,but the image is not clear

Posted: 2015-02-27T11:51:25-07:00
by glennrp
The PNG8: format uses a quick-and-dirty color-reduction method that doesn't work well when colors are all one hue.
Try

Code: Select all

 convert input.png -resize 100 -colors 254 output.png

Re: convert resize png8,but the image is not clear

Posted: 2015-02-27T17:10:19-07:00
by fmw42
Very interesting comment, Glenn. It is important to know that fact. Is this documented anywhere? Anthony did not note that as far as I can tell with a quick scan of his document at http://www.imagemagick.org/Usage/formats/#png