Search code examples
graphicsmagick

How to create a transparent image with GraphicsMagick CLI?


I'm coming up empty handed while trying to find out how to modify the opacity of an image using the GraphicsMagick CLI. I'm simply trying to input a standard image and convert it to the corresponding image with a reduced opacity. I'm running GraphicsMagick 1.3.14. Using ImageMagick, I can issue the command:

convert input.png -alpha set -channel a -evaluate set 50% +channel output.png

However, the -alpha option (among others) is unrecognized as a valid GM convert option (convert option reference here). Any help would be greatly appreciated.


Solution

  • This question was cross-posted on SuperUser, as I later thought SuperUser might be the more appropriate outlet. To quote Bob Friesenhahn:

    The equivalent in GraphicsMagick is

    gm convert input.png -operator Opacity Multiply 0.5 output.png

    or

    gm convert input.png -operator Opacity Assign 50% output.png

    depending on what you really want to do (modulate or assign).

    You should add -matte prior to -operator if you don't know if the image already has an active opacity channel.

    Bob