convert resize png8,but the image is not clear

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
sohuaurong
Posts: 2
Joined: 2015-02-26T21:49:30-07:00
Authentication code: 6789

convert resize png8,but the image is not clear

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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.
sohuaurong
Posts: 2
Joined: 2015-02-26T21:49:30-07:00
Authentication code: 6789

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

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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.
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

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

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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
Post Reply