extracting biggest square from a rotated image

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?".
manit
Posts: 92
Joined: 2009-01-30T22:31:26-07:00

Re: extracting biggest square from a rotated image

Post by manit » 2018-08-20T06:57:49-07:00

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 .

manit
Posts: 92
Joined: 2009-01-30T22:31:26-07:00

Re: extracting biggest square from a rotated image

Post by manit » 2018-08-20T07:11:35-07:00

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 .

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

Re: extracting biggest square from a rotated image

Post by GeeMack » 2018-08-20T08:04:17-07:00

manit wrote:
2018-08-20T07:11:35-07:00
But in such cases also i have observed a white triangle in corner of 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.

manit
Posts: 92
Joined: 2009-01-30T22:31:26-07:00

Re: extracting biggest square from a rotated image

Post by manit » 2018-08-20T08:08:32-07:00

GeeMack wrote:
2018-08-20T08:04:17-07:00
manit wrote:
2018-08-20T07:11:35-07:00
But in such cases also i have observed a white triangle in corner of 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.
ok .

Post Reply