resizeImage: generate an image in the format of the original image. (Tested with tranparent PNG, transparent GIF, BMP, JPEG)

paul/schema_breaking_changes
Emmanuel ROHEE 2014-08-22 10:48:00 +02:00
parent c8d0c4762d
commit 53f4fbd99a
1 changed files with 3 additions and 1 deletions

View File

@ -103,7 +103,9 @@ angular.module('mUtilities', [])
var ctx = canvas.getContext("2d");
ctx.drawImage(img, 0, 0, width, height);
var dataUrl = canvas.toDataURL("image/jpeg", 0.7);
// Extract image data in the same format as the original one.
// The 0.7 compression value will work with formats that supports it like JPEG.
var dataUrl = canvas.toDataURL(imageFile.type, 0.7);
deferred.resolve(self.dataURItoBlob(dataUrl));
};
img.onerror = function(e) {