Old VS New ImageMagick BMP to Transparent PNG

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
BDIL
Posts: 1
Joined: 2011-09-22T01:18:23-07:00
Authentication code: 8675308

Old VS New ImageMagick BMP to Transparent PNG

Post by BDIL »

Recently we had to move to a new server with a new imagemagick version. We always used the following to convert BMP's to transparent PNG's:

convert -limit memory 256mb -limit map 512mb TEST.bmp -transparent white -depth 8 -type PaletteMatte -shave 1x1 TEST.png

On the new server however the result is much different. The old server had ImageMagick 6.3.7, the new server version 6.6.2-6

On the old server I got a PNG with BitDepth 2, ColorType 3 and chunks: IHDR, PLTE, tRNS, BKGD, vpAG, IDAT and IEND
On the new server I get a PNG with BitDepth 8, ColorType 6 and chucks: IHDR BKGD, vpAG, IDAT, IDAT, tEXt, tEXt and IEND

The problem is that I am obligated to get a PNG with PLTE, tRNS chunks, BitDepth 2, ColorType 3. How would I achieve this result?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Old VS New ImageMagick BMP to Transparent PNG

Post by fmw42 »

PNG has undergone quite some development, though there are still some issues with -type. You might try upgrading. You might also try removing the -type palettmatte (what you need, though I don't see that option is -type bilevelmatte, though png may not support that) and then add PNG8: to your result image.

try this, though no guarantee that it will work:

convert -limit memory 256mb -limit map 512mb TEST.bmp -transparent white -depth 8 -shave 1x1 PNG8:TEST.png

The PNG developer will have to comment further as I am not an expert on PNG.
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: Old VS New ImageMagick BMP to Transparent PNG

Post by glennrp »

Try this.

Code: Select all

convert -limit memory 256mb -limit map 512mb TEST.bmp -transparent white  -colors 3  -shave 1x1 TEST.png
Your input file probably has only 4 colors or less, including the transparent color, so you can omit the "-colors 3".
You don't want to use PNG8 because that will force the bit-depth to be 8.
Post Reply