0

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.

kmthrong kmthrongi
  • 145
  • 1
  • 5
  • 13
  • You need to show us what you have tried so far and describve precisely where you are stuck; the question as it is not is nothing but a vague task request... – aschipfl Jan 04 '16 at 14:28
  • Is there some console application built-in to Photoshop to do this? That would be the only way to do it with a Windows .bat file. You would then need to provide the name of the command and parameters for that application and we could then provide you a working Windows batch file. – Squashman Jan 04 '16 at 14:36
  • I would be curious to see if literally any programming language can do this. – SomethingDark Jan 04 '16 at 14:37
  • @SomethingDark It can be done in C, C++, C#, Perl, PHP, Python, Ruby, Ada, Java, Lisp... and others. – Mark Setchell Jan 04 '16 at 15:17

2 Answers2

3

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

enter image description here

and it turns into this:

enter image description here

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!

Mark Setchell
  • 191,897
  • 31
  • 273
  • 432
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

Community
  • 1
  • 1
SachaDee
  • 9,245
  • 3
  • 23
  • 33
  • TNX guys but by using image magick I get this error I mean: http://i66.tinypic.com/11j58b4.png – kmthrong kmthrongi Jan 07 '16 at 13:46
  • The reason you got that error is that you actually ran `c:\windows\system32\convert.exe` (which is part of Windows and converts filesystems to NTFS) rather than setting your PATH correctly or specifying the full path to the `convert` tool in the ImageMagick suite. That is, you need to do something like `C:\ImageMagick\bin\convert image.png -transparent ...` – Mark Setchell Jan 08 '16 at 10:54