Copyright 2025

The Valley of Code

A Flavio Copes project

Optimize images from a Node.js script
Optimize images from a Node.js script

One tool I’ve been using to optimize images is sharp.

import sharp from 'sharp'

Here’s how I used it to convert images to webp:

await sharp('image.png')
  .webp({ lossless: true })
  .toFile('image.webp')

It can do a lot more image processing stuff like rotate resize etc.


Join my AI Workshop !

The Web Development BOOTCAMP cohort starts in February 2026