img-to-canvas
Convert an img tag into a canvas tag, optionally with clipped dimensions (works only in browser).
Usage
img
an<img>
elementx
the distance along the x axis to begin croppingy
the distance along the y axis to begin croppingwidth
the width of the section you want to cropheight
the height of the section you want to cropscaleWidth
scale the final image up/down to this width (optional - defaults towidth
)scaleHeight
scale the final image up/down to this height (optional - defaults toheight
)
Returns a canvas element containing the cropped image.
Example
var img = document
Takes #img-to-crop
and generates a canvas that contains a 40x40 square of pixels 20 pixels into the image along each axis.