I tried something like this.

I have an original image with a width of 300 and a height of 227. And I'm going to collapse this image 15 pixels down. Therefore, create a canvas with the same width and height = imageWidth + 15 px. i.e. 227 + 15 = 242.
HTML:
<img id="source" src="rhino.jpg"> <canvas id="canvas" width="300" height="242" ></canvas>
Javascript
var canvas = document.getElementById('canvas'); var ctx = canvas.getContext('2d'); var img = document.getElementById('source'); var x1 = img.width / 2; var x2 = img.width; var y1 = 15;
Sajith Mar 18 '15 at 9:33 2015-03-18 09:33
source share