png-dpi-cli
Reader
Detect width, height and DPI for PNG image.
Retina screenshots
https://i.gyazo.com/5edcf7b10ee138faac70938314b3c97f.png
non-Retina screenshot
Writer
Write DPI for PNG image.
code:reader.ts
import {args, Buffer} from 'deno'
const main = async () => {
if (!args1) throw new Error('image url is required.') let buf: Buffer
if (!/https?:\/\//.test(srcUrl)) {
buf = await loadLocalImage(srcUrl)
} else {
buf = await fetchImage(srcUrl)
}
console.log(await parsePngFormat(buf))
}
main()
code:writer.ts
import {args, Buffer, stdout} from 'deno'
const main = async () => {
if (!args1) throw new Error('image url is required.') if (!args2) throw new Error('dpi is required.') let buf: Buffer
if (!/https?:\/\//.test(srcUrl)) {
buf = await loadLocalImage(srcUrl)
} else {
buf = await fetchImage(srcUrl)
}
const arr: Uint8Array = await writePngDpi(buf, dpi)
stdout.write(arr)
}
main()