# changedpi

> Quickly change the dpi for an image without re enconding

Latest version **1.0.4** (published 2018-10-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install changedpi
pnpm add changedpi
yarn add changedpi
bun add changedpi
```

## 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.4 |
| Published | 2018-10-22 |
| First published | 2018-06-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 21.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 242 |
| Author | Andrea Bogazzi |
| Maintainers | sstk-admin |
| Keywords | dpi, ediot, imagemagick, image, header, jpeg, png |

## Links

- npm: https://www.npmjs.com/package/changedpi
- Repository: https://github.com/shutterstock/changeDPI
- Homepage: https://github.com/shutterstock/changeDPI#readme
- Issues: https://github.com/shutterstock/changeDPI/issues
- npm.io page: https://npm.io/package/changedpi

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 1.0.4 (latest) — 2018-10-22
- 1.0.3 — 2018-07-12
- 1.0.2 — 2018-07-12
- 1.0.1 — 2018-06-07

## README

# changeDPI

changeDPI provides 2 utility functions that can change the dpi of canvas-generated image, of either dataUrl or Blob formats. The functions work on separating the header from the image data, converting and manipulating just the header, then sticking the header back on the file. In this way, very large images can be converted fast without having to convert the entire contents of an image file. This process is non-destructive&mdash;image data does not get modified in the process.

## Install

This project depends on [node](https://nodejs.org) and [npm](https://npmjs.com).

```js
npm install --save changedpi
```

## Usage

From a canvas element dataUrl:
```js
// create the dataUrl at standard 72dpi
var dataUrl = canvas.toDataURL('image/jpeg', 0.92);
var daurl150dpi = changeDpiDataUrl(dataUrl, 150);
```

From a canvas element blob:
```js
// create the blob at standard 72dpi
canvas.toBlob(function(blob) {
  changeDpiBlob(blob, 300).then(function(blob){
    // use your changed blob
  })
},'image/jpeg', 0.92);
```

```js
  TODO add example with file reader.
```

### ES6

This module uses ES6. To see a compiled ES5 version, run `npm run build` and look in `dist/`.

## Testing

```js
npm install .
npm run test
```

## Contribute

Please do contribute! Open an issue or submit a pull request.

The project falls under [@Shutterstock](https://github.com/shutterstock/welcome)'s [Code of Conduct](https://github.com/shutterstock/welcome/blob/master/CODE_OF_CONDUCT.md).

## License

MIT.

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