![]() ![]() gap to decrease in size until we reach the target size, Var startSmallerDim = Math.min(image.width, image.height) Var startDim = Math.max(image.width, image.height) if image size already within target size, just copy and return blob use caller dimension or default length if none providedĬonst length = maxLength = null ? MAX_LENGTH : maxLength ĬanvasContext.drawImage(image, 0, 0, image.width, image.height) The lanczos convolution approach is higher quality at the cost of being slower, whereas the step-wise downscaling approach produces reasonably antialiased results and is significantly faster.Įxample usage: angular.module('demo').controller('ExampleCtrl', function (imageService) The service includes two solutions because they both have their own pros / cons. The hook function to execute before drawing the image into the canvas for compression.I created a reusable Angular service to handle high quality resizing of images / canvases for anyone who's interested:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |