diff --git a/examples/resize.js b/examples/resize.js index 0caa7f0..cd0f68b 100644 --- a/examples/resize.js +++ b/examples/resize.js @@ -15,9 +15,11 @@ img.onerror = function(err){ }; img.onload = function(){ - var canvas = new Canvas(img.width / 2, img.height / 2) + var width = img.width / 2 + , height = img.height / 2 + , canvas = new Canvas(width, height) , ctx = canvas.getContext('2d'); - ctx.drawImage(img, 0, 0, img.width / 2, img.height / 2); + ctx.drawImage(img, 0, 0, width, height); canvas.toBuffer(function(err, buf){ fs.writeFile(__dirname + '/resize.png', buf, function(){ console.log('Resized and saved in %dms', new Date - start);