Breaks on animated GIF #6

Closed
oncletom opened this Issue Sep 27, 2013 · 9 comments

Projects

None yet

4 participants

The tasks stops. I wonder how it should treated.

pltan33 commented Dec 12, 2013

I don't seem to have that problem.....mine just takes the first frame of the gif... did you change any part of the code?

Owner

This is not something the task would directly support, it would be up to the library used for generating images to support this. There is an open issue for this in that Github repo.

Agreed. My only concern is it's impossible to distinguish an animated GIF from a static one through filenames.
Hence it's impossible to exclude files from the src, unless excluding all GIF files.

Is it possible to at least catch the error, to suggest the failure might be due to animations?

Owner

Hmm, I'll see what l can do.

drwlrsn commented Mar 3, 2014

@oncletom It looks like one could look at the GIF's properties. I am still a little new at this and I haven't extensively tested a whole lot of GIFs, but there are some differences we can look for to determine if a GIF is animated.

Using gm('animated.gif').identify(function(err, data) { console.log(data) });, the data hash will look something like this:

{ Format: 'GIF (CompuServe graphics interchange format)',
  format: 'GIF',
  Geometry: '471x123',
  size: { width: 471, height: 123 },
  Class: 'PseudoClass',
  Type: 'palette',
  Depth: '8 bits-per-pixel component',
  depth: 8,
  'Channel Depths': { Red: '8 bits', Green: '8 bits', Blue: '8 bits' },
  'Channel Statistics': 
   { Red: 
      { Minimum: '1.00 (0.0039)',
        Maximum: '255.00 (1.0000)',
        Mean: '112.77 (0.4422)',
        'Standard Deviation': '65.19 (0.2557)' },
     Green: 
      { Minimum: '1.00 (0.0039)',
        Maximum: '243.00 (0.9529)',
        Mean: '74.26 (0.2912)',
        'Standard Deviation': '54.72 (0.2146)' },
     Blue: 
      { Minimum: '0.00 (0.0000)',
        Maximum: '240.00 (0.9412)',
        Mean: '45.87 (0.1799)',
        'Standard Deviation': '41.11 (0.1612)' } },
  Colors: 
   { '0': '(  1,  3,  0)\t  #010300',
     '1': '(  3,  3,  0)\t  #030300',
     '2': '(  1,  3,  3)\t  #010303',
     ...a bunch of colours
     '255': '(118,109,104)\t  #766D68' },
  color: 256,
  Filesize: '898.9K',
  Interlace: 'No',
  Orientation: 'Unknown',
  'Background Color': '#010300',
  'Border Color': '#DFDFDF',
  'Matte Color': '#BDBDBD',
  'Page geometry': '720x416+160+75',
  Compose: 'Over',
  Delay: '6',
  Iterations: '0',
  Scene: '15 of 16',
  Compression: 'LZW',
  Signature: 'a169966506be4b52155985e9158ceb8db265c6e2f6fade642f5b3174a153a050',
  Tainted: 'False',
  'User Time': '0.300u',
  'Elapsed Time': '0:01',
  'Pixels Per Second': '188.6K',
  path: 'animated.gif' }

And a representative non-animated GIF will look something like this:

{ Format: 'GIF (CompuServe graphics interchange format)',
  format: 'GIF',
  Geometry: '250x297',
  size: { width: 250, height: 297 },
  Class: 'PseudoClass',
  Type: 'palette',
  Depth: '4 bits-per-pixel component',
  depth: 4,
  'Channel Depths': { Red: '4 bits', Green: '4 bits', Blue: '4 bits' },
  'Channel Statistics': 
   { Red: 
      { Minimum: '0.00 (0.0000)',
        Maximum: '255.00 (1.0000)',
        Mean: '117.94 (0.4625)',
        'Standard Deviation': '52.24 (0.2049)' },
     Green: 
      { Minimum: '0.00 (0.0000)',
        Maximum: '204.00 (0.8000)',
        Mean: '114.14 (0.4476)',
        'Standard Deviation': '43.44 (0.1704)' },
     Blue: 
      { Minimum: '0.00 (0.0000)',
        Maximum: '204.00 (0.8000)',
        Mean: '62.30 (0.2443)',
        'Standard Deviation': '46.81 (0.1836)' } },
  Colors: 
   { '0': '(255,255,255)\t  white',
     '1': '(255,255,204)\t  #FFFFCC',
     '2': '(255,255,153)\t  #FFFF99',
     ...a bunch of colours
     '255': '(255,255,255)\t  white' },
  color: 256,
  Filesize: '27.9K',
  Interlace: 'No',
  Orientation: 'Unknown',
  'Background Color': 'white',
  'Border Color': '#DFDFDF',
  'Matte Color': '#BDBDBD',
  'Page geometry': '250x297+0+0',
  Compose: 'Over',
  Dispose: 'Undefined',
  Compression: 'LZW',
  Signature: '61f320a7c783dd8b81014f4ebdeb553de84d0d9972724bb6e2ed3a507742125d',
  Tainted: 'False',
  path: 'non-animated.gif' }

I noticed there is no data.Scene which means testing for this when the file is a GIF might solve the problem.

oncletom commented Mar 3, 2014

You also have the Delay, Iterations and Pixels Per Second headers.

I'm a bit like you, not knowing much things about GIF, but that's cool to learn that through this issue! :-)

drwlrsn commented Mar 3, 2014

Yeah exactly. I just chose Scene because it is one word and so I can use dot notation. It would be great to resize GIFs, but since this is a project about building responsive assets it might be better to create looping videos with a service like gyfycat.

Owner

In 0.1.4, animated GIFs are skipped by default. There's no way in Imagemagick to resize animated GIFs. You can in Graphicsmagick but the file size becomes huge. There's nothing I can do about this without writing my own image manipulation software and somehow fixing a problem the teams on those two projects haven't been able to solve. So I'd recommend not using this tool for that purpose and just putting 'skip' on.

Hope the skip option helps.

@andismith andismith closed this Sep 25, 2014

Yep thank you @andismith :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment