choose starting frame (different than frame 0) for a GIF

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
yeneb
Posts: 1
Joined: 2019-10-05T01:49:22-07:00
Authentication code: 1152

choose starting frame (different than frame 0) for a GIF

Post by yeneb »

I'm using ImageMagick-7.0.6-Q16 on windows 10 via command line

I currently use a bat file I created to convert PNG sequences into GIFs while resizing and adding a text watermark in the process. It works fine, though in some cases I want to have the starting frame to be different (frame 25 for example) than frame 0, but still loop completely.

i.e. GIF start on 25f play through the end to frame 90 then continue 1 to 24 and loop.

my current solution has been batch renaming the files to choose the starting frame but then I have to alter all the provided frames and it's quite time consuming.

Ideally I'd like to have a way to set in the bat file the starting frame for the GIF and still loop through all provided images from the png sequence.

Is this possible?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: choose starting frame (different than frame 0) for a GIF

Post by fmw42 »

What about

Code: Select all

magick animate movie.gif[1--1]
to start with the second frame (skip frame 0) and go the last
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: choose starting frame (different than frame 0) for a GIF

Post by snibgo »

If you have read many images and want your GIF to start after the first 25 of those images, you can move those to the end of the list:

Code: Select all

magick *.png ( -clone 0-24 +write mpr:FIRST -delete 0--1 ) -delete 0-24 mpr:FIRST out.gif
snibgo's IM pages: im.snibgo.com
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: choose starting frame (different than frame 0) for a GIF

Post by GeeMack »

If you want to take some frames from the beginning and put them at the end, you can use "-duplicate" and "-delete" like this...

Code: Select all

convert input.gif -duplicate 1,0-4 -delete 0-4 result.gif
That would duplicate five frames from the beginning, frames number 0 through 4, and place them at the end of the animation. Then it deletes the original frames 0 through 4. That will start the animation on frame 5, or the original sixth frame.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: choose starting frame (different than frame 0) for a GIF

Post by snibgo »

Ah, yes, thanks GeeMack. I thought there was a better way.
snibgo's IM pages: im.snibgo.com
Post Reply