Search code examples
imageimage-manipulationimage-editing

Application/script for merging images, applying color, black & white filter in batch?


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. (I'm using Windows)

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

I think there must be an application capable of this.

But if not, is there a way to quickly do this in some programming/script language for example in Python?


Solution

  • Here's the best you can hope for without providing any images or expected results. I am using the following as background, image A and image B:

    enter image description here enter image description here enter image description here

    Then using ImageMagick, like this:

    magick background.png -gravity center \
       \( a.png -fill "#ff00ff" -tint 70% -resize 64x64   -geometry -30-40 \) -composite \
       \( b.png -fill "#00ff00" -tint 85% -resize 100x100 -geometry +0+0   \) -composite \
       -write coloured.png \
       -colorspace gray grey.png
    

    You'll get:

    enter image description here enter image description here

    If using Windows, you'll need to:

    • replace any \ at end of line with caret ^
    • remove any \ before opening and closing parentheses ( and )
    • change any single quotes to double quotes
    • mess around with any % signs using some arcane Microsoft rules about doubling them up to make sure it really does what you asked it in batch files.