resizeImage: generate an image in the format of the original image. (Tested with tranparent PNG, transparent GIF, BMP, JPEG)
This commit is contained in:
parent
c8d0c4762d
commit
53f4fbd99a
1 changed files with 3 additions and 1 deletions
|
@ -103,7 +103,9 @@ angular.module('mUtilities', [])
|
||||||
var ctx = canvas.getContext("2d");
|
var ctx = canvas.getContext("2d");
|
||||||
ctx.drawImage(img, 0, 0, width, height);
|
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));
|
deferred.resolve(self.dataURItoBlob(dataUrl));
|
||||||
};
|
};
|
||||||
img.onerror = function(e) {
|
img.onerror = function(e) {
|
||||||
|
|
Loading…
Reference in a new issue