0.2.4 • Published 5 years ago

png-dpi-reader-writer v0.2.4

Weekly downloads
185
License
MIT
Repository
github
Last release
5 years ago

png-dpi-reader-writer

Reader/Writer for png image's pHYs chunk on browsers.

CircleCI

Installation

$ npm install png-dpi-reader-writer

Usage

Reader

Detect width, height and DPI for PNG image.

const res = await fetch(srcUrl, {mode: 'cors'})
const arrayBuffer = await res.arrayBuffer()

const {width, height, dpi} = parsePngFormat(arrayBuffer)

Writer

Write DPI for PNG image. See also demo/src/index.js.

const newByteArray = writePngDpi(arrayBuffer, window.devicePixelRatio * 72)

const img = document.querySelector('img')
img.src = convertToDataURI(newByteArray)

Demo

$ npm run start

Related projects

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago