load-image
code:mod.ts
import {open, copy, Buffer} from 'deno'
export const loadLocalImage = async (srcPath): Promise<Buffer> => {
const imgFile = await open(srcPath)
const buf = new Buffer()
await copy(buf, imgFile)
return buf // Buffer {off: 0, buf: []}
}
インターネットから画像データをfetchして、Bufferに読み込む code:mod.ts
export const fetchImage = async (srcUrl): Promise<Buffer> => {
const res = await fetch(srcUrl)
return new Buffer(await res.arrayBuffer())
}