Convert a gray PNG with alpha to a 1-bit black rectanble with 8-bit alpha
Posted
by
jcayzac
on Super User
See other posts from Super User
or by jcayzac
Published on 2012-12-15T09:34:39Z
Indexed on
2012/12/15
11:08 UTC
Read the original article
Hit count: 391
conversion
|imagemagick
I use a tool to render LaTeX equations as PNG. The resulting images are in RGBA8888 format. I would like to extract the luminance (grayscale from RGB channels, multiplied by the A channel) as my new alpha channel, set the picture fully black, and save the result in Gray1Alpha8 (G1A8) format.
So far I've only managed to get G1A4 or G8A8 but not G1A8. Also, the resulting picture looks like it's not multiplied correctly…
convert original.png \
\( -clone 0 -alpha extract \) \
\( -clone 0 -clone 1 -compose multiply -composite \) \
-delete 0 +swap -alpha off -compose copy_opacity -composite -colorspace Gray -depth 4 result.png
What am I missing?
© Super User or respective owner