Page 1 of 1

Transparency in the BG when object has the same color as BG?

Posted: 2011-02-21T13:52:20-07:00
by john86b
Alright, I'm doing all the icons in an specific folder become transparent.
Here's one example of the icon: http://i.imgur.com/31xND.png
As you can see, the background is white, and there are white elements inside the icon.

Here's the code I used in a batch file:
for /f %%a in ('dir /b *.png') do C:\TestIco\imagik\convert %%a -fuzz 10%% -transparent white png32:alpha_%%a
pause
Here's the result:
http://i.imgur.com/d8nNr.png
Not bad, as you can see, until you put it somewhere that has a grey background. It removed the white elements inside the icon.

Photoshop background eraser tool does an AMAZING job at that. However, there are over 10.000 files like that, is there any way on earth to preserve the white elements inside the icons?


Thanks.

Re: Transparency in the BG when object has the same color as

Posted: 2011-02-21T14:08:12-07:00
by fmw42
try -draw with matte floodfill, see http://www.imagemagick.org/Usage/draw/#matte


convert 31xND.png -fuzz 10% -fill none -draw 'matte 0,0 floodfill' 31xND_trans.png

Re: Transparency in the BG when object has the same color as

Posted: 2011-02-21T14:17:25-07:00
by john86b
That sounds like a good idea, but I can't get this to work..

Code: Select all

C:\TestIco\imagik>convert AccessTableContacts.png -fuzz 10% -fill none -draw 'ma
tte 0,0 floodfill' alpha_AccessTableContacts.png
convert: Non-conforming drawing primitive definition `matte' @ error/draw.c/Draw
Image/3135.
convert: unable to open image `0,0': No such file or directory @ error/blob.c/Op
enBlob/2587.
convert: no decode delegate for this image format `0,0' @ error/constitute.c/Rea
dImage/532.
convert: unable to open image `floodfill'': No such file or directory @ error/bl
ob.c/OpenBlob/2587.
convert: no decode delegate for this image format `floodfill'' @ error/constitut
e.c/ReadImage/532.
convert: Non-conforming drawing primitive definition `matte' @ error/draw.c/Draw
Image/3135.

C:\TestIco\imagik>

Re: Transparency in the BG when object has the same color as

Posted: 2011-02-21T14:22:25-07:00
by fmw42
try with double quotes rather than single quotes. I am not on Windows and don't really know all the differences. But the windows article has a list.

What version of IM are you using?

http://www.imagemagick.org/Usage/windows/

Re: Transparency in the BG when object has the same color as

Posted: 2011-02-21T14:28:12-07:00
by john86b
Hi, double quotes also didn't work, going to look for the documentation see if I find anything relevant.
I downloaded this version from the Website: ImageMagick-6.6.7-Q16-windows.zip (Description: Portable Win32 static at 16 bits-per-pixel. Just copy to your host and run (no installer, no Windows registry entries).)

Edit: Wow, sorry, double quotes did work, I just didn't saw that I had accidentally deleted a character. Thank you so much!!!!!!!!!!!!!!