Series of images by rotating

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
sfg
Posts: 17
Joined: 2009-12-30T13:44:31-07:00
Authentication code: 8675309

Series of images by rotating

Post by sfg »

I want to apply this code, more or less:

Code: Select all

convert test.png -matte -virtual-pixel transparent \ -distort ScaleRotateTranslate 1 *.png
to generate a series of images, each rotated 1 degree more than the previous one. So, I start with test.png which will be at 0 degrees, test1.png will be at 1 degree and so on until a 360 degrees rotation is done.

Like it is, it will do one image and that's all. I don't know how to make it run over the newly created images or apply a bigger rotation to the original image and create a new file everytime... and I assume both are possible?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Series of images by rotating

Post by anthony »

sfg wrote:I want to apply this code, more or less:

Code: Select all

convert test.png -matte -virtual-pixel transparent \ -distort ScaleRotateTranslate 1 *.png
to generate a series of images, each rotated 1 degree more than the previous one. So, I start with test.png which will be at 0 degrees, test1.png will be at 1 degree and so on until a 360 degrees rotation is done.

Like it is, it will do one image and that's all. I don't know how to make it run over the newly created images or apply a bigger rotation to the original image and create a new file everytime... and I assume both are possible?
First -- you can not output to a 'wildcard' filename! That just does not make any sense

As for the series.. try this...

Code: Select all

for i in {000..359}
do   
    convert test.png -alpha on -virtual-pixel transparent \
                -distort ScaleRotateTranslate $i \
                rotated_$i.png
done
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Series of images by rotating

Post by fmw42 »

you need to write a script loop changing the rotation and resulting filename each iteration
sfg
Posts: 17
Joined: 2009-12-30T13:44:31-07:00
Authentication code: 8675309

Re: Series of images by rotating

Post by sfg »

anthony wrote:
First -- you can not output to a 'wildcard' filename! That just does not make any sense
Yeah, I know... I wanted to show that there should be different files.
As for the series.. try this...

Code: Select all

for i in {000..359}
do   
    convert test.png -alpha on -virtual-pixel transparent \
                -distort ScaleRotateTranslate $i \
                rotated_$i.png
done
I tried, but I get a "sintax error" for each line... except the convert one where it says it can't find the file.
Am I doing something wrong?

This is the image:
Image
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Series of images by rotating

Post by fmw42 »

might it not be able to tell 000 from 0? that is 000 causes an error? or like in my old Mac OSX Tiger, that "for" sequence does not work and you have to use another looping method.
sfg
Posts: 17
Joined: 2009-12-30T13:44:31-07:00
Authentication code: 8675309

Re: Series of images by rotating

Post by sfg »

I'm using Windows, in case it matters... and I launched that from a bat file.

I tried replacing 000 with 0, but still the same.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Series of images by rotating

Post by fmw42 »

In windows, the \ is replaced with ^

see http://www.imagemagick.org/Usage/windows/

but perhaps you have corrected for that.


Is your IM version current enough for -distort SRT?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Series of images by rotating

Post by snibgo »

Translated to Windows:

Code: Select all

for /L %%i in (0,1,359) DO (
  convert test.png -alpha on -virtual-pixel transparent ^
                -distort ScaleRotateTranslate %%i ^
                rotated_%%i.png
)
snibgo's IM pages: im.snibgo.com
sfg
Posts: 17
Joined: 2009-12-30T13:44:31-07:00
Authentication code: 8675309

Re: Series of images by rotating

Post by sfg »

Still getting Syntax Error after

Code: Select all

for /L %%i in (0,1,359) DO (
I also tried putting everything in one line, but I get the same error...
sfg
Posts: 17
Joined: 2009-12-30T13:44:31-07:00
Authentication code: 8675309

Re: Series of images by rotating

Post by sfg »

Ah, it seems to work like this

Code: Select all

FOR /L %%i IN (0,1,359) DO convert test.png -alpha on -virtual-pixel transparent -distort ScaleRotateTranslate %%i rotated_%%i.png
Thanks for the help!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Series of images by rotating

Post by snibgo »

I am on Windows 7, IM version 6.6.3-0. You should paste my example into a batch file, then run it.

What version of Windows and IM are you on? (Type: convert -version)

What EXACT output do you get from the command file?
snibgo's IM pages: im.snibgo.com
Post Reply