Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Animated images render incorrectly when viewed dynamically #44

Closed
juan-manuel-alberro opened this issue May 4, 2017 · 5 comments
Closed
Labels
Milestone

Comments

@juan-manuel-alberro
Copy link
Contributor

Summary

The GIF images doesn´t work as expected after publish

Steps to Reproduce

  1. Create a new publication
  2. Add a GIF and insert it into the publication
  3. Save

Additional info

  • Postleaf version: latest version from master
  • Node version: 7.9.0
  • Affected browsers: alls
  • Operating system: macOS Sierra

Demo

@claviska
Copy link
Member

claviska commented May 4, 2017 via email

@juan-manuel-alberro
Copy link
Contributor Author

Is the GIF from the Atom's website, here's the link.

@claviska claviska added the Bug label May 4, 2017
@claviska claviska added this to the 1.0.0-alpha.4 milestone May 4, 2017
@claviska
Copy link
Member

claviska commented May 4, 2017

This is an issue with how GraphicsMagick handles animated GIFs. I need to investigate this more, but I believe this option will be helpful: https://www.graphicsmagick.org/GraphicsMagick.html#details-coalesce

We either need to not process animated GIFs or find a reliable way to process them. Also affects Dynamic Images.

@claviska
Copy link
Member

claviska commented May 5, 2017

Found a fix using GM's coalesce method, but it deoptimizes frames, resulting in a larger image size than the original despite the dimensions getting smaller (in this case, 820x940 @ 296KB ==> 500x573 @ 5MB). It's also very time consuming and memory intensive, which I'm not comfortable with:

In dynamic_images.js:

// Detect animated images
.then((image) => {
  return new Promise((resolve, reject) => {
    image.identify('%n\n', (err, info) => {
      if(err) reject(err);

      info = info.split('\n');
      let numFrames = parseInt(info[0]);

      if(numFrames > 1) {
        image.coalesce().write(targetFile, (err) => {
          if(err) return reject(err);
          return resolve(Gm(targetFile));
        });
      } else {
        return resolve(image);
      }
    });
  });
})

Still looking into options.

@claviska claviska changed the title Issue with GIF files? Animated images render incorrectly when viewed dynamically May 5, 2017
@claviska
Copy link
Member

claviska commented May 5, 2017

The best I can do to address this is to simply not process images with animation (see 59921a3). This leaves animations unaltered, but at the expense of not being able to use any Dynamic Images with them. Unfortunately, this type of processing is just too slow and memory intensive.

One alternative is to use just the first frame of the animation, but that may cause confusion since the original would be animated but modified versions won't.

@claviska claviska closed this as completed May 5, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants