[magick-users] Make transparent background white in multiple PNGs
Fred Weinhaus
fmw at alink.net
Fri Sep 25 10:19:47 PDT 2009
You may be able to use mogrify to process each image in one folder
and place it with the same name in a second folder. Something like
create second empty folder
cd to first folder where your images are located
mogrify -path /fullpathto/secondfolder -format png -background white
-flatten *.png
I am not sure that mogrify will allow -flatten. If not, then you will
need to write a script to loop over each image and use convert
convert infile.png -background white -flatten infile.png
I am not sure what you can do about the dithering as IM will
reprocess your image to one extent or another. It may or may not work
out. So you will need to test it on one image to see about the above.
I hope that this will just flatten your transparency to white, but I
really don't know what will happen with any specific dither pattern.
Also there is no guarantee that IM will not change the filesize
either. Some things that can be done depend upon if you have 8 or 16
bit images and are running IM in 8 or 16 bit mode. If your image is
8-bit and you are on 16-bit IM, then you need to add -depth 8 to the
commands. PNG compression controls can be used as well as PNG output
formats.
see http://www.imagemagick.org/Usage/formats/#png
If your pngs are optimized then IM will probably produce larger sizes
and you may need to use one of the other tools mentioned in this page
to post process and reoptimize your png.
>I have a folder full of PNGs with transparent background
>and need to process all of them so as to
>
>* make the background white/add a white background
>* not change the filenames
>* not break dithering
>* not change the size of the images
>
>What would be the invocation?
>
>TIA,
>
>/BP
More information about the Magick-users
mailing list