Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image artifacting even just with readimage -> writegif no-op #3

Open
jasonrhodes opened this issue Sep 7, 2014 · 1 comment
Open

Comments

@jasonrhodes
Copy link
Member

It's hard for me to narrow down if this is a problem with writegif or with readimage, but I've noticed that while unaltered meatspace GIFs come out of readimage/writegif perfectly, a lot of other GIFs come through with strange pixel artifacting.

Simplest reproduction:

function makeDataUri(type, buffer) {
  return 'data:' + type + ';base64,' + buffer.toString('base64');
}

function imgTag(image) {
  return "<img src='" + makeDataUri("image/gif", image) + "' />";
}

// readimage/writegif no-op
function writegiftest(buffer, cb) {
  readimage(buffer, function (err, buf) { 
    writegif(buf, cb); 
  });
}

// Express.js route
app.get("/writegiftest", function (req, res) {
  fs.readFile("./gifs/example.gif", function (err, buffer) {

    if (err) {
      res.send(err);
      return;
    }

    writegiftest(buffer, function (err, image) {
      res.send(imgTag(image));
    });

});

You can see two examples below, one is a Photoshop-resized meatspace GIF, the other is just a GIF of Homer Simpson from GIS.

homer
homer-noop
ryan-thumb
ryan-thumb-noop

@brycebaril
Copy link
Member

I'm pretty sure this is due to gif optimization, where I think optimized gifs have no data set for the pixels that don't change.

However, since data isn't cleared from Node buffers by default, I think what happens is the "empty" data gets occupied with random noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants