Batch Convert png24 files to png8 preserving transparency

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
thatfellow
Posts: 4
Joined: 2014-02-10T17:05:31-07:00
Authentication code: 6789

Batch Convert png24 files to png8 preserving transparency

Post by thatfellow »

I have about 5000 png24 files that I need converted to png8 preserving all transparency data..
Is this possible through terminal with image magick?

I have tried pngquant but no success, I kept getting this error :
NOTE: the -map option is NOT YET SUPPORTED.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Batch Convert png24 files to png8 preserving transparenc

Post by fmw42 »

PNG24 (24-bit color) does not include any transparency. Do you mean PNG32 (24-bit color with 8-bit transparency)?


If so, the use mogrify to convert all the images in a folder

Assume image are in folder1 and you have an empty folder2 in which to put the output images (so you do not overwrite your input images)

Code: Select all

cd folder1
mogify -path path2/folder2 -format png -type palettealpha *.png
Generally when doing this with convert, you will get the same results, but I thought that palettealpha data had binary alpha as when using PNG8:image.png for output. But with only -type palettealpha it seems to keep the 8-bit transparency, which is not what I thought was supported.

Code: Select all

convert logo: -transparent white PNG32:logo.png
convert logo.png -alpha on -channel a -blur +channel logo.png
The above makes a 32-bit png.

Code: Select all

convert logo.png -type palettealpha logo2.png 
give 8-bit alpha

but

Code: Select all

convert logo.png PNG8:logo3.png
gives binary alpha.
Post Reply