Convert black parts of an image to transparent par

2019-09-21 07:19发布

问题:

Hi guys I'm an animator working with textures that some of them need to Convert black parts of an image to transparent parts and it's really boring to sit and all the day do it with photoshop can't I do it with a batch file?tnx.

回答1:

Another Way is to use these 2 commands :

PNG2HEX.EXE

This will decompose your image in one pixel (in Hexa value) per line.

Then you can parse the output file and replace each ALPHA CHANEL from FF TO 00 (000000FF to 00000000 for BLACK -> Transparent)

and then rebuild it with

HEX2PNG.EXE

These examples are in FRENCH but if you have some problem I can make you an example in English.

You can build you're own filters in BAT with these commands.

Sure the imageMagick solution is easier (the filter is already done !). But if you want to make your own filters (steganographic, gray level,...) It stay a very good solution.

Download : https://goo.gl/614NH8



回答2:

Sure, use ImageMagick - it is free and available for Linux, OSX and Windows. The command you need is this:

convert image.png -transparent black result.png

and it turns into this:

If your blacks are not perfectly black, you can allow a fiddle factor like this:

convert image.png -fuzz 20% -transparent black result.png

If you want to apply that to all the PNG files in the current directory and save the results in a subdirectory called deblacked, you could do this:

mkdir deblacked
mogrify -path deblacked -transparent black *.png

Please try that on a COPY of your images first till you get the idea of it!