2

How can I create an empty (transparent) PNG containing 24 bit color channels with ImageMagick? The obvious one

    convert -size 1920x1080 xc:transparent blank.png      

will create an 1bit b/w image with alpha channel. Adding some options like

convert -size 1920x1080 xc:transparent  -colorspace rgb  -type truecolor blank.png

which work for .jpg format, still gains the same 1bit result. Any ideas?

3

ImageMagick defines several "sub-formats" for PNG that can be used to request the encoder to write a particular PNG color-type and bit-depth. By 24-bit I assume you mean 8-bit red, green, and blue channels; for that use the png24 subformat:

convert -size 1920x1080 xc:transparent png24:blank.png

Note that "xc:transparent" creates an image with an alpha channel, which will be conveyed in a PNG24 via a PNG tRNS chunk. If you don't want that, then specify a non-transparent color such as "xc:white" instead.

Other possibilities are png8 (8-bit indexed with binary transparency), png32 (8-bit-per-channel RGBA), png48 (16-bit-per channel RGB), and png64 (16-bit-per-channel RGBA).

Type

convert -list format | grep PNG

to see what's available in your ImageMagick installation.

  • Ah cool. So the internal color format is actually not used, but the selection is made by the output format. The png24: worked well for me. Thanks! – dronus Jun 28 '15 at 20:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.