https://github.com/semibran/image-clip
Clip out transparent pixels from an image
https://github.com/semibran/image-clip
clip crop image
Last synced: about 1 year ago
JSON representation
Clip out transparent pixels from an image
- Host: GitHub
- URL: https://github.com/semibran/image-clip
- Owner: semibran
- License: mit
- Created: 2017-02-26T19:07:20.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-02-28T05:10:10.000Z (over 9 years ago)
- Last Synced: 2025-02-12T18:59:23.107Z (over 1 year ago)
- Topics: clip, crop, image
- Language: JavaScript
- Homepage:
- Size: 9.77 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# image-clip
> Clip out transparent pixels from an image
Converts an image or canvas like this:

to a canvas with the edges clipped off:

## Installation
```sh
npm install semibran/image-clip
```
## Usage
```javascript
const clip = require('image-clip')
```
### `clip`
```javascript
clip(image, rect*) // => HTMLCanvasElement
```
Get the clipped version of an `Image` or `HTMLCanvasElement`. If `rect` is not provided, `clip.bounds` will be used instead.
### `bounds`
```javascript
clip.bounds(image) // => Rect
```
Get the relative bounding box of a prospective clipped image in the form `{ x, y, width, height }`. See [`semibran/rect`](https://github.com/semibran/rect) for more details.
## License
MIT