Skip to content

Commit

Permalink
Merge pull request #1012 from jboolean/720w
Browse files Browse the repository at this point in the history
Add 720w and make progressive
  • Loading branch information
jboolean authored Jun 29, 2024
2 parents 1296709 + 4b5f7af commit ef031db
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions backend/convertImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ const FILENAMES: Record<string, Template> = {
prefix: 'jpg/',
suffix: '.jpg',
},
jpeg720: {
prefix: '720-jpg/',
suffix: '.jpg',
},
jpeg420: {
prefix: '420-jpg/',
suffix: '.jpg',
Expand Down Expand Up @@ -72,7 +76,9 @@ export const handler = async (event): Promise<unknown> => {
// ),

sharp(inputBuffer)
.jpeg()
.jpeg({
progressive: true,
})
.toBuffer()
.then((outputBuffer) =>
s3
Expand All @@ -86,9 +92,30 @@ export const handler = async (event): Promise<unknown> => {
.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
Expand Down

0 comments on commit ef031db

Please sign in to comment.