Replacing a colour with transparency in a batch process

Moderator: Kathy_9

piffle
Posts: 2
Joined: Sat Feb 05, 2022 12:35 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Not Known
processor: AMD Ryzen 5 2600X
ram: 16GB
Video Card: GeForce GTX 1060 6GB
sound_card: Not Known
Hard_Drive_Capacity: 2TB
Monitor/Display Make & Model: Dell
Corel programs: PSP 2020, Painter 2020

Replacing a colour with transparency in a batch process

Post by piffle »

Hi all! First post and still learning after switching from a very old version of Photoshop to PSP 2020! I have a folder of images each with a single colour that I want to replace with transparency. From what I've discovered so far the PNG Optimizer seems to be the way to achieve this. I have no problem doing it manually with a single image; what I can't figure out is how to incorporate that functionality into a batch process. Any pointers appreciated; apologies if I'm being a bit dim.
Jean-Luc
Advisor
Posts: 1997
Joined: Sat Oct 22, 2011 10:50 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: ASUS Computer N751J
processor: Intel i7_4710 HQ 2_50GHz
ram: 16GB
Video Card: NVIDIA GeForce GTX 850M
sound_card: NVIDIA High Definition Audio
Hard_Drive_Capacity: 2 Tb
Monitor/Display Make & Model: NVIDIA GeForce GTX 850M
Corel programs: PSP X7, X9, 2018 to 2023
Location: Belgium (French speaking)

Re: Replacing a colour with transparency in a batch process

Post by Jean-Luc »

See if this script (Remove Any Color) could help you:
https://forum.corel.com/viewtopic.php?t=65307
THE PAINTSHOP PRO COOKBOOK
Installed PSP Ultimate: X7, X9, 2018, 2019, 2020, 2021, 2022, 2023
LeviFiction
Advisor
Posts: 6472
Joined: Thu Oct 02, 2008 1:07 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Alienware M17xR4
processor: Intel Core i7-3630QM CPU - 2_40GH
ram: 6 GB
Video Card: NVIDIA GeForce GTX 660M
sound_card: Sound Blaster Recon3Di
Hard_Drive_Capacity: 500GB
Corel programs: PSP: 8-2023
Location: USA

Re: Replacing a colour with transparency in a batch process

Post by LeviFiction »

EdIt: That script Jean-Luc just pointed to does the exact same thing I was just about to recommend. :D And it's pre-made so huge bonus.

If you're curious how the script works, read further on, but yeah my suggestion and Jean-Luc's are essentially the same so you can ignore this.

Technically the PNG optimizer actually erases the color selected from the resulting image. The result is a layer transparency. So you don't actually need to use the optimizer. You could do something like this.

1) Promote Background Layer if it's not already a full Raster Layer
2) Select All ( Ctrl + A)
3) Selections -> Modify -> Select Color Range
4) Set the values of the dialog box to
Tolerance: 1
Softness: 0
Reference Color: The color you want to remove
Subtract Color range

5) Hit OK, the selection should not have everything but the color you chose selected.
6) Selections -> Invert (now only your color is selected)
7) Edit -> Clear (Delete key)
8) Selections -> None ( Ctrl + D)

Your image is now in the exact same state it is when using the PNG Optimizer. This can easily be scripted by just recording the steps into a script. Then in the batch process set this script to be one of the processes performed on the image. And let the Batch Process save the image as a PNG.
piffle
Posts: 2
Joined: Sat Feb 05, 2022 12:35 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Not Known
processor: AMD Ryzen 5 2600X
ram: 16GB
Video Card: GeForce GTX 1060 6GB
sound_card: Not Known
Hard_Drive_Capacity: 2TB
Monitor/Display Make & Model: Dell
Corel programs: PSP 2020, Painter 2020

Re: Replacing a colour with transparency in a batch process

Post by piffle »

Many thanks to both of you. The pre-written script wasn't behaving quite as I wanted so I ended up following LeviFiction's steps and recording my own script. It worked perfectly.