Skip to content

Instantly share code, notes, and snippets.

@aschuhardt
Created May 9, 2023 23:08
Show Gist options
  • Save aschuhardt/5af87f26247f3db0320e428a814ab42e to your computer and use it in GitHub Desktop.
Save aschuhardt/5af87f26247f3db0320e428a814ab42e to your computer and use it in GitHub Desktop.
A Powershell script that transforms a set of 128x96px tiles by converting black and magenta to transparent, then adding extra spacing between each tile
# I'm an ImageMagick newbie and don't know/care enough to make this performant
# I made this for working with this isometric walls pack: https://screamingbrainstudios.itch.io/isowallpack
foreach ($name in Get-ChildItem -Recurse -Filter *.png | ForEach-Object FullName) {
# convert magenta and black to transparent
mogrify -transparent "rgb(255,0,255)" $name;
mogrify -transparent "rgb(0,0,0)" $name;
# add 64px of spacing along the X-axis, and 32px along the Y-axis
convert $name -background None `
-crop 128x0 +repage -splice 64x0 +append `
-crop 0x96 +repage -splice 0x32 -append `
$name;
# add some extra padding around the edge of the image
convert $name -gravity east -background None -splice 64x0 $name;
convert $name -gravity south -background None -splice 0x64 $name;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment