[](https://github.com/onigoetz/resquoosh/releases)  
!License
!GitHub Workflow Status

Resquoosh is a fork of @squoosh/lib.
But copied from Vercel's fork.
This version has a simple API.
``javascript
import fs from "node:fs/promises";
import { optimizeImage, getImageSize } from "@onigoetz/resquoosh";
const file = await fs.readFile("file.jpg");
const size = await getImageSize(file);
console.log(size); // { width: 400, height: 400 }
const optimized = await optimizeImage(file);
// returns an optimized buffer
`
Get the size of an image within a Buffer.
Supports the same formats as image-size + AVIF.
Compresses images, optionally resize or rotate the image.
- webp (Except animated webp)
- avif
- jpeg
- png
`typescript``
interface OptimizeOptions {
/**
* Value between 1 and 100
*/
quality?: number;
/**
* If only width is specified; will resize and respect ratio
*/
width?: number;
/**
* If only height is specified; will resize and respect ratio
*/
height?: number;
}