.identify returning last frame size instead of the largest - fixes #393

master
Philippe de Reynal 9 years ago
parent 1d833f7ea5
commit e05346a217
  1. 13
      lib/getters.js
  2. 20
      test/393.js
  3. BIN
      test/fixtures/nyancat.gif

@ -280,9 +280,16 @@ module.exports = function (gm) {
// We only want the size of the first frame.
// Each frame is separated by a space.
var split = val.split(" ").shift().split("x");
o.size = {
width: parseInt(split[0], 10)
, height: parseInt(split[1], 10)
var width = parseInt(split[0], 10);
var height = parseInt(split[1], 10);
if (o.size && o.size.width && o.size.height) {
if (width > o.size.width) o.size.width = width;
if (height > o.size.height) o.size.height = height;
} else {
o.size = {
width: width,
height: height
}
}
};

@ -0,0 +1,20 @@
'use strict';
var assert = require('assert');
var fs = require('fs');
var path = require('path');
module.exports = function (_, dir, finish, gm) {
if (!gm.integration) return finish();
var imagePath = path.join(__dirname, './fixtures/nyancat.gif');
var inputStream = fs.createReadStream(imagePath);
gm(inputStream)
.identify({ bufferStream: true }, function(err, value) {
if (err) return finish(err);
var size = value.size;
assert.equal(400, size.width);
assert.equal(400, size.height);
finish();
});
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Loading…
Cancel
Save