Page 1 of 1

Rotating image around a given point?

Posted: 2008-09-15T06:07:23-07:00
by derMatze
I'm trying to rotate an image aroung a given point, but it doesn't work at all...
This is how I tried it:
convert -distort ScaleRotateTranslate '34,29 100 20' pic_a.jpg' 'pic_b.jpg'
...but nothings happend.
Anyone who can explain the needed arguments for SRT to me?

Re: Rotating image around a given point?

Posted: 2008-09-15T07:29:15-07:00
by Bonzo
Does your version of IM support that distort ?

Code: Select all

convert -list distort
Read the image in first

Code: Select all

convert pic_a.jpg -distort ScaleRotateTranslate '34,29 100 20' pic_b.jpg
Thats all I can think of, in your post you are missing a ' I pressume this is a typing error?

Re: Rotating image around a given point?

Posted: 2008-09-15T07:34:57-07:00
by derMatze
Mmmh, there seems to be no support for distort. How can I add that?

(Yes, that was a typing error :) )

Re: Rotating image around a given point?

Posted: 2008-09-15T07:40:42-07:00
by Bonzo
I do not know when distort came in; what version are you using?

Re: Rotating image around a given point?

Posted: 2008-09-15T07:43:16-07:00
by Bonzo
Looks like it came in around IM v6.3.5-1

Re: Rotating image around a given point?

Posted: 2008-09-15T07:56:27-07:00
by derMatze
Thanks! I'm gonna ask my admin to update it...

Re: Rotating image around a given point?

Posted: 2008-09-16T03:32:57-07:00
by derMatze
Yes, it works! :)
But I got two questions
- I want to have the rotating point the new middle-point of the new image, how can I do that?
- How can I set the background of that new image to white?

Re: Rotating image around a given point?

Posted: 2008-09-16T04:39:29-07:00
by Bonzo
Its good to know you now have it working; have you checked this page out http://www.imagemagick.org/Usage/distorts/ ?

I do not know if you can use -background white in your code for a white background, but the page above should help with that.

I have no idea how you would do this
I want to have the rotating point the new middle-point of the new image

Re: Rotating image around a given point?

Posted: 2008-09-16T10:14:24-07:00
by fmw42
convert <image> -virtual-pixel white -distort SRT "X,Y Scale Angle NewX,NewY" <result>

-virtual-pixel white will make the background white

-distort SRT "X,Y Scale Angle NewX,NewY"

will rotate and scale about X,Y and then translate that to NewX,NewY

see
http://www.imagemagick.org/Usage/distorts/#srt
http://www.imagemagick.org/script/comma ... tual-pixel

Re: Rotating image around a given point?

Posted: 2008-09-17T00:17:25-07:00
by anthony
Note scale probably should be 1.0 unless your want an image 100 times bigger!!!

With +distort the center point will not move on the layer image, (virtual canvas location). of course in terms of location on the actual image, it may be in a different pixel coordinate!

In -distort the output image size does not change, so the center point will still be the original actual image pixel location. in general -distort ignores virtual 'layer' position completely.

Re: Rotating image around a given point?

Posted: 2008-09-17T03:36:26-07:00
by derMatze
It works great, thanks guys! :)