diff --git a/backend/convertImage.ts b/backend/convertImage.ts index 69d21a9a..91fc297f 100644 --- a/backend/convertImage.ts +++ b/backend/convertImage.ts @@ -13,6 +13,10 @@ const FILENAMES: Record = { prefix: 'jpg/', suffix: '.jpg', }, + jpeg720: { + prefix: '720-jpg/', + suffix: '.jpg', + }, jpeg420: { prefix: '420-jpg/', suffix: '.jpg', @@ -72,7 +76,9 @@ export const handler = async (event): Promise => { // ), sharp(inputBuffer) - .jpeg() + .jpeg({ + progressive: true, + }) .toBuffer() .then((outputBuffer) => s3 @@ -86,9 +92,30 @@ export const handler = async (event): Promise => { .promise() ), + sharp(inputBuffer) + .resize(720, undefined, { withoutEnlargement: true }) + .jpeg({ + progressive: true, + quality: 95, + }) + .toBuffer() + .then((outputBuffer) => + s3 + .putObject({ + Body: outputBuffer, + Bucket: srcBucket, + Key: makeFilename(FILENAMES.jpeg720, rootKey), + ACL: 'public-read', + ContentType: 'image/jpeg', + }) + .promise() + ), + sharp(inputBuffer) .resize(420, undefined, { withoutEnlargement: true }) - .jpeg() + .jpeg({ + progressive: true, + }) .toBuffer() .then((outputBuffer) => s3