Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can I use GIMP to batch process .png files?
#1
Question 
I'm working on recolouring resource asset files for iTunes to create a dark mode theme - I managed to extract the files and now I'm searching a way to modify the extracted .png files.

The directory looked like this:
[Image: bef.png]

I went through the first 50 or so files manually adjusting the hue/saturation in Photoshop and they are starting to look much more like a dark mode theme:
[Image: aft.png]

Although manually editing them was a sound approach for testing the alterations, there are around 3000 extracted .png files in total so I'm searching for a way to process all of these files as a batch.

I was wondering if there was a way that GIMP could do this - perhaps a script that replaces certain colours with other colours so that it would be possible to create a variety of skins/themes in the future, for many different software. A script that could replicate the photoshop changes (hue/saturation adjustments) as a batch would suffice too as I would still be able to create a very basic dark mode theme for the community.
Reply
#2
There is a Gimp batch plugin BIMP see: https://alessandrofrancesconi.it/projects/bimp/

The BIMP commands are a bit meagre - Colour Correction is brightness / contrast but it also uses Other Gimp Procedures where you can use the Gimp Hue-Saturation function.

There is also a Gimp plugin gimp_gmic_qt from http://www.gmic.eu which has all sorts of filters, there is a colour swao for example. BIMP can use this plugin, again as a 'Other Gimp Procedure'

It can get a bit complicated to explain and I am packing in for the day, Have a look at BIMP and gmic. If you can post a few of those icons you have already done, before and after and I can make a procedure example for you.
Reply
#3
Two possibilities


Using a CLUT

Looking at two images that only differ by the colors you can construct a "Color Lookup Table" (CLU) that maps every color in an image to the corresponding color in the other. A"full" CLUT  maps 16Million colors, (three 8-bit channels), but when you accept some interpolation you can make a CLUT that has entries for only 6 bits (so 262K colors) or 4bit (4096 colors).

When you have obtained the CLUT that goes from one image to anot,er you can apply the same CLUT to all other image in the same theme to produce the images for the other theme. Determining the CLUT is is done with the GMIC plugin. Applying the CLUT en masse is done with the GMIC application (outside of GIMP).

One restriction is that you have to make the CLUT with an image that contains a decent sample of the mapped colors. Colors in another image that are quite different from the ones in the source image run the risk of being strangely interpolated.

Using tiles


If all your images are the same size, you can create a big layer from them,  apply the color changes on that big layer, and split the layer back to individual files.. I have scripts for this.

The restriction is that you lose the tile-file association, so you have to maintain this on the side and perhaps rename the files at the end suing a shell script (note that my script allows consistent naming schemes for the output files so it is not as nightmarish as it seems).
Reply
#4
(01-09-2024, 09:28 PM)rich2005 Wrote: There is a Gimp batch plugin BIMP see: https://alessandrofrancesconi.it/projects/bimp/

The BIMP commands are a bit meagre - Colour Correction is brightness / contrast but it also uses Other Gimp Procedures where you can use the Gimp Hue-Saturation function.

There is also a Gimp plugin gimp_gmic_qt from http://www.gmic.eu which has all sorts of filters, there is a colour swao for example.  BIMP can use this plugin, again as a 'Other Gimp Procedure'

It can get a bit complicated to explain and I am packing in for the day, Have a look at BIMP and gmic. If you can post a few of those icons you have already done,  before and after  and I can make a procedure example for you.

Hi Rich thanks so much for the quick and super helpful reply - I'll have a look into BIMP and gmic first thing tomorrow morning, they sound very promising - thank you again for the suggestions -

In the meantime I've attached a few icons as requested - a procedure example would be incredibly helpful thank you!  Big Grin

(01-09-2024, 09:47 PM)Ofnuts Wrote: Two possibilities


Using a CLUT

Looking at two images that only differ by the colors you can construct a "Color Lookup Table" (CLU) that maps every color in an image to the corresponding color in the other. A"full" CLUT  maps 16Million colors, (three 8-bit channels), but when you accept some interpolation you can make a CLUT that has entries for only 6 bits (so 262K colors) or 4bit (4096 colors).

When you have obtained the CLUT that goes from one image to anot,er you can apply the same CLUT to all other image in the same theme to produce the images for the other theme. Determining the CLUT is is done with the GMIC plugin. Applying the CLUT en masse is done with the GMIC application (outside of GIMP).

One restriction is that you have to make the CLUT with an image that contains a decent sample of the mapped colors. Colors in another image that are quite different from the ones in the source image run the risk of being strangely interpolated.

Using tiles


If all your images are the same size, you can create a big layer from them,  apply the color changes on that big layer, and split the layer back to individual files.. I have scripts for this.

The restriction is that you lose the tile-file association, so you have to maintain this on the side and perhaps rename the files at the end suing a shell script (note that my script allows consistent naming schemes for the output files so it is not as nightmarish as it seems).

Thanks so much for the reply! I did see a similar thread before posting mine which had a link to your scripts - this was the first thing I tried (combining them all as a layer) and unfortunately it threw a few error messages. I presumed it was because I was trying to process too many image files in one action but after reading your above comment, it may be because the resource asset image files pulled from the original .dll vary drastically in size.

The idea of Color Lookup Tables sounds extremely promising and I've been looking for something like that for a long time. It sounds like if I can familiarize myself with producing CLUTs, I can streamline producing recolours/themes for many of my proposed projects - many thanks for that suggestion and I will certainly research it extensively in the morning  Big Grin


Attached Files Image(s)
                                       
Reply
#5
Examples using BIMP.  A lot to describe in words and screenshots, it will have to be videos. Each about 4 minutes, no great ordeal.

1. Using BIMP to desaturate using Hue-Saturation.






2. BIMP and the gmic plugin to colour using gmic presets.



Reply
#6
(01-10-2024, 11:28 AM)rich2005 Wrote: Examples using BIMP.  A lot to describe in words and screenshots, it will have to be videos. Each about 4 minutes, no great ordeal.

Wow these are absolutely fantastic! Thank you so much for these extremely clear and helpful tutorials, I really appreciate you taking the time to make these so straight-forward and easy to follow. Absolutely perfect, I truly appreciate it thank you!  Big Grin  Big Grin Big Grin
Reply


Forum Jump: