Converting RGB color to transparent

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
BajungaDustin
Posts: 15
Joined: 2016-06-29T11:40:12-07:00
Authentication code: 1151

Converting RGB color to transparent

Post by BajungaDustin »

I have a series of Images i need to turn into a gif with transparent background.

When i try to convert the RGB it does nothing.

when i do

Code: Select all

>Convert 00*.png -transparent -fill "rgb(0,255,0)" test.png
i get

Code: Select all

Convert: unrecognized color `-fill' @ warning/color.c/GetColorCompliance/1045.
Convert: unable to open image 'rgb(0,255,0)': No such file or directory @ error/blob.c/OpenBlob/2695.
Convert: no decode delegate for this image format `' @ error/constitute.c/ReadImage/508.
When i try

Code: Select all

>convert -fill "rgb(0,255,0)" +transparent 00*.png test.png
i get

Code: Select all

convert: no images defined `test.png' @ error/convert.c/ConvertImageCommand/3235.
im not real good with this program and only have to use it a few times a year seems like. But im recently setting up some stream alerts for a friend and cant get the green background to go away. And yes it is a perfect 0,255,0 but im not sure if i am laying the commands out correctly.

Any help would be great.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Converting RGB color to transparent

Post by fmw42 »

convert 00*.png -transparent "rgb(0,255,0)" test.png
BajungaDustin
Posts: 15
Joined: 2016-06-29T11:40:12-07:00
Authentication code: 1151

Re: Converting RGB color to transparent

Post by BajungaDustin »

fmw42 wrote:convert 00*.png -transparent "rgb(0,255,0)" test.png
didnt work.. still green

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

Re: Converting RGB color to transparent

Post by fmw42 »

You probably do not have pure green. As I measure it, it is rgb(11, 253, 9) and not rgb(0,255,0), So add -fuzz XX% before -transparent. Find the smallest % that works adequately. Since you have antialiasing in your image so that the green mixes with the outline of your small images, you will need a fairly substantial fuzz value. This seems to work, but you may want to tune it more.

Code: Select all

convert test.png -fuzz 30% -transparent green1 result.png
BajungaDustin
Posts: 15
Joined: 2016-06-29T11:40:12-07:00
Authentication code: 1151

Re: Converting RGB color to transparent

Post by BajungaDustin »

fmw42 wrote:You probably do not have pure green. As I measure it, it is rgb(11, 253, 9) and not rgb(0,255,0), So add -fuzz XX% before -transparent. Find the smallest % that works adequately. Since you have antialiasing in your image so that the green mixes with the outline of your small images, you will need a fairly substantial fuzz value. This seems to work, but you may want to tune it more.

Code: Select all

convert test.png -fuzz 30% -transparent green1 result.png

Ok so that worked but it gave me a bad result

Image

Will more fuzz reduce the amount of green left around the edges of the model? or less fuzz?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Converting RGB color to transparent

Post by fmw42 »

You need a larger fuzz value. The fuzz value is how close to your color you want to remove. 0% will remove only the exact color. A larger value will remove colors further from your specified color.
BajungaDustin
Posts: 15
Joined: 2016-06-29T11:40:12-07:00
Authentication code: 1151

Re: Converting RGB color to transparent

Post by BajungaDustin »

fmw42 wrote:You need a larger fuzz value. The fuzz value is how close to your color you want to remove. 0% will remove only the exact color. A larger value will remove colors further from your specified color.
Awesome.. Thank you
Post Reply