Search code examples
iconsimagemagicktransparencyalphaimagemagick-convert

How to add transparency to a PNG image with ImageMagick


How to add transparency to a PNG image using ImageMagick?
How to reduce PNG file opacity using ImageMagick?
How to modify a PNG's alpha channel using ImageMagick?

Use case:
You have several PNG images like this (Source opacity: 100%)
Source image

And what to increase their transparency like this (Target opacity: 70%)
Wished result

Using ImageMagick's convert command, allowing to script and process hundreds of icons at a time.

(Note: Background pattern is only used to highlight transparency)


Solution

  • You can use one of the following command:

    $ convert input.png -matte -channel A +level 0,70% +channel output.png
    

    This command will add 30% transparency (decrease opacity from 100% to 70%)

    Source