crop-image
Takes an img tag and crops it according to the specified dimensions/offsets
Last updated 5 years ago by ashaffer88 .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install crop-image 
SYNC missed versions from official npm registry.

img-to-canvas

Convert an img tag into an (optionally cropped) blob (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 blob containing the cropped image.

Example

var img = document.querySelector('#img-to-crop')
var blob = cropImage(img, 20, 20, 40, 40)
upload(blob)

Takes #img-to-crop and generates a blob that contains a 40x40 square of pixels 20 pixels into the image along each axis.

Current Tags

  • 0.1.5                                ...           latest (5 years ago)

6 Versions

  • 0.1.5                                ...           5 years ago
  • 0.1.4                                ...           5 years ago
  • 0.1.3                                ...           5 years ago
  • 0.1.2                                ...           5 years ago
  • 0.1.1                                ...           5 years ago
  • 0.1.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 2
Last Month 3
Dependencies (2)
Dev Dependencies (0)
None
Dependents (2)

Copyright 2014 - 2016 © taobao.org |