Tool imagemagick tile recoloring

Discussion in 'Starbound Modding' started by Storm_UK, Jul 3, 2017.

  1. Storm_UK

    Storm_UK Existential Complex

    I recently discovered imagemagick which has made the process of turning a bunch of tile png files I had (in my Greebles mod) into full multi-coloured variants a lot easier.

    It allowed turning a png such as this:

    geometricpanel.png

    into this:

    geometricpanel.png

    without having to resize and recolor each row in a paint program by hand.

    It took a while figuring out, but I created a few .bat files which automated the process for me.

    tilepainter.bat
    Code:
    @echo off
    setlocal
    
    (
      for %%f in (opulent*.png) do (
      tilerecolor.bat %%f "#9da8af" "#676f83" "#3d3d51" "#24232f"
      )
    )
    
    The above bat file when double clicked would go through every png matching the given filename (in this case opulentpanel.png, opulentbeam.png, etc.) in the same folder as itself and run the following bat file on each of those found png, passing the png filename and four color strings given.

    tilerecolor.bat
    Code:
    if not exist .\repainted mkdir .\repainted
    magick convert %1 ^
    ( -clone 0 ^
      -fill "#f4988c" -opaque %2 ^
      -fill "#d93a3a" -opaque %3 ^
      -fill "#932625" -opaque %4 ^
      -fill "#601119" -opaque %5 ) ^
    ( -clone 0 ^
      -fill "#96cbe7" -opaque %2 ^
      -fill "#5588d4" -opaque %3 ^
      -fill "#344495" -opaque %4 ^
      -fill "#1a1c51" -opaque %5 ) ^
    ( -clone 0 ^
      -fill "#b2e89d" -opaque %2 ^
      -fill "#51bd3b" -opaque %3 ^
      -fill "#247824" -opaque %4 ^
      -fill "#144216" -opaque %5 ) ^
    ( -clone 0 ^
      -fill "#ffffa7" -opaque %2 ^
      -fill "#e2c344" -opaque %3 ^
      -fill "#a46e06" -opaque %4 ^
      -fill "#642f00" -opaque %5 ) ^
    ( -clone 0 ^
      -fill "#ffd495" -opaque %2 ^
      -fill "#ea9931" -opaque %3 ^
      -fill "#a46e06" -opaque %4 ^
      -fill "#642f00" -opaque %5 ) ^
    ( -clone 0 ^
      -fill "#eab3db" -opaque %2 ^
      -fill "#d35eae" -opaque %3 ^
      -fill "#97276d" -opaque %4 ^
      -fill "#59163f" -opaque %5 ) ^
    ( -clone 0 ^
      -fill "#838383" -opaque %2 ^
      -fill "#555555" -opaque %3 ^
      -fill "#383838" -opaque %4 ^
      -fill "#151515" -opaque %5 )^
    ( -clone 0 ^
      -fill "#e6e6e6" -opaque %2 ^
      -fill "#b6b6b6" -opaque %3 ^
      -fill "#7b7b7b" -opaque %4 ^
      -fill "#373737" -opaque %5 )^
    -append repainted\%1
    
    This second bat file then takes a passed filename png (%1) and the four colors (%2 to %5), recolors and adds rows based off the original png accordingly before saving the result into a folder called repainted (creating that folder if it doesn't already exist.)

    The only con with this is imagemagick doesn't like transparent colors so glass etc. so I still needed to do those parts by hand (although I did use the bat file to convert any non-transparent pixels in a lot of cases.)

    Thought this might be useful for others creating tilesets, as you only need to do the pixel art for a single row this way first!
     
    Last edited: Sep 22, 2017
    Cyel, bk3k and Inf_Wolf14 like this.
  2. bk3k

    bk3k Oxygen Tank

    I'll definitely need to check this out when I get a chance. Thanks for the info.
     
  3. TheElderScroller

    TheElderScroller Pangalactic Porcupine

    Ye i discovered this imagemagick yesterday, while i was searching for a workaround because i didnt want to crop, resize and paint alot images one after another...
    Made it alot easier and faster... (Then i realized the transparency was gone, but i dont care)

    But ye, imagemagick with batch files is great!
     

Share This Page