mp4 to animated gif using ImageMagick

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
tedriley
Posts: 1
Joined: 2018-08-02T16:46:57-07:00
Authentication code: 1152

mp4 to animated gif using ImageMagick

Post by tedriley »

Hi friends, have any of you encountered this use case? Using Rails 5 on a project to do this and wasn't able to find anything on StackOverflow. Hoping to convert an mp4 to an animated gif using ImageMagick. Any help is greatly appreciated, or just a point to a tutorial or the right direction. Many thanks! 8)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: mp4 to animated gif using ImageMagick

Post by fmw42 »

I believe to be able to convert mp4, you need ffmpeg loaded where ImageMagick could find it. If that is available, then the following should work in the command line. Sorry I do not know Rails.

Code: Select all

convert -delay X image.mp4 -loop 0 animation.gif
If that does not work, then try

Code: Select all

convert -delay X image.mp4 -coalesce -layers optimize -loop 0 animation.gif
Where X is the desired frame delay in ticks (1/100 s)

See also https://www.imagemagick.org/Usage/video/




Please, always provide your IM version and platform when asking questions, since syntax may differ. Also provide your exact command line and if possible your images.

See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at http://www.imagemagick.org/discourse-se ... f=1&t=9620

If using Imagemagick 7, then see http://imagemagick.org/script/porting.php#cli


For novices, see

http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown
Post Reply