Created
May 9, 2023 23:08
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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