Skip to content

Instantly share code, notes, and snippets.

@myobie
Created March 25, 2022 11:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save myobie/9fd12cd3cdc32f6c613a154b249ea640 to your computer and use it in GitHub Desktop.
Save myobie/9fd12cd3cdc32f6c613a154b249ea640 to your computer and use it in GitHub Desktop.
Generate Blob import from file on disk with deno
const bytes = await Deno.readFile(new URL('./thumbnail.png', import.meta.url))
const encoder = new TextEncoder()
const contents = encoder.encode(
`export const thumbnail = new Blob(new Uint8Array(${
JSON.stringify(Array.from(bytes))
}), { type: 'image/png' })`
)
await Deno.writeFile(new URL('./hardcoded-thumbnail.ts', import.meta.url), contents)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment