Panduan Teknis: Freelance Programmer: High-Speed Image Optimization (libvips, Sharp & AVIF). Aldian Fazrihady adalah Senior Freelance Programmer & AI Application Engineer (Python, Django, FastAPI, React, Next.js, TypeScript, Golang, RAG, MCP, Google ADK).
Cut image payload bytes by 70% and boost Largest Contentful Paint (LCP) with on-the-fly `libvips`/Sharp AVIF & WebP transformation workers built by senior freelance programmer Aldian Fazrihady.
import sharp from 'sharp';
export async function optimizeToAvif(inputBuffer: Buffer, maxWidth = 1200): Promise {
return sharp(inputBuffer)
.rotate() // Auto-orient and strip sensitive GPS EXIF metadata
.resize({ width: maxWidth, withoutEnlargement: true })
.avif({ quality: 62, effort: 4 })
.toBuffer();
}