ok .

Here is the original 512x512 image -> https://ibb.co/cneSfz

Then I ran this command

convert f0001_01.png -rotate 15 -set option:leg "%[fx:512/(cos(15*(pi/180))+sin(15*(pi/180)))]" -set option:distort:viewport "%[leg]x%[leg]" \( -clone 0 -distort srt 0 \) -gravity center +swap -composite output.png

where f0001_01.png is the above original image.

output.png looked like this -> https://ibb.co/dBcxfz .

Notice that there is a triangle in bottom left corner .

## extracting biggest square from a rotated image

### Re: extracting biggest square from a rotated image

I am beginning to think that it works as follows

convert f0001_01.png -rotate -15 rotated.png

Then

convert rotated.png -rotate 15 -set option:leg "%[fx:512/(cos(15*(pi/180))+sin(15*(pi/180)))]" -set option:distort:viewport "%[leg]x%[leg]" \( -clone 0 -distort srt 0 \) -gravity center +swap -composite output-with-rotated-input.png

But in such cases also i have observed a white triangle in corner of image .

Can you give a working example ?

Thanks .

convert f0001_01.png -rotate -15 rotated.png

Then

convert rotated.png -rotate 15 -set option:leg "%[fx:512/(cos(15*(pi/180))+sin(15*(pi/180)))]" -set option:distort:viewport "%[leg]x%[leg]" \( -clone 0 -distort srt 0 \) -gravity center +swap -composite output-with-rotated-input.png

But in such cases also i have observed a white triangle in corner of image .

Can you give a working example ?

Thanks .

- GeeMack
**Posts:**647**Joined:**2015-12-01T22:09:46-07:00**Authentication code:**1151**Location:**Central Illinois, USA

### Re: extracting biggest square from a rotated image

The command you've been using works perfectly. The sample image you provided has a 32 pixel high strip of white along the bottom edge. That's what makes the white triangle in your output.