Skip to content

Commit eea9d1b

Browse files
committed
Fix image conversion.
1 parent fb832e1 commit eea9d1b

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

functions/function-helpers/upload-image.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,25 @@ import sharp from 'sharp';
22
import { upload } from './upload.js';
33

44
export async function uploadImage(photo) {
5+
console.log('Converting image...', photo);
6+
57
const time = Date.now();
6-
const resized = sharp(photo.content).resize(800);
7-
const [jpeg, avif, webp] = Promise.all([
8-
resized.jpeg().toBuffer(),
9-
resized.avif().toBuffer(),
10-
resized.webp().toBuffer()
11-
]);
8+
const jpeg = await sharp(photo.content)
9+
.resize(800)
10+
.jpeg()
11+
.toBuffer();
1212
await upload('New photo (jpeg).\n\n[skip ci]', 'images', `${time}.jpeg`, jpeg);
13+
14+
const avif = await sharp(photo.content)
15+
.resize(800)
16+
.avif()
17+
.toBuffer();
1318
await upload('New photo (avif).\n\n[skip ci]', 'images', `${time}.avif`, avif);
19+
20+
const webp = await sharp(photo.content)
21+
.resize(800)
22+
.webp()
23+
.toBuffer();
1424
await upload('New photo (webp).\n\n[skip ci]', 'images', `${time}.webp`, webp);
1525

1626
return `/images/${time}.jpeg`;

0 commit comments

Comments
 (0)