Skip to content

Instantly share code, notes, and snippets.

@uploadcare-user
Forked from dayton1987/abetterone.js
Created October 17, 2016 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uploadcare-user/11780cd4a704882142fee0191210c919 to your computer and use it in GitHub Desktop.
Save uploadcare-user/11780cd4a704882142fee0191210c919 to your computer and use it in GitHub Desktop.
brr_blog_script1
function resizeImage(image, width, height) {
var cIn = document.createElement('canvas');
cIn.width = image.width;
cIn.height = image.height;
var ctxIn = cIn.getContext('2d');
ctxIn.drawImage(image, 0, 0);
var dataIn = ctxIn.getImageData(0, 0, image.width, image.heigth);
var dataOut = ctxIn.createImageData(width, heigth);
resizePixels(dataIn, dataOut);
var cOut = document.createElement('canvas');
cOut.width = width;
cOut.height = height;
cOut.getContext('2d').putImageData(dataOut, 0, 0);
return cOut;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment