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
Change Transparent Background to Color/Opacity
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Change Transparent Background to Color/Opacity
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)
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
didn't work on Ubuntu 13.04. For some reason both rgba and the -flatten shortcut did not work.fmw42 wrote: convert image.png -background "rgba(r,g,b,a)" -flatten result.png
What did work is:
Code: Select all
convert image.png -background '#RRGGBBAA' -layers flatten result.png
Thanks a lot.
M
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Change Transparent Background to Color/Opacity
Users of Ubuntu often seem to be running very old versions of IM. What is your version?
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Change Transparent Background to Color/Opacity
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
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.
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.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Change Transparent Background to Color/Opacity
Code: Select all
convert.im6: unrecognized option `-flatten,' @ error/convert.c/ConvertImageCommand/1582.
snibgo's IM pages: im.snibgo.com
Re: Change Transparent Background to Color/Opacity
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.snibgo wrote:Don't use a comma.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Change Transparent Background to Color/Opacity
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?