Rotating image around a given 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
derMatze

Rotating image around a given point?

Post 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?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Rotating image around a given point?

Post 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?
derMatze

Re: Rotating image around a given point?

Post by derMatze »

Mmmh, there seems to be no support for distort. How can I add that?

(Yes, that was a typing error :) )
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Rotating image around a given point?

Post by Bonzo »

I do not know when distort came in; what version are you using?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Rotating image around a given point?

Post by Bonzo »

Looks like it came in around IM v6.3.5-1
derMatze

Re: Rotating image around a given point?

Post by derMatze »

Thanks! I'm gonna ask my admin to update it...
derMatze

Re: Rotating image around a given point?

Post 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?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Rotating image around a given point?

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Rotating image around a given point?

Post 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
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Rotating image around a given point?

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
derMatze

Re: Rotating image around a given point?

Post by derMatze »

It works great, thanks guys! :)
Post Reply