SVG -> PNG, Massive PLTE chunk difference when scaling
Posted: 2009-08-27T06:32:36-07:00
Hi All
I have encountered an issue while converting from SVG to PNG and scaling at the same time that I'd like to discuss. In short, the amount of colors used for indexed PNGs (images with PLTE chunk) increase rapidly as I scale down the SVG resource.
I have attached an example of the above. Resource 'smile_100.svg' is the master SVG file. On this master file I do the two below calls producing files 'smile_100.png' & 'smile_73.png'.
convert -filter blackman -alpha on -depth 8 -background none -resize 100.0%!x100.0%! smile.svg smile_100.png
convert -filter blackman -alpha on -depth 8 -background none -resize 73.33%!x73.33%! smile.svg smile_73.png
Things is, that while 'smile_100.png' has 57 indexed colors, 'smile_73.png' has 159! This affects the size of the low res file which in my case is unacceptable.
I have tried almost all possible parameters of '-filter' without any changes. Have also tried blurring, sharpening, etc in the hopes that this might reduce the number of colors. Simply using '-colors n' will mess up the TRNS chunk of indexed PNGs and hence cannot be used.
Can anybody explain to me why the issue I am describing occurs, direct me to some resources on the subject or simply suggest ImageMagick parameters that solves the issue?
Thanks in advance!
smile_100.svg:
smile_100.png:
smile_73.png:
Resources:
smile_100.svg: http://kenneth.io/anders/smile_100.svg
smile_100.png: http://kenneth.io/anders/smile_100.png
smile_73.png: http://kenneth.io/anders/smile_73.png
I have encountered an issue while converting from SVG to PNG and scaling at the same time that I'd like to discuss. In short, the amount of colors used for indexed PNGs (images with PLTE chunk) increase rapidly as I scale down the SVG resource.
I have attached an example of the above. Resource 'smile_100.svg' is the master SVG file. On this master file I do the two below calls producing files 'smile_100.png' & 'smile_73.png'.
convert -filter blackman -alpha on -depth 8 -background none -resize 100.0%!x100.0%! smile.svg smile_100.png
convert -filter blackman -alpha on -depth 8 -background none -resize 73.33%!x73.33%! smile.svg smile_73.png
Things is, that while 'smile_100.png' has 57 indexed colors, 'smile_73.png' has 159! This affects the size of the low res file which in my case is unacceptable.
I have tried almost all possible parameters of '-filter' without any changes. Have also tried blurring, sharpening, etc in the hopes that this might reduce the number of colors. Simply using '-colors n' will mess up the TRNS chunk of indexed PNGs and hence cannot be used.
Can anybody explain to me why the issue I am describing occurs, direct me to some resources on the subject or simply suggest ImageMagick parameters that solves the issue?
Thanks in advance!
smile_100.svg:
smile_100.png:
smile_73.png:
Resources:
smile_100.svg: http://kenneth.io/anders/smile_100.svg
smile_100.png: http://kenneth.io/anders/smile_100.png
smile_73.png: http://kenneth.io/anders/smile_73.png