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

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
john86b
Posts: 5
Joined: 2011-02-21T13:28:59-07:00
Authentication code: 8675308

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

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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
john86b
Posts: 5
Joined: 2011-02-21T13:28:59-07:00
Authentication code: 8675308

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

Post 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>
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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/
john86b
Posts: 5
Joined: 2011-02-21T13:28:59-07:00
Authentication code: 8675308

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

Post 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!!!!!!!!!!!!!!
Post Reply