stomita/ios-imagefile-megapixel

[Enhancement] provide method for rendering scaled images

Closed this issue · 1 comments

Would be nice if MegaPixImage could render scaled images, like:

var imageWidth = 4000;
var imageHeight = 3000;
var newWidth = 80;
var newHeight = 60;

canvas = document.createElement('canvas');
canvas.width = newWidth;
canvas.height = newHeight;
canvas.getContext('2d').drawImage(image, 0, 0, newWidth, newHeight);

if I do:

canvas = document.createElement('canvas');
canvas.width = newWidth;
canvas.height = newHeight;

var mpi = new MegaPixImage(image);
mpi.render(canvas, {
       width: newWidth,
       height: newHeight
});

the image get´s cropped

Oh, used an older version of MegaPixImage ... the current one does scale. Great work! closed.