0.1.4 • Published 11 years ago
img-to-canvas v0.1.4
img-to-canvas
Convert an img tag into a canvas tag, optionally with clipped dimensions (works only in browser).
Usage
imgan<img>elementxthe distance along the x axis to begin croppingythe distance along the y axis to begin croppingwidththe width of the section you want to cropheightthe height of the section you want to cropscaleWidthscale the final image up/down to this width (optional - defaults towidth)scaleHeightscale the final image up/down to this height (optional - defaults toheight)
Returns a canvas element containing the cropped image.
Example
var img = document.querySelector('#img-to-crop')
imgToCanvas(img, 20, 20, 40, 40)Takes #img-to-crop and generates a canvas that contains a 40x40 square of pixels 20 pixels into the image along each axis.