I am working with the ImageMagick convert program via command line. I am using it to split an image into 16x16 images. This work well with the crop command. I do as such:
convert.exe "C:\Users\Matt\Desktop\tiles\maps\shrine_source\shadow_light.png" -crop 16x16 "C:\Users\Matt\Desktop\tiles\maps\shadow_light_input\shadow_light_%02d.png"
The problem is I would like to format the part after the underscore starting from an index. For instance, starting from "shadow_light_2048.png
" and so forth. Looking at some examples I was thinking it could be done with bracket notations like "shadow_light_%[2048-3071].png
", but it seems to ignore this.
Could someone help point me in the right direction on how to properly format to filename? Ideally in a way to where I only have to specify the starting index.
Use the -scene
option to set the scene number which is what gets put where you use %d
:
convert input.png -crop ... -scene 2048 result-%04d.png
So, for example, let's create a 20x20 black image and chop it up into tiles each 10x10:
convert xc:black[20x20] -crop 10x10 -scene 2048 tile-%d.png
-rw-r--r-- 1 mark staff 301 21 Jul 09:18 tile-2051.png
-rw-r--r-- 1 mark staff 301 21 Jul 09:18 tile-2050.png
-rw-r--r-- 1 mark staff 301 21 Jul 09:18 tile-2049.png
-rw-r--r-- 1 mark staff 280 21 Jul 09:18 tile-2048.png