ImageMagick tries to handle all frames of an 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?".
RandomTroll
Posts: 15
Joined: 2017-12-28T11:38:17-07:00
Authentication code: 1152

Re: ImageMagick tries to handle all frames of an animated GIF

Post by RandomTroll »

Getting 1 pixel from each image made no difference: IM still made an 8MB temp file for each frame.

I run it with no other apps running. top reports it using 2-2.4 GB RAM, 64-80% - not all. 149 frames, 8 MB each: that's 1.2 GB: why does IM cache to disk?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: ImageMagick tries to handle all frames of an animated GIF

Post by fmw42 »

You need enough room for the input and the output in RAM and any temp files that may be created. So I suspect you are running out of RAM.
RandomTroll
Posts: 15
Joined: 2017-12-28T11:38:17-07:00
Authentication code: 1152

Re: ImageMagick tries to handle all frames of an animated GIF

Post by RandomTroll »

python-pillow's explode.py extracts individual frames in a jiffy; gifbuild returns a count quickly. I've solved my problem but not answered my question.
RandomTroll
Posts: 15
Joined: 2017-12-28T11:38:17-07:00
Authentication code: 1152

Re: ImageMagick tries to handle all frames of an animated GIF

Post by RandomTroll »

fmw42 wrote: 2017-12-30T11:13:06-07:00 You need enough room for the input and the output in RAM and any temp files that may be created. So I suspect you are running out of RAM.
You can suspect that, but it's inconsistent with observation.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: ImageMagick tries to handle all frames of an animated GIF

Post by snibgo »

RandomTroll wrote:... why does IM cache to disk?
From what you've said, I can only think that the O/S is denying the memory requests. Have you tried "-debug all"?
snibgo's IM pages: im.snibgo.com
RandomTroll
Posts: 15
Joined: 2017-12-28T11:38:17-07:00
Authentication code: 1152

Re: ImageMagick tries to handle all frames of an animated GIF

Post by RandomTroll »

snibgo wrote: 2017-12-30T14:35:22-07:00
RandomTroll wrote:... why does IM cache to disk?
From what you've said, I can only think that the O/S is denying the memory requests. Have you tried "-debug all"?
top reports that it's getting 2-2.4GB of RAM and there's still .6GB free. That should easily be enough to hold a 7MB input file and 149 8MB output files. I occasionally run other apps that use all my RAM.

There's a more important question: why does IM have to render every frame just to count them? to extract a single one? Even if it does it all in RAM, it's a waste.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: ImageMagick tries to handle all frames of an animated GIF

Post by fmw42 »

I don't know if this helps, but to get the number of frames, you can do (on Unix)

Code: Select all

convert rose: rose: rose: rose.gif

Code: Select all

identify -ping -format "%n\n" rose.gif | head -n 1
3
The -ping avoids reading the pixel data and just reads from the header, if the information is in the header.
Post Reply