Skip to content
Browse files

cleanup resize example

  • Loading branch information...
1 parent 804eeb6 commit 92e612bdc679131016e2faa91363f50f5289907c @tj tj committed
Showing with 4 additions and 2 deletions.
  1. +4 −2 examples/resize.js
View
6 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);

0 comments on commit 92e612b

Please sign in to comment.
Something went wrong with that request. Please try again.