Page 1 of 1

Re: How to make color from top left pixel transparent?

Posted: 2008-04-27T15:09:50-07:00
by fmw42
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

Re: How to make color from top left pixel transparent?

Posted: 2008-04-27T15:30:53-07:00
by el_supremo
This will also do it:

Code: Select all

convert input.png -alpha on -fill none -draw 'color 0,0 replace' output.png
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

Re: How to make color from top left pixel transparent?

Posted: 2008-04-27T16:52:43-07:00
by fmw42
el_supremo:

your method is clearly superior to mine.

Re: How to make color from top left pixel transparent?

Posted: 2008-04-27T19:02:03-07:00
by el_supremo
Hi Fred:
your method is clearly superior to mine.
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.

Best Wishes
Pete

Re: How to make color from top left pixel transparent?

Posted: 2008-04-27T19:19:06-07:00
by fmw42
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