# @f/img-to-canvas

> Convert an img tag to a canvas element where it can be manipulated

Latest version **1.0.0** (published 2016-05-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install @f/img-to-canvas
pnpm add @f/img-to-canvas
yarn add @f/img-to-canvas
bun add @f/img-to-canvas
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2016-05-26 |
| First published | 2016-05-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | f |

## Links

- npm: https://www.npmjs.com/package/@f/img-to-canvas
- Repository: https://github.com/micro-js/img-to-canvas
- Homepage: https://github.com/micro-js/img-to-canvas#readme
- Issues: https://github.com/micro-js/img-to-canvas/issues
- npm.io page: https://npm.io/package/@f/img-to-canvas

## Recent versions

- 1.0.0 (latest) — 2016-05-26

## README

# img-to-canvas

[![Build status][travis-image]][travis-url]
[![Git tag][git-image]][git-url]
[![NPM version][npm-image]][npm-url]
[![Code style][standard-image]][standard-url]

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

## Installation

    $ npm install @f/img-to-canvas

## Usage

```javascript
var toBlob = require('@f/dataurl-to-blob')
var toCanvas = require('@f/img-to-canvas')

function cropImage (img, x, y, width, height) {
  return toBlob(toCanvas(img, x, y, width, height).toDataURL('image/png'))
}
```

Returns a canvas element containing the cropped image.

## API

### imgToCanvas(arg)

* `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 image at the specified dimensions.

## License

MIT

[travis-image]: https://img.shields.io/travis/micro-js/img-to-canvas.svg?style=flat-square
[travis-url]: https://travis-ci.org/micro-js/img-to-canvas
[git-image]: https://img.shields.io/github/tag/micro-js/img-to-canvas.svg?style=flat-square
[git-url]: https://github.com/micro-js/img-to-canvas
[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square
[standard-url]: https://github.com/feross/standard
[npm-image]: https://img.shields.io/npm/v/@f/img-to-canvas.svg?style=flat-square
[npm-url]: https://npmjs.org/package/@f/img-to-canvas

---
_Source: https://npm.io/package/@f/img-to-canvas · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
