create gif animation by scrolling a big 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?".
Locked
manit
Posts: 157
Joined: 2009-01-30T22:31:26-07:00

create gif animation by scrolling a big image

Post by manit »

hi,
I am using

Code: Select all

magick -version
Version: ImageMagick 7.0.7-25 Q16 x86 2018-03-04 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Visual C++: 180040629
Features: Cipher DPC HDRI
Delegates (built-in): bzlib cairo flif freetype gslib heic jng jp2 jpeg lcms lqr openexr pangocairo png ps raw rsvg tiff webp xml zlib
in windows OS.

My idea is as follows
Given :- I have an image that is 500x50 wide with a number in each 100x100 block starting from the corner.

Code: Select all

magick -background white -fill black -font "Comic-Sans-MS-Bold" -size 40x40  caption:1  caption:2  caption:3  caption:4  caption:5  caption:6  caption:7  caption:8  caption:9  caption:10 miff:- |magick montage - -tile 10x -geometry +5+5 one-to-ten.png
Now, I want to roll this image across a 50x50 pixel window so that numbers go by one after another in field of view .
If you consider one-to-ten.png and scrolling is left to right then 10 will appears first followed by nine,eight,.. upto one.
How can I accomplish this ?


Thanks.

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

Re: create gif animation by scrolling a big image

Post by fmw42 »

See -roll

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: create gif animation by scrolling a big image

Post by snibgo »

The question is vague. How many frames should the output contain? Ten, or 450, or some other number? How large should each output frame be? 50x50 or some other size?
snibgo's IM pages: im.snibgo.com

manit
Posts: 157
Joined: 2009-01-30T22:31:26-07:00

Re: create gif animation by scrolling a big image

Post by manit »

to fmw42,
did you mean http://www.imagemagick.org/Usage/warping/#roll ?
How do I use it in my case ?

to snibgo,
output frame size should be 50x50.
Number of frames should be 50 so that each number appears in 5 frames.
Thank you.

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: create gif animation by scrolling a big image

Post by snibgo »

How about this Windows BAT script:

Code: Select all

magick ^
  one-to-ten.png ^
  -duplicate 49 ^
  -crop 50x50+%%[fx:450-t*9]+0 +repage ^
  one-to-ten_1.gif
Image
snibgo's IM pages: im.snibgo.com

manit
Posts: 157
Joined: 2009-01-30T22:31:26-07:00

Re: create gif animation by scrolling a big image

Post by manit »

snibgo wrote:
2020-05-22T09:11:35-07:00
How about this Windows BAT script:

Code: Select all

magick ^
  one-to-ten.png ^
  -duplicate 49 ^
  -crop 50x50+%%[fx:450-t*9]+0 +repage ^
  one-to-ten_1.gif
Image
looks fine.
First you make 49 duplicates of original image then it seems you are cropping 50x50 frames with starting x position of crop decreasing with successive images.
+repage makes every crop in top left corner.
Then you combine all those 50x50 frames to make gif.
Is that so ?
what does t stand for ?
One thing - '1' goes away very quickly ?

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: create gif animation by scrolling a big image

Post by snibgo »

Yes, that's how it works. Adjust the expression to suit, eg instead of 9, use 10 or 9.5 or whatever. "t" is the index of the image in the list, so has the value 0, 1, 2, ... 49. See https://www.imagemagick.org/script/fx.php

EDIT: See also Animation with SRT which uses "-distort SRT" to give smoother results than "-crop".
snibgo's IM pages: im.snibgo.com

Locked