I have over 200,000 images stored as transparent PNGs. I need to convert each to an alpha transparent, grayscale PNG. The settings of this PNG must match a specific format to be compatible with a GD and ImageMagick driven system.
Samples below have a goldenrod and lightblue backgrounds to show original transparency and converted transparency.
Sample Original File | Sample Output File (generated via Fireworks) | Fireworks Settings Used |
Sample Output File | ImageMagick Convert String Used |
Close but still a PNG32. :(convert -size 634x668 xc:white -matte white.png convert -size 634x668 xc:black -matte black.png convert \( original.png -quantize GRAY -colors 256 \) grayed.png composite -compose Dst_Over white.png grayed.png grayed_flat.png convert black.png \( grayed_flat.png -negate \) +matte -compose Copy_Opacity -composite -depth 8 -colors 16 composite_copy_opacity.png |
|
If we just add the png8: to above? Yup, a blank PNG. :(convert -size 634x668 xc:white -matte white.png convert -size 634x668 xc:black -matte black.png convert \( original.png -quantize GRAY -colors 256 \) grayed.png composite -compose Dst_Over white.png grayed.png grayed_flat.png convert black.png \( grayed_flat.png -negate \) +matte -compose Copy_Opacity -composite -depth 8 -colors 16 png8:composite_copy_opacity_png8.png |
Sample Output File | ImageMagick Convert String Used |
convert original.png -type GrayScaleMatte png8:grayscalematte_png8.png | |
convert -size 634x668 xc:transparent -matte original.png -compose Copy_Opacity -composite png8:transparent_compose_copy_opacity_png8.png | |
convert original.png -contrast-stretch 10% \( +clone \) +negate +matte -compose Copy_Opacity -composite -fill '#000000' -colorize 100%:contrast_stretch_compose_copy_opacity_colorize_png8.png | |
convert -compose Copy_Opacity original.png \( original.png -quantize GRAY -dither -colors 16 \) -composite -depth 8 png8:compose_copy_opacity_quantize_gray_png8.png |