Reader/Writer for png image's pHYs chunk on browsers.
$ npm install png-dpi-reader-writer
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)
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)
$ npm run start