cstefanache / angular2-img-cropper

Angular 2 Image Cropper
MIT License
364 stars 135 forks source link

Support for Image conversion and comperssion #57

Closed andriesvn01 closed 8 years ago

andriesvn01 commented 8 years ago

Any chance of adding Image Conversion and Compression support?

Been looking through the code and it seems it would be simple enough since the resulting image is already loaded into a canvas and exported from there. So it would basically just require an additional setting specifying the output format you want and the quality.

Then in the imageCropper, instead of using this.croppedImage.src = this.cropCanvas.toDataURL("image/" + this.fileType);

you would end up with someting like if (this.settings.OutputFormat){ //Since compression would only work on jpg and webp if (this.settings.OutputFormat == "image/jpg" | this.settings.OutputFormat == "image/webp"){ this.croppedImage.src = this.cropCanvas.toDataURL(this.settings.OutputFormat,this.settings.OutputQuality); } else { this.croppedImage.src = this.cropCanvas.toDataURL(this.settings.OutputFormat) } } else { this.croppedImage.src = this.cropCanvas.toDataURL("image/" + this.fileType); }

Im assuming that this might break your circular image transparency?

jurienhamaker commented 8 years ago

Pull requests are always appreciated.

More info: https://help.github.com/articles/about-pull-requests/

as for now, it's not a core function for "cropping images", Neither is it an issue, as you can always do this after obtaining the base64 yoursel.