Creating a resulting image with 24 rotations of the source image (every 15°)

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
FrereTuck
Posts: 19
Joined: 2017-10-13T02:50:15-07:00
Authentication code: 1151

Creating a resulting image with 24 rotations of the source image (every 15°)

Post by FrereTuck » 2018-01-25T10:52:28-07:00

Hi,

I currently have an image I'd like to rotate (every 15°) to create a series of images I will use later on.
Image
It would be nice to have that series in a single image.
I made a simple bash script that creates the 24 images, but would like to know how to do it in a single image and a single command if possible.

Code: Select all

convert -rotate "15" c.png c15.png
I also found this script, but it creates a gif file, and I'd like to keep a png:

Code: Select all

#!/bin/sh
#
# Create a rotating figure using Distort SRT transformations
#
command='convert -delay 10 c.png -virtual-pixel white'

for i in `seq 15 15 360`; do
  command="$command \\( -clone 0 -distort SRT $i \\)"
done

command="$command -delete 0 -loop 0 animated_distort_rot.gif"

eval $command

chmod 644 animated_distort_rot.gif
Image
If you think it's possible, please let me know.

Thanks.

User avatar
fmw42
Posts: 23627
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Creating a resulting image with 24 rotations of the source image (every 15°)

Post by fmw42 » 2018-01-25T11:15:38-07:00

PNG does not support multi-frame images. GIF supports multi-frame images and animations. I believe you can save to TIFF also to have multipage images, but not animations. The imagemagick MIFF format can also be used, but only Imagemagick can view that.

So try

Code: Select all

convert c.png c.tif
for ((i=15; i<360; i=i+15)); do
convert c.tif \( c.png -background none -distort SRT $i \) c.tif
done
Again, this will not animate, but does contain every rotation angle in one file.

User avatar
fmw42
Posts: 23627
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Creating a resulting image with 24 rotations of the source image (every 15°)

Post by fmw42 » 2018-01-25T11:20:19-07:00

P.S. You can view the animation, using Imagemagick animate as follows:

Code: Select all

animate -delay 50 c.tif

FrereTuck
Posts: 19
Joined: 2017-10-13T02:50:15-07:00
Authentication code: 1151

Re: Creating a resulting image with 24 rotations of the source image (every 15°)

Post by FrereTuck » 2018-01-25T11:40:13-07:00

Thanks a lot, Fred.

Post Reply