From 4b670228ff8425a92b68c324ff519036a4527954 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Sun, 3 Mar 2013 20:30:07 +0200 Subject: [PATCH] Fix canvas image ratio (don't stretch or squash) --- converse.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/converse.js b/converse.js index 8c9bc0a6b..0dddb40ce 100644 --- a/converse.js +++ b/converse.js @@ -597,8 +597,8 @@ var ctx = this.$el.find('canvas').get(0).getContext('2d'); var img = new Image(); // Create new Image object img.onload = function(){ - // execute drawImage statements here - ctx.drawImage(img,0,0, 35, 35) + var ratio = img.width/img.height; + ctx.drawImage(img,0,0, 35*ratio, 35) } img.src = img_src;