imagejs icon indicating copy to clipboard operation
imagejs copied to clipboard

When a bitmap comes from readFile rotate crashes

Open abepetrillo opened this issue 7 years ago • 1 comments

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 avatar Oct 20 '17 12:10 abepetrillo

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

abepetrillo avatar Oct 20 '17 12:10 abepetrillo