I'm still very much a beginner with ImageMagick, but have been trying to use it instead of manually cropping images.
I'm using Windows, and running the commands in PowerShell. Version 6.9.2-8 Q16.
I've been using the following command to crop some regular-sized images.
Code: Select all
convert .\original.png -crop 32x32 -set filename:tile '%[fx:page.y/32+1]_%[fx:page.x/32+1]' +repage +adjoin 'original\tiled_%[filename:tile].png'
However, I now want to have a bit more control over where my crop starts. With the image I'm currently working with the rows are either 16 pixels, 32 pixels, or 48 pixels tall, but all 32 pixels wide.
Can I have IM slice an image into pieces after defining a starting point?
What I'd like to do, for example, is skip the first row of 16x32 tiles, and then crop the next 7 rows of 32x32 tiles. Then I have another row of 16x32 tiles to skip, followed by 4 rows of 32x32 tiles that I want to grab again. Etcetera.
It looks like I can add to the geometry parameter, which gives me something like the following:
Code: Select all
convert .\original.png -crop 32x32+0+16 -set filename:tile '%[fx:page.y/32+1]_%[fx:page.x/32+1]' +repage +adjoin 'original\tiled_%[filename:tile].png'
I could probably cut out the standardized rows. So in my case, create a new image skipping the first row of 16, grabbing the 7 rows of 32, then create a second image skipping the row of 16, 7 rows of 32, and second row of 16, grabbing the next 4 rows of 32, etcetera. Something like this for the first section of 32x32 tiles:
Code: Select all
convert .\original.png -crop 768x224+0+16 -set filename:tile '%[fx:page.y/32+1]_%[fx:page.x/32+1]' +repage +adjoin 'original\tiled_%[filename:tile].png'
Code: Select all
convert .\original.png -crop 768x224+0+128 -set filename:tile '%[fx:page.y/32+1]_%[fx:page.x/32+1]' +repage +adjoin 'original\tiled_%[filename:tile].png'
However, I'm wondering if there's perhaps an easier way to do this? Can I have IM slice an image into pieces after defining a starting point?
Thanks!