Creating a semi-transparent PNG with ImageMagick/convert

前端 未结 3 1597
野性不改
野性不改 2021-02-06 01:11

I have PNG files that I would like to convert the whole image to be semi-transparent.

The image will be referenced in a KML file as an icon overlay for use in Google Ear

3条回答
  •  执笔经年
    2021-02-06 01:34

    convert input.png -alpha set -channel A -evaluate Divide 2 output.png
    

    Thank you @caw for pointing this out in your comment. This helps in the case where the image already has some transparent pixels. -evaluate set 50% ruins the already-transparent pixels that had alpha 0, setting their alpha to 50%, which is often not desirable.

    -evaluate Divide 2 preserves the alpha, since fully transparent pixels are alpha 0, and 0 divided by 2 is still 0.

提交回复
热议问题