png-chunk-phys

0.0.2 • Public • Published

png-chunk-pHYs

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

CircleCI

Installation

$ npm install png-chunk-phys

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

Readme

Keywords

none

Package Sidebar

Install

npm i png-chunk-phys

Weekly Downloads

0

Version

0.0.2

License

MIT

Unpacked Size

11.3 kB

Total Files

7

Last publish

Collaborators

  • daiiz