Skip to content

Commit

Permalink
feat: Adjust AVIF image processing quality and sharpening
Browse files Browse the repository at this point in the history
- Update AVIF image processing quality parameter to ensure optimal compression
- Add sharpening to AVIF transformation for improved image clarity
  • Loading branch information
ITJesse committed May 10, 2024
1 parent b062e1a commit 006716b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/lib/optimizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ export function optimizeImage({
}

if (contentType === AVIF) {
const avifQuality = Math.max(quality - 25, 45)
const avifQuality = Math.max(quality - 25, 40)
transformer
.avif({
effort: 3,
effort: 4,
quality: avifQuality,
chromaSubsampling: '4:2:0', // same as webp
bitdepth: 8,
})
.sharpen()
.sharpen({ sigma: 0.5, m1: 0.5, m2: 1.5 })
} else if (contentType === WEBP) {
transformer.webp({ quality })
} else if (contentType === PNG) {
Expand Down
7 changes: 1 addition & 6 deletions src/server/routes/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ import fs from 'fs'
import { NumberFromString } from 'io-ts-types'
import { PassThrough } from 'node:stream'

import {
AVIF,
returnOriginalFormats,
supportedFormats,
supportedTargetFormats,
} from '@/consts'
import { returnOriginalFormats, supportedFormats, supportedTargetFormats } from '@/consts'
import { getWithCache } from '@/lib/cache'
import { config, shouldUseOssCompressionForAvif } from '@/lib/config'
import { D, E, O } from '@/lib/fp'
Expand Down

0 comments on commit 006716b

Please sign in to comment.