guyonroche / imagejs

Pure JavaScript NodeJS Image Processing Module
MIT License
77 stars 5 forks source link

When a bitmap comes from readFile rotate crashes #4

Open abepetrillo opened 7 years ago

abepetrillo commented 7 years ago

Given the following code:

var ImageJS = require('imagejs');

var bitmap = new ImageJS.Bitmap();

bitmap.readFile('image.png')
    .then(function() {
        // bitmap is ready
        var rotated = bitmap.rotate({degrees: -10, fit: 'crop'});
        bitmap.writeFile("rotated-image.png", {type: ImageJS.ImageType.PNG})
    });

I get an error:

Unhandled rejection TypeError: Cannot read property 'data' of undefined
    at module.exports (...node_modules/imagejs/lib/bitmap.js:46:46)

Not sure if I'm using the tool as intended, but was referencing the readme.

abepetrillo commented 7 years ago

Seems to be related to using a negative value for the degrees attribute.