Rotation around a point

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
dargaud
Posts: 31
Joined: 2006-08-06T01:58:58-07:00

Rotation around a point

Post by dargaud »

Hello all,
OK, I understand the affine rotationcan do an arbitrary rotation around a point, but I want the result to be still the same dimensions as the original image (the only fixed point being the center of rotation). The way I understand it, the affine transform enlarges the image to the smallest box that encloses the resulting image.

Is there a way to disable that behavior ?
I don't think +repage is the solution here.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Rotation around a point

Post by fmw42 »

use -distort SRT

see http://www.imagemagick.org/Usage/distorts/#srt

it will keep the output the same size, but may clip some of the image after rotation and pad elsewhere. I believe that you can use the virtual-pixel setting to control the kind of padding. So the other way is to precompute the scaling you need to shrink the image so that after a rotation, the image is smaller and fits within the size of the original.
dargaud
Posts: 31
Joined: 2006-08-06T01:58:58-07:00

Re: Rotation around a point

Post by dargaud »

Thank you, SRT works perfectly and is easy to use. Since I'm manipulating 256Mpix images, I really need to figure out how to crop before the rotation in order to optimize the process as you suggest.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Rotation around a point

Post by anthony »

The distortion can 'crop' the resulting image as part of its processing using the 'viewport' expert option. This defines what part of the 'distorted image space' you want to look at. You will needto use a +repage afterward to remove the virtual offset of the viewport afterward.

http://www.imagemagick.org/Usage/distor ... t_viewport
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply