0.1.4 • Published 10 years ago

img-to-canvas v0.1.4

Weekly downloads
9
License
MIT
Repository
github
Last release
10 years ago

img-to-canvas

Convert an img tag into a canvas tag, optionally with clipped dimensions (works only in browser).

Usage

  • img an <img> element
  • x the distance along the x axis to begin cropping
  • y the distance along the y axis to begin cropping
  • width the width of the section you want to crop
  • height the height of the section you want to crop
  • scaleWidth scale the final image up/down to this width (optional - defaults to width)
  • scaleHeight scale the final image up/down to this height (optional - defaults to height)

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.

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago