Gimp-Forum.net
Merging images, applying color saving in color and in black & white? - Printable Version

+- Gimp-Forum.net (https://www.gimp-forum.net)
+-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP)
+--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP)
+---- Forum: Scripting questions (https://www.gimp-forum.net/Forum-Scripting-questions)
+---- Thread: Merging images, applying color saving in color and in black & white? (/Thread-Merging-images-applying-color-saving-in-color-and-in-black-white)



Merging images, applying color saving in color and in black & white? - tudvari - 03-30-2021

I'm making achievements for my game, and I would like to make an automated process to save a lot of time instead of doing it manually.

So I'd like to make a GIMP script doing this for me Big Grin But I'm complete noobie with it. Could you help me please?

The inputs of this process would be
  • one rectangular opaque background image (i.e. 200x200 PNG)
  • Color A, (i.e. in hex)
  • Color B, (i.e. in hex)
  • and multiple same sized, rectangular, transparent foreground images. (i.e. 200x200 PNG)

And the process would do this for every foreground image:
  1.  Start with the background image.
  2.  Merge the foreground image with Color A filter applied, and also with an offset from the middle.
  3.  Merge the foreground image with Color B filter applied, in the middle.
  4.  Save the result in a file.
  5.  Apply a black & white filter and save the result in a file.
So the output would be for example multiple 200x200 PNG images, each of it having a colored and a black & white version

Could you help me please? Smile


RE: Merging images, applying color saving in color and in black & white? - Ofnuts - 03-30-2021

"with Color A filter applied", what do you mean by this? Can you post example images (input and output)?

Also, since you don't seem to be using any fancy filters/tools in Gimp, this is likely faster to do with ImageMagick in a shell script. The learning curve would be somewhat easier.


RE: Merging images, applying color saving in color and in black & white? - rich2005 - 03-30-2021

Same as Ofnuts easier with ImageMagick (IM) although it does depend on those 'color filters you want to use. 
Looking through my IM notes, I can maybe help a little, save a hunt through the IM documentation.

This is for a single image  It needs to be wrapped up in a Windows batch file (I use linux, no good with Win bat files )

Code:
magick fg.png -colorspace gray -fill "rgb( 0, 128, 0)" -tint 100 temp01.png
magick fg.png -colorspace gray -fill "rgb( 128, 0, 0)" -tint 100 temp02.png
magick composite -gravity center temp01.png  bg.png temp03.png
magick composite -gravity center -geometry +20+20  temp02.png temp03.png colored.png
magick colored.png -colorspace gray gs.png

Just linear application of commands (1) and  (2) colorise the overlay. (3) adds first overlay (4) adds second overlay at an offset (5) makes new greyscale from (4)  

[attachment=5810]


RE: Merging images, applying color saving in color and in black & white? - tudvari - 03-30-2021

Thanks! It seems to work, even if it took me 2 hours to make it work in a batch file Big Grin

One question:
I tried adding the "-resize 250x250" flag to the composite command, and also to the "load" commands, but at best it wasn't resized, at worst it crashed the batch file.
How could I do it? Thanks in advance! Smile

Also, is there an option to dynamically darken a given rgb value?

Because I want to input only one color:
- the centered foreground would be in that color,
- but the offsetted one would be in a darker version of that.


RE: Merging images, applying color saving in color and in black & white? - tudvari - 03-31-2021

I've got a problem: I switched to a white foreground (transparent with white on it), but now the colorisation doesn't work. Why?
I've tried removing the -colorspace gray flags, but it didn't help.


RE: Merging images, applying color saving in color and in black & white? - rich2005 - 03-31-2021

Quote:Also, is there an option to dynamically darken a given rgb value?
Because I want to input only one color:
- the centered foreground would be in that color,
- but the offsetted one would be in a darker version of that.

I do not know, your best bet for anything IM is ask on the Imagemagick forum. https://github.com/ImageMagick/ImageMagick/discussions
Very helpful there, remember to state your IM version.

Quote:I switched to a white foreground (transparent with white on it), but now the colorisation doesn't work. Why?
I've tried removing the -colorspace gray flags, but it didn't help.

A bit like Gimp you can get an Indexed png if you are not careful. This seems to work, a white shape on transparent.

Code:
magick white.png -colorspace RGB -fuzz 20% -fill  "rgb(50, 100, 40)" +opaque   "#00000000"  png32:coloured.png



RE: Merging images, applying color saving in color and in black & white? - tudvari - 03-31-2021

I managed to fix it by changing tint to colorize Smile Thanks for the help, I will look out there as well.