Convert set of images streamed to STDIN into animated 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
jdevelop
Posts: 1
Joined: 2013-11-15T23:24:34-07:00
Authentication code: 6789

Convert set of images streamed to STDIN into animated GIF

Post by jdevelop »

Hello!

I have third-party app which writes set of PNG images to STDOUT. Is there any way to get animated GIF from these images? I tried so far

Code: Select all

app | convert png:- output.gif
but that captures only first image and skips all subsequent frames.

Please advice.
zarel
Posts: 1
Joined: 2018-02-21T05:43:11-07:00
Authentication code: 1152

Re: Convert set of images streamed to STDIN into animated GIF

Post by zarel »

I know this thread is very old but we encountered the very same problem and I wanted to avoid the "wisdom of the ancients" effect.

It looks like that many images can be passed to convert via STDIO only when they're in PPM format. If you don't want to change your app to output PPM you can pipe your app output to ffmpeg and then to convert like this:

Code: Select all

app | ffmpeg -i - -f image2pipe -vcodec ppm - | convert - output.gif
We tested it with an app that streams JPGs and PNGs
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert set of images streamed to STDIN into animated GIF

Post by snibgo »

Extra bytes at the end of a PNG stream are ignored by IM, hence only the first PNG is processed. The same is true of JPG. Some formats (eg PPM, GIF, TIFF and MIFF) can contain multiple images, and each will be processed.
snibgo's IM pages: im.snibgo.com
Post Reply