# Optimize images from a Node.js script

**URL:** <https://forum.hhf.technology/t/optimize-images-from-a-node-js-script/379>\
**Category:** Node.js\
**Tags:** nodejs, optimize-images\
**Created:** [April 10, 2024, 4:48pm UTC](https://forum.hhf.technology/t/optimize-images-from-a-node-js-script/379 "2024-04-10T16:48:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hhf.technoloy](https://forum.hhf.technology/user_avatar/forum.hhf.technology/hhf.technoloy/32/68_2.png) [@hhf.technoloy](https://forum.hhf.technology/u/hhf.technoloy)\
**Post date:** [April 10, 2024, 4:48pm UTC](https://forum.hhf.technology/t/optimize-images-from-a-node-js-script/379/1 "2024-04-10T16:48:00Z")

</div>

I’ve been utilizing the [sharp](https://github.com/lovell/sharp) tool for image optimization.x`

```js
import sharp from 'sharp'

```

Here’s the method I employed to convert images to the webp format:

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

```

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