Page 1 of 1
Make an image transparent
Posted: 2011-05-09T13:45:03-07:00
by iam8up
I have a script that generates and image and such and I want to overlay this on Google Maps.
The only problem I have now is that I want to make the image (PNG) something like 65% transparent. Can this be done? I'm not sure if I am doing something wrong, as every argument I've tried either gives me no result or something I do not want.
Re: Make an image transparent
Posted: 2011-05-09T15:39:40-07:00
by fmw42
try
convert image.png -alpha set -channel a -evaluate set 65% +channel newimage.png
see
http://www.imagemagick.org/Usage/transf ... aluate_set
what IM version, platform and OS?
can you post a link to your image(s)?
Re: Make an image transparent
Posted: 2011-05-10T10:06:49-07:00
by iam8up
Thank you very much for the response.
This is the image I want to make transparent.
http://inxwireless.com/work/outage-orig.png
the -alpha argument doesn't take:
-> convert outage-orig.png -alpha set -channel a -evaluate set 65% +channel outage.png
convert: unrecognized option `-alpha'.
convert outage-orig.png -channel a -evaluate set 65% +channel outage.png
http://inxwireless.com/work/output.png
ImageMagick.i386 6.2.8.0-4.el5_5.3
-> cat /etc/redhat-release
CentOS release 5 (Final)
32-bit
Re: Make an image transparent
Posted: 2011-05-10T10:17:44-07:00
by fmw42
Your input image does not look like the correct link. The page is missing all images.
Your version of IM is too old (over 400 versions old) to use -alpha set and perhaps -evaluate set
If you cannot upgrade IM (highly recommended!), then
try
convert image.png -matte -channel a -evaluate set 65% +channel newimage.png
or
convert image.png -matte -channel a -evaluate set 35% +channel newimage.png
as the alpha channel at that time might be really opacity and not transparency
if that fails, try
convert image.png \( -clone 0 -fill "gray(65%)" -colorize 100% \) -compose copy_opacity -composite result.png
or
convert image.png \( -clone 0 -fill "gray(35%)" -colorize 100% \) -compose copy_opacity -composite result.png
Re: Make an image transparent
Posted: 2011-05-10T11:26:23-07:00
by iam8up
I fixed both links to images above, they should work now. Sorry about that.
I tried the first two commands and I don't see any differences between the output images and original.
The third command is missing a quote somewhere, so I did:
-> convert outage-orig.png \( -clone 0 -fill grey -colorize 100% \) -compose copy_opacity -composite result.png
Of which I don't see any change in the image either.
http://inxwireless.com/work/newimage.png
http://inxwireless.com/work/result.png
I'm guessing it has something to do with how the image is colored (alpha, palette, something of that sort). Total guess, mind you!
Re: Make an image transparent
Posted: 2011-05-10T11:52:10-07:00
by fmw42
try this (I fixed the quote and added +matte to turn off any existing alpha channel, sorry about the quote)
convert newimage.png \( -clone 0 -fill "gray(35%)" -colorize 100% \) +matte -compose copy_opacity -composite newimage_result.png
or
convert newimage.png \( -clone 0 -fill "gray(65%)" -colorize 100% \) +matte -compose copy_opacity -composite newimage_result.png
Then drop it on your browser's white background and you should see it look somewhat whiter as it is overlaid on the white background.
This also works for me:
convert newimage.png -matte -channel a -evaluate set 35% +channel newimage_result2.png
Re: Make an image transparent
Posted: 2011-05-10T13:11:30-07:00
by iam8up
I upgraded versions as your initial suggestion put. Since there is no repo for it, I had to do it semi-manually. This guide was used and was flawless short of the version (I used 6.6.9)
http://en.citizendium.org/wiki/User:Dan ... k_6.6.2-10
-> convert --version
Version: ImageMagick 6.6.9-8 2011-05-10 Q16
http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP
This worked! Thanks so so much!
convert outage-orig.png \( -clone 0 -fill "gray(35%)" -colorize 100% \) +matte -compose copy_opacity -composite newimage_result.png
Re: Make an image transparent
Posted: 2011-05-10T15:19:52-07:00
by fmw42
With your new release, the other method should work also and is shorter and faster.
convert newimage.png -alpha set -channel a -evaluate set 35% +channel newimage_result2.png
or
convert newimage.png -alpha opaque -channel a -evaluate set 35% +channel newimage_result2.png
Re: Make an image transparent
Posted: 2016-02-14T02:02:51-07:00
by Rye
It works, but there is one problem.
It replaces the "already present transperency" my pictures have with "black".
Any way to keep that transparancy aswell ?
Re: Make an image transparent
Posted: 2016-02-14T02:13:09-07:00
by fmw42
So what do you want to happen? You want to reduce the opacity of all pixels from whatever they have by 65%. If so, try this
Code: Select all
convert image.png -alpha on -channel a -evaluate multiply 0.65 +channel newimage.png
Re: Make an image transparent
Posted: 2016-02-14T03:48:48-07:00
by Rye
Perfect