Skip to content

Instantly share code, notes, and snippets.

@odoe
Created April 25, 2019 15:56
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 odoe/33db014a099a186d2db21e3f0d200a4c to your computer and use it in GitHub Desktop.
Save odoe/33db014a099a186d2db21e3f0d200a4c to your computer and use it in GitHub Desktop.
import { resolve } from 'path';
import { v } from '@dojo/framework/widget-core/d';
import * as sharp from 'sharp';
export default async function (path: string) {
path = resolve(__dirname, path);
// resize my images
const images = [
await sharp(path).resize(200).toBuffer(),
await sharp(path).resize(300).toBuffer(),
await sharp(path).resize(400).toBuffer(),
await sharp(path).resize(500).toBuffer()
];
return images.map((a) =>
v('img', { src: `data:image/jpeg;base64, ${a.toString('base64')}`, alt: 'sally' })
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment