21

I am trying to convert this image, http://en.wikipedia.org/wiki/File:Dijkstra_Animation.gif, to a series of .png files.

This was pretty simple, I used the convert command in Linux:

convert  Dijkstra_Animation.gif dijkstra.png

The command went fine and produced the 27 frames, as reported at the bottom of the original page.

However, I find that some of the produced .png files are only single numbers or arrows. Which is different from what I expected.

I want the .png files to be a simple sequence in the same way the .gif file is showing.

Could you please suggest a method (for Linux please) to achieve this?

Masroor
  • 1,227
  • 2
  • 13
  • 30

2 Answers2

33

Using the -coalesce option will do the wonder.

Like this,

convert -verbose -coalesce Dijkstra_Animation.gif dijkstra.png

Actually the -coalesce option "merges a sequence of images" as is claimed in the manual page.

Masroor
  • 1,227
  • 2
  • 13
  • 30
  • `jalal@klein:~$ convert -verbose -coalesce MRtIA77.gifv rabbit.jpg convert: no decode delegate for this image format `GIFV' @ error/constitute.c/ReadImage/501. convert: no images defined `rabbit.jpg' @ error/convert.c/ConvertImageCommand/3210.` – Mona Jalal Oct 18 '16 at 19:14
  • @MonaJalal Are you sure that the name `MRtIA77.gifv` is correct? Perhaps I see an extra `v` at the end. – Masroor Oct 18 '16 at 23:54
2

If convert does not work for you and you are a Mac user, you can try sips, which comes with your MacOS. For example, you can convert a GIF image into a PNG image:

sips -s format png 1.gif --out 1.png

You can also convert a folder filled with GIFs to PNGs saved in folder pngs:

sips -s format png gifs/*.gif --out pngs

More about sips. It is an abbreviation of Scriptable image processing system. It is used to query or modify raster image files (JPG/GIF/PNG). Image processing options include flip, rotate, change image format/width/height. You can find more details in its manual: in command line man sips or at online manual.

FYI, my MacOS release (obtained by uname -rsv) is:

Darwin 18.2.0 Darwin Kernel Version 18.2.0: Mon Nov 12 20:24:46 PST 2018; root:xnu-4903.231.4~2/RELEASE_X86_64
Mark Chen
  • 21
  • 3