Crop and tile picture for ML

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Locked
littlenode
Posts: 1
Joined: 2020-03-17T09:37:06-07:00
Authentication code: 1152

Crop and tile picture for ML

Post by littlenode »

Hi there,
I just got a recommendation to use Imagemagick and i would love to get some info how to tackle this problem.
Im having a picture with 8x8 tiles with a white border around it.

Image

https://imgur.com/a/ZHybsub

I messured the coordinates are as followed: Left top corner=78,69, Right top corner=513.0,69.0, Left bottom corner=78.0,504.0, Right bottom corner=513.0,504.0

I would like to crop that box and then cut out 8x8 tiles each 576x576px in size.

How could i achive that? I checked the guide and i dont quite get it.

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Crop and tile picture for ML

Post by fmw42 »

try either

Code: Select all

convert img.png -fuzz 10% -trim +repage -crop 8x8@ x_%02d.png
or

Code: Select all

convert img.png -crop 435x435+78+69 +repage -crop 8x8@ x_%02d.png

The first does an automatic trim to remove the white and then gets the best 8x8 set of blocks to fix your trimmed region.

In the second, ImageMagick does a crop using WxH+X+Y. So I had to use your top left and bottom right corner coords to compute WxH and then the top left corner for X,Y.

Locked