Transparency level for image

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
KaGeUa

Transparency level for image

Post by KaGeUa »

I think that it must me very easy but I can`t find option to make transparency for the image

I`m currently have code
convert image.jpg -colorize 100,0,0 image2.jpg

What should I add here to get image2.jpg with 0.7 transparency

Thanks in advance
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Transparency level for image

Post by fmw42 »

KaGeUa wrote:I think that it must me very easy but I can`t find option to make transparency for the image

I`m currently have code
convert image.jpg -colorize 100,0,0 image2.jpg

What should I add here to get image2.jpg with 0.7 transparency

Thanks in advance

I am not sure what you are doing, but your use of -colorize is just selecting the red channel and turning the green and blue channels to black. If you want to colorize an image (mix in some color) then typically you would use -fill somecolor -colorize XX%. That would mix in somecolor by XX% to all channels.

Nevertheless if you want to set the transparency to some constant value across the image, you can use

convert image -alpha set -channel A -evaluate set 30% result

to get a 70% transparent image. See http://www.imagemagick.org/Usage/canvas/#other


If you just want to create a color image with some transparency, then

convert -size WxH xc:"rgba(R,G,B,A)" result


If you have a binary image, you can set the transparency with -alpha copy. see http://www.imagemagick.org/Usage/basics/#alpha


Perhaps you can explain further what you want to do?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Transparency level for image

Post by anthony »

[quote="KaGeUa"
What should I add here to get image2.jpg with 0.7 transparency[/quote]

First -- JPEG can't save transparency!!!! You need to use some other format to save transparency like PNG.

Second just add a alpha channel and multiply it (or as JPEG are fully opaque you can just set it too.

Code: Select all

  convert image.jpg -alpha set -channel A -evaluate multiply 0.7 +channel   image_semitransparent.png 
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply