Skip to content

Instantly share code, notes, and snippets.

@fquarters
fquarters / gist:5455460
Last active March 26, 2016 10:17
This plugin is dead simple. It takes your large image and gives you back a proportionally downscaled one as a dataURL object. Works fine in both Chrome and Firefox, not so fine in Opera (‘onload’ event doesn’t fire as it should and I have no idea why, seems to be a “known bug”), and doesn’t work in IE (it may work in IE10 though, but I couldn’t …
var Resizer = function() {
var maxWidth = 0, maxHeight = 0;
var canvas = document.createElement('canvas');
var img = new Image();
var callback;
var isFileOk = function(file) {
if (!file || !file.type.match(/image.*/)) {
return false;