Help with transparency to a newbie

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
hrqmonteiro
Posts: 5
Joined: 2018-07-20T18:29:45-07:00
Authentication code: 1152

Help with transparency to a newbie

Post by hrqmonteiro »

Hi i'm using this code i found on the net which uses ImageMagick:

Image

And on this field who generates that background, if i clear it the whole background becames full transparent, but what i wanted to do is to set the image to match my terminal, which uses the color #000 with 70% opacity. Is there a way to do it? I tried to fint through the search engine but every code i tried (some like this: \( -alpha set -channel A -evaluate set 60% \) -draw "image over 169,555 875,109 'img1.png'") but it didnt work, can someone help me please?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Help with transparency to a newbie

Post by fmw42 »

You can specify the color as hex with alpha values by adding two more characters or better you can use rgba(r,g,b,a) values in your command. See http://www.imagemagick.org/script/color.php

________________

Please, always provide your IM version and platform when asking questions, since syntax may differ. Also provide your exact command line and if possible your images.

See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at http://www.imagemagick.org/discourse-se ... f=1&t=9620

If using Imagemagick 7, then see http://imagemagick.org/script/porting.php#cli


For novices, see

http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown
hrqmonteiro
Posts: 5
Joined: 2018-07-20T18:29:45-07:00
Authentication code: 1152

Re: Help with transparency to a newbie

Post by hrqmonteiro »

fmw42 wrote: 2018-07-20T19:12:46-07:00 You can specify the color as hex with alpha values by adding two more characters or better you can use rgba(r,g,b,a) values in your command. See http://www.imagemagick.org/script/color.php

________________

Please, always provide your IM version and platform when asking questions, since syntax may differ. Also provide your exact command line and if possible your images.

See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at http://www.imagemagick.org/discourse-se ... f=1&t=9620

If using Imagemagick 7, then see http://imagemagick.org/script/porting.php#cli


For novices, see

http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown
I'm using ImageMagick 7 and writing like this really dont work, and i've looked through this page you sent before posting in here, where do i find a way to do it on ImageMagick 7? Can you be more specific? As i said i would like to set 70% transparency, thats all
hrqmonteiro
Posts: 5
Joined: 2018-07-20T18:29:45-07:00
Authentication code: 1152

Re: Help with transparency to a newbie

Post by hrqmonteiro »

Can't someone just say to me which line i write after the background to make it 70% transparent, please?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Help with transparency to a newbie

Post by fmw42 »

hrqmonteiro wrote: 2018-07-20T19:30:24-07:00 Can't someone just say to me which line i write after the background to make it 70% transparent, please?
what i wanted to do is to set the image to match my terminal, which uses the color #000 with 70% opacity

Hex #000 is black and the same as rgb(0,0,0). But you want to have it with 70% opacity.

Code: Select all

"rgba(0,0,0,0.7)"
keep the quotes in on Unix.
hrqmonteiro
Posts: 5
Joined: 2018-07-20T18:29:45-07:00
Authentication code: 1152

Re: Help with transparency to a newbie

Post by hrqmonteiro »

fmw42 wrote: 2018-07-20T19:36:34-07:00
hrqmonteiro wrote: 2018-07-20T19:30:24-07:00 Can't someone just say to me which line i write after the background to make it 70% transparent, please?
what i wanted to do is to set the image to match my terminal, which uses the color #000 with 70% opacity

Hex #000 is black and the same as rgb(0,0,0). But you want to have it with 70% opacity.

Code: Select all

"rgba(0,0,0,0.7)"
keep the quotes in on Unix.
Didn't work

Image
hrqmonteiro
Posts: 5
Joined: 2018-07-20T18:29:45-07:00
Authentication code: 1152

Re: Help with transparency to a newbie

Post by hrqmonteiro »

Man i just wanted it to match the colors... wouldnt it be possible?...
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Help with transparency to a newbie

Post by fmw42 »

If the background is not transparent enough, then change to

Code: Select all

"rgba(0,0,0,0.3)"
Note that if you are saving to JPG, JPG does not support transparency. You will need to save to PNG or TIFF.

Try these two simple commands. Do either give the background you want?

Code: Select all

convert rose: -gravity center -background "rgba(0,0,0,0.7)" -extent 150x150 result1.png
convert rose: -gravity center -background "rgba(0,0,0,0.3)" -extent 150x150 result2.png

If that does not work, then please clarify exactly what you want changed and where.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Help with transparency to a newbie

Post by fmw42 »

hrqmonteiro wrote: 2018-07-20T19:50:21-07:00 Man i just wanted it to match the colors... wouldnt it be possible?...
Are you sure you know exactly what the color is that you want to match?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Help with transparency to a newbie

Post by fmw42 »

I cannot read your screen snap very well. Did you use

rgbo(0,0,0,0.7) with an O after rgb

or

rgba(0,0,0.0.7) with an A after rgb

O is incorrect. A is correct.
Post Reply