Page 1 of 1

Split image

Posted: 2017-01-02T23:52:38-07:00
by ahstanin
Hello there magicians,

I need a magical spell for my work. I will have an uploader where people can upload random sized images. I want those to Split each image in random pieces depend on the image size. All Split-ed output has to be in square size (eg. 100X100 or 200X200). There will be always 3 Split by width and for hight depending on the image size. Some examples bellow :

1. User upload a random picture which is a square (2049 X 2049). It will be Split 3 pieces in width and 3 pieces in height because it's a square image. As I mentioned earlier Split-ed output has to be in square size. Each piece will be 683X683 and total 9 pieces.

Code: Select all

convert -crop 33.33%x33.33% +repage DSC_0972.jpg out%d_image.jpg
This CLI work perfect for me.

2. User upload a random picture which is a landscape (2049 X RANDOM_HEIGHT). It has to Split 3 pieces in width and XYZ pieces in height depending on the picture size. As well all Split-ed output has to be in square size.

3. User upload a random picture which is a portrait (2049 X RANDOM_HEIGHT). It has to Split 3 pieces in width and XYZ pieces in height depending on the picture size. As well all Split-ed output has to be in square size.


Note: Width always will be Split 3 pieces and final Split pieces has to be square (eg. 100X100 or 200X200).


Thank You in advance

Re: Split image

Posted: 2017-01-03T00:15:26-07:00
by snibgo
ahstanin wrote:2. User upload a random picture which is a landscape (2049 X RANDOM_HEIGHT). It has to Split 3 pieces in width and XYZ pieces in height depending on the picture size. As well all Split-ed output has to be in square size.
So the width of each output square will be 2049/3 = 683 pixels. As they are square, the height of each will also be 683 pixels. This will work only when RANDOM_HEIGHT is an exact multiple of 683.