Making a gif by rotating an 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?".
Post Reply
dargaud
Posts: 31
Joined: 2006-08-06T01:58:58-07:00

Making a gif by rotating an image

Post by dargaud »

Hello all,
it's been a while since I last did any 'advanced' IM tricks, so I'm a little rusty. I'd like to take an image and make a gif (or any video format with settable speed and looping) with that image, then that same image rotated by 360*1/n, that same image rotated by 360*2/n, ... that same image rotated by 360*(n-1)/n, and then loop the gif. Where n is the number of divisions of the circle.

Any idea ? Thanks
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Making a gif by rotating an image

Post by snibgo »

For example, 36 views at 10 degree intervals:

Code: Select all

convert rose: -duplicate 35 -distort SRT 1,%[fx:t*10] x.gif
snibgo's IM pages: im.snibgo.com
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Making a gif by rotating an image

Post by GeeMack »

dargaud wrote: 2017-01-16T08:20:35-07:00I'd like to take an image and make a gif (or any video format with settable speed and looping) with that image, then that same image rotated by 360*1/n, that same image rotated by 360*2/n, ... that same image rotated by 360*(n-1)/n, and then loop the gif. Where n is the number of divisions of the circle.
Please remember to always provide your IM version and which OS or platform you're working on.

In concept, with any recent version of IM, this should make a 24 frame animated GIF, each frame rotated by 360/24 more than the previous frame.

Code: Select all

convert input.png -duplicate 23 -distort SRT %[fx:t*360/n] -set delay 10 -loop 0 output.gif
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Making a gif by rotating an image

Post by anthony »

See IM Examples, GIF animations, for an explanation of this technique...
http://www.imagemagick.org/Usage/anim_mods/#distort

For older technique see
Simple Image Warping, Animations
http://www.imagemagick.org/Usage/warping/#animations
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
dargaud
Posts: 31
Joined: 2006-08-06T01:58:58-07:00

Re: Making a gif by rotating an image

Post by dargaud »

Thanks, that's what I was looking for. Although I couldn't get -delay to work in either .gif or .mng output until I saw GeeMack's syntax being "-set delay". In many places of the documentation it's given as -delay (even the man page) and it doesn't work. I'm using version 6.8.9-9 Q16 x86_64 2016-11-29
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Making a gif by rotating an image

Post by fmw42 »

Use -delay before reading the input images or use -set delay after reading the input images.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Making a gif by rotating an image

Post by anthony »

See... GIF Animations Basics....
http://www.imagemagick.org/Usage/anim_basics/#gif_anim

Also see Basics, Setting/Changing Image Attributes/Properities
http://www.imagemagick.org/Usage/basics/#attributes
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply