0

After much struggling, I've managed to get node-canvas installed on Windows.

When I try to read in the image size of a GIF, however, it just gives me back 0 for the width and height.

var FileSystem = require('fs');
var Canvas = require('canvas');

FileSystem.readdir(baseDir, function(err, files) {
    files.forEach(function(filename) {
        var path = Path.join(baseDir, filename);
        FileSystem.readFile(path, function(err, buf) {
            var img = new Canvas.Image;
            img.src = buf;
            console.log(path, img.width, img.height);
        });
});

Is it not supposed to be able to read GIFs?

Charles
  • 50,943
  • 13
  • 104
  • 142
mpen
  • 272,448
  • 266
  • 850
  • 1,236

1 Answers1

1

You must install giflib and reinstall node-canvas like is said in here https://github.com/LearnBoost/node-canvas/wiki/Installation---OSX and then you will be able to manipulate your gif file (retrieve width/height). But beware, the image processed with canvas will stop being animated.