Creating a semi-transparent PNG with ImageMagick/convert

前端 未结 3 1519
北荒
北荒 2021-02-06 01:16

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:25

    To followup on Tony Bogdanov's comment. If you already have fully transparent pixels you may want to use the following strategy:

    1.) convert the transparent pixels into a mask

    convert -alpha extract input.png mask.png

    2.) perform the command listed in the answer above:

    convert input.png -alpha on -channel a -evaluate set 65% output.png

    3.) create a blank canvas the same size as the original image

    example: convert -size 700x800 xc:none blankcanvas.png

    4.) composite the semitransparent image and the blank canvas together using the transparent pixel mask

    composite output.png blankcanvas.png mask.png -compose Src final_output.png

提交回复
热议问题