lksv / node-resemble.js

LOOKING FOR MAINTAINER - Image analysis and comparison
MIT License
99 stars 37 forks source link

BMP file format support is missing #26

Open github-polymer-user opened 8 years ago

github-polymer-user commented 8 years ago

var jpeg = require('jpeg-js'); var bmp = require("bmp-js");

            if(ext=="png") {
                var png = new PNG();
                fs.createReadStream(fileData)
                  .pipe(png)
                  .on('parsed', function() {
                    callback(this, this.width, this.height);
                  });
            }
            if(ext=="jpg" || ext=="jpeg") {
                var jpegData = fs.readFileSync(fileData);
                fileData = jpeg.decode(jpegData, true);
                callback(fileData, fileData.width, fileData.height);
            }
            if(ext=="bmp") {
                var bmpData = fs.readFileSync(fileData);
                fileData = bmp.decode(bmpData, true);
                callback(fileData, fileData.width, fileData.height);
            }
mirzazeyrek commented 7 years ago

One of the most important reasons for adding jpeg support was the png sizes. They are bigger than jpg. AFAIK, bmp images are even bigger than PNGs.

Why not converting bmp files into jpg or png before comparing ? I can't come up with a scenario you would definitely need BMP...