Cutting image and reassembling

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?".
Post Reply
masagrator
Posts: 2
Joined: 2019-06-05T11:41:21-07:00
Authentication code: 1152

Cutting image and reassembling

Post by masagrator »

Hello. I'm still learning ImageMagick but this issue looks too advanced.
I need to cut texture with different dimensions to 36px x 36px pieces from first row left to right, then next row left to right, etc.
And reassemble them in the same manner to images like 512x512, if it's too small, then 1024x512, if again - 1024x1024, if again - 2048x1024, if again - 2048x2048 (there is no need for more).

Doesn't matter format of input/output if it supports TrueTypeAlpha.

Is it possible to do?

I'm using IM 7.0.8.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Cutting image and reassembling

Post by snibgo »

masagrator wrote:I need to cut texture with different dimensions to 36px x 36px pieces from first row left to right, then next row left to right, etc.

Code: Select all

-crop 36x36
masagrator wrote:And reassemble them in the same manner to images like 512x512...
I don't understand. 512 isn't a multiple of 36, so how should the reassembly work?
snibgo's IM pages: im.snibgo.com
masagrator
Posts: 2
Joined: 2019-06-05T11:41:21-07:00
Authentication code: 1152

Re: Cutting image and reassembling

Post by masagrator »

snibgo wrote: 2019-06-05T12:13:26-07:00 I don't understand. 512 isn't a multiple of 36, so how should the reassembly work?
Rest of space should be transparent.
So from f.e. this:
https://i.imgur.com/h3WrDN1.png
I will get this
https://i.imgur.com/e7wtI2k.png

Input is always multiplication of 36 in width and height.
So maybe if it needs custom script, then it can be done by:
512 - 14 tiles max
1024 - 28 tiles max
2048 - 56 tiles max

So for 512x512 = 1-196 tiles, -tile 14x and work space change to 512x512 after merging
1024x512 = 197-396 tiles, -tile 28x and work space change to 1024x512 after merging
1024x1024 = 397-784 tiles, -tile 28x and work space change to 1024x1024 after merging
2048x1024 = 785-1568 tiles, -tile 56x and work space change to 2048x1024 after merging
2048x2048 = 1569-3136 tiles, -tile 56x and work space change to 2048x2048 after merging

Maybe i figured it out, but it's not a clean script. Maybe something better will be there.
So I First cutted to pieces and putted it to separate folders, next I've count how many files are in each folder, then in text file I'd segregate folders by resolution based on how many files they have, then I need to change name for each piece to contain 4 numbers as windows * sorting is shitty (this is the longest process as it takes about 3-4 hours for my 1kk pieces), then montage it and change workspace for montaged images.
Post Reply