Do you want every pixel with that same color to be transparent or only the top left pixel to be transparent?
The former can be done either in two command lines:
color=`convert logo: -format "%[pixel:p{0,0}]" info:`
convert logo: -transparent $color logo_tmp.png
or combined into one command line
convert logo: -transparent $(echo `convert logo: -format "%[pixel:p{0,0}]" info:`) logo_tmp.png
see fx escapes:
http://www.imagemagick.org/Usage/transform/#fx_escapes
The latter can be done as follows:
convert rose: -alpha on -channel RGBA -fx "i==0&&j==0?none:u" rose_tmp.png
How to make color from top left pixel transparent?
-
- Posts: 1015
- Joined: 2005-03-21T21:16:57-07:00
Re: How to make color from top left pixel transparent?
This will also do it:
This will replace those pixels which are exactly the same colour as the one at (0,0).
If you also want it to match colours close to the one at (0,0), you can also add a fuzz factor, e.g. -fuzz 5% Put it before the -draw option.
Pete
Code: Select all
convert input.png -alpha on -fill none -draw 'color 0,0 replace' output.png
If you also want it to match colours close to the one at (0,0), you can also add a fuzz factor, e.g. -fuzz 5% Put it before the -draw option.
Pete
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to make color from top left pixel transparent?
el_supremo:
your method is clearly superior to mine.
your method is clearly superior to mine.
-
- Posts: 1015
- Joined: 2005-03-21T21:16:57-07:00
Re: How to make color from top left pixel transparent?
Hi Fred:
Best Wishes
Pete
I keep a file of "IM tidbits" that I have gleaned from this forum and the email reflector. I can't take the credit for it but unfortunately I don't remember who to give the credit to.your method is clearly superior to mine.
Best Wishes
Pete
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to make color from top left pixel transparent?
Hi Pete,
I, too, have been keeping an IM tidbits file from tips on the forum, from Anthony Thyssen and from things with which I have experimented. I keep my eye on the forums to learn new techniques and for challenges to try and for script ideas. I have added your method into my iM tidbits file.
Fred
I, too, have been keeping an IM tidbits file from tips on the forum, from Anthony Thyssen and from things with which I have experimented. I keep my eye on the forums to learn new techniques and for challenges to try and for script ideas. I have added your method into my iM tidbits file.
Fred