Turning Still image into animation (frames) Roll ?

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
Rye
Posts: 158
Joined: 2013-02-25T10:43:05-07:00
Authentication code: 6789

Turning Still image into animation (frames) Roll ?

Post by Rye »

So... I got a rather... unique idea here...

Even though I'm not even sure if Imagemagick is my tool of choice for what I have planned I'll ask anyways.

To make it simple:

I want to go from this:

Image

to this:

Image

Obviously I want to extract frames from a big image and play em, (animated gif) so it appears as if the image is "scrolling" across the screen.

I was thinking if a slice approach with offset and bleed might work here.

Any ideas are welcome.

Would be especially dandy if it were possible to determine the scrolling direction and resulting frame's size.

Thanx in advance.

- Rye
Last edited by Rye on 2017-01-28T16:15:03-07:00, edited 1 time in total.
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Turning Still image into animation (frames) ?

Post by fmw42 »

You can do that in a loop with successive use of -roll and -crop.

See

http://www.imagemagick.org/script/comma ... s.php#roll
http://www.imagemagick.org/Usage/warping/#roll
http://www.imagemagick.org/Usage/crop/#crop


What platform are you on, since scripting and IM syntax is different on Windows and Unix systems?
Rye
Posts: 158
Joined: 2013-02-25T10:43:05-07:00
Authentication code: 6789

Re: Turning Still image into animation (frames) ?

Post by Rye »

Windows.

That sounds interesting.

Are there examples on how to use roll and crop ?

Also, is it possible to change the scrolling direction ?
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Turning Still image into animation (frames) ?

Post by fmw42 »

Read the links I provided above for examples.

In unix, it can be done as follows using subshell processing. The direction is controlled by the incx and incy arguments. Though you can give a direction and increment and convert that to its x and y increments.

Code: Select all

incx=5
incy=5
wd=250
ht=250
numx=`convert xc: -format "%[fx:$wd/$incx]" info:`
numy=`convert xc: -format "%[fx:$wd/$incx]" info:`
num=`convert xc: -format "%[fx:max($numx,$numy)]" info:`
echo "num=$num;"
offx=0
offy=0
(
for ((i=0; i<num; i++)); do
convert still.gif -roll +${offx}+${offy} -gravity center -crop ${wd}x${ht}+0+0 +repage miff:-
offx=$((offx+incx))
offy=$((offy+incy))
done
) | convert -dispose previous -delay 20 - -loop 0 -layers optimize animation.gif
Sorry I do not know how to do this in Windows scripting.

It can also be done by using -distort SRT and just use the oldx,oldy and newx,newy to control the direction. You would also have to provide a viewport crop. See

http://www.imagemagick.org/Usage/distorts/#srt
http://www.imagemagick.org/Usage/distor ... t_viewport

The roll is easier, but only works in full pixel increments. SRT can do fractional pixel shifts.
Rye
Posts: 158
Joined: 2013-02-25T10:43:05-07:00
Authentication code: 6789

Re: Turning Still image into animation (frames) ?

Post by Rye »

Would a cygwin evironment / linux wrapper make these commands work under windows perhaps ?
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Turning Still image into animation (frames) ?

Post by fmw42 »

Rye wrote:Would a cygwin evironment / linux wrapper make these commands work under windows perhaps ?
Yes, it should. But perhaps some Windows IM user can provide the equivalent bat script in native Windows.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Turning Still image into animation (frames) ?

Post by snibgo »

For this, I would use "-distort SRT". See my page "Animation with SRT", which includes examples for Windows BAT.
snibgo's IM pages: im.snibgo.com
Rye
Posts: 158
Joined: 2013-02-25T10:43:05-07:00
Authentication code: 6789

Re: Turning Still image into animation (frames) ?

Post by Rye »

@snibgo:

I assume you are talking about this site of yours ?:
http://im.snibgo.com/animsrt.htm

I tried the samples out...

But failed to produce anything more than a simple copy of my source image.

I think you wrote them for windows, correct ?
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Turning Still image into animation (frames) ?

Post by snibgo »

"Yes" to all your questions. The commands with the green backgrounds, run as a Windows BAT script, made the images shown.
Rye wrote:I tried the samples out...

But failed to produce anything more than a simple copy of my source image.
If you post your source image and exact commands, we may be able to suggest something.
snibgo's IM pages: im.snibgo.com
Rye
Posts: 158
Joined: 2013-02-25T10:43:05-07:00
Authentication code: 6789

Re: Turning Still image into animation (frames) ?

Post by Rye »

Has been a long time, but at long last I found an approch that works in windows:

Code: Select all

@echo off
echo "Press Enter to roll image into rolled dir"
echo "Exit Script to stop processing"
mkdir rolled
:START
set SAVESTAMP=%DATE:/=-%@%TIME::=-%
set SAVESTAMP=%SAVESTAMP: =%
set SAVESTAMP=%SAVESTAMP:,=.%.jpg
for %%x in (*jpg) do convert %%x -roll +15+15 %%x.no
move *.jpg rolled/%savestamp%
for /R %%x in (*.jpg.no) do ren "%%x" *.
goto start

It's a bit laughable, but feel free to use it in any way you like xD.

This thread can now be closed.
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
Post Reply