Page 1 of 1
Change Transparent Background to Color/Opacity
Posted: 2013-09-09T22:15:14-07:00
by markfinch
I have some Social Media Icons that have a transparent background and I want to change the full transparency to semi-transparent colors. I have searched for hours but haven't found the magic bullet to do this.
How does one go about changing a transparent background to a translucent one? Thanks,
Mark
Re: Change Transparent Background to Color/Opacity
Posted: 2013-09-09T22:25:21-07:00
by fmw42
try
convert image.png -background "rgba(r,g,b,a)" -flatten result.png
for color definitions, see
http://www.imagemagick.org/script/color.php
(note alpha values in rgba format are always in the range 0 to 1)
Re: Change Transparent Background to Color/Opacity
Posted: 2013-09-10T06:26:23-07:00
by markfinch
fmw42 wrote: convert image.png -background "rgba(r,g,b,a)" -flatten result.png
didn't work on Ubuntu 13.04. For some reason both rgba and the -flatten shortcut did not work.
What did work is:
Code: Select all
convert image.png -background '#RRGGBBAA' -layers flatten result.png
I must have typed basically that command a dozen times yesterday with variations on the color with both rgba() and hex values not in ' and with/without -flatten shortcut to no avail. Any ideas why RGBA, hex not in ' and shortcuts don't work?
Thanks a lot.
M
Re: Change Transparent Background to Color/Opacity
Posted: 2013-09-10T07:10:54-07:00
by snibgo
Users of Ubuntu often seem to be running very old versions of IM. What is your version?
Re: Change Transparent Background to Color/Opacity
Posted: 2013-09-10T10:49:41-07:00
by fmw42
what was the exact value for rgba(....) that you used. It works fine for me on IM 6.8.6.9 Q16 Mac OSX.
Re: Change Transparent Background to Color/Opacity
Posted: 2013-09-11T11:14:41-07:00
by markfinch
Ubuntu 13.04 with ImageMagick 6.7.7-10 (although I think it was just updated today and haven't tried using rgba yet. Just double checked the package log and it was updated today. Not certain what the previous version was.) Although it would seem even if they aren't on the latest something as basic as that command would work since it has been available for awhile. Guessing it is some option not enabled by the package maintainer.
the line was convert file -background "rbga(0,0,0,.8)" -layers flatten, newfile and also did single quote ' and a grey value of 55,55,55,.8 as well as used 0.8.
Decided to go ahead and do a quick check with the new version and it still generates an errors.
convert.im6: unrecognized option `-flatten,' @ error/convert.c/ConvertImageCommand/1582.
convert.im6: unrecognized color `rbga(0,0,0,0.8)' @ warning/color.c/QueryMagickColorCompliance/2684
If one of you can confirm this command works with a png with a transparent background and sets the background to a translucent black or grey I will file a bug in Launch Pad on this.
Re: Change Transparent Background to Color/Opacity
Posted: 2013-09-11T11:43:30-07:00
by snibgo
Code: Select all
convert.im6: unrecognized option `-flatten,' @ error/convert.c/ConvertImageCommand/1582.
Don't use a comma.
Re: Change Transparent Background to Color/Opacity
Posted: 2013-09-11T12:52:45-07:00
by markfinch
snibgo wrote:Don't use a comma.
Comma was in there from the bash script I was using and has to be there, but on single convert removing the comma does work for using flatten shortcut. Although the rgba error is still thrown. Next time I am running the script I will try putting a space between -flatten and comma.
Re: Change Transparent Background to Color/Opacity
Posted: 2013-09-11T13:02:01-07:00
by fmw42
You cannot have a comma in IM syntax even with spaces in bash script. Why do you think you need that? What was your full command? Do you need it for some other calling API such as PHP?