Hi,
I'm using ImageMagick on Linux (version 6.8.9-9) and I'd like to rotate a transparent gif in a directory through angles varying from -90 to +90 degrees. I'd like to invoke a shell script and then save each converted image with the angle appended (eg MyImage90.gif and MyImage-60.gif). My knowledge of bash etc is not very good - can anyone help?
Best wishes
Paul
Rotate using script
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Rotate using script
Are these animated gifs or single frame gifs? What increments of angle?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Rotate using script
try
Code: Select all
infile="MyImage.gif "
incr=30
inname=`convert "$infile" -format "%t" info:`
for ((i=-90; i<=90; i=i+incr)); do
convert "$infile" -background none -rotate $i ${inname}$i.gif
done
- GeeMack
- Posts: 718
- Joined: 2015-12-01T22:09:46-07:00
- Authentication code: 1151
- Location: Central Illinois, USA
Re: Rotate using script
If I understand what you're trying to accomplish, it may be possible with a single IM command. Here's an example using IM 6.9.6 in a Windows command shell. With a simple conversion to a *nix command, this should get you pretty close...PaulLee wrote:I'm using ImageMagick on Linux (version 6.8.9-9) and I'd like to rotate a transparent gif in a directory through angles varying from -90 to +90 degrees. I'd like to invoke a shell script and then save each converted image with the angle appended (eg MyImage90.gif and MyImage-60.gif). My knowledge of bash etc is not very good - can anyone help?
Code: Select all
convert input.gif -rotate -90 -duplicate 179 ^
-distort SRT %[fx:t] -set filename:f MyImage%[fx:t-89] +adjoin %[filename:f].gif
You might want to use a "-virtual-pixel" setting to manage the parts of the image that start outside the viewport and get moved in with the rotation.
Also, if you're starting with a multi-layer (animated) GIF, you'll have to "-flatten" the image right after reading it in, or maybe select which particular layer you want to work with by specifying its index like "input.gif[0]".