Change color batch script

Moderator: Kathy_9

Post Reply
dbarselow
Posts: 1
Joined: Wed Apr 19, 2023 10:53 pm
operating_system: Windows 10
System_Drive: N/A
32bit or 64bit: 64 Bit

Change color batch script

Post by dbarselow »

Hello I want to learn how it is I can change a single color in a batch of gif files in the same folder, all are gradient type.

Thanks and,

best regards

Dbarselow
LeviFiction
Advisor
Posts: 6831
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: Change color batch script

Post by LeviFiction »

Interesting question. GIF images are 255 color indexed images. You can have the same RGB value located in multiple indexes. Though I imagine that's rare. At least so long as it's optimized. If it is optimized and the same color is not used in multiple indexes it's as simple as editing the index. The biggest problem is whether or not the color is at the same index in each image. If not, then we either need to use a selection tool such to select the color, or we need to make a smarter script that filters through the indexes until it finds the color. Are you a programmer? If not I'll start with what I think might work (haven't tried it) for recording a simple script.

Please note that if these are animated GIFs, PSP can only edit the first frame.

EDIT: So I found the instructions I gave originally won't work. Literally the easiest way to edit a color palette color is to go Edit -> Palette -> Edit Palette. Select the color you want to change and then change it. But this doesn't work well in scripts unless the exact same index is changed on all of the images. Attempting to record a script that changes the color in the normal way would require increasing and then decreasing the color count which could alter colors in unexpected ways. So here's a simple script that I think should work.

You use the script like so.
1) Put the script into your Scripts-Restricted folder
2) Open the script in Notepad
3) Find the lines OldColor = (0,0,0) and NewColor = (0,0,0). Change the values to be whatever the RGB value of your colors are. I show an example of this in the video demonstration.
4) Run the script to test it on a sample image.
5) File -> Batch Process, and use the script option.

Here's a video demonstration: https://drive.google.com/file/d/1HKmbO4 ... sp=sharing
Attachments
EditIndexColorBatch.zip
(846 Bytes) Downloaded 55 times
https://levifiction.wordpress.com/
Post Reply