unjs / ipx

🖼️ High performance, secure and easy-to-use image optimizer.
MIT License
1.2k stars 59 forks source link

Ability to provide options to Sharp operations #207

Open jameswragg opened 5 months ago

jameswragg commented 5 months ago

Describe the feature

I've found myself wanting to use IPX to transform the image format & wanting to supply options, e.g. process an animated gif by reducing the colour count (and therefore size), which is supported by Sharp but I have no interface for supplying these arguments to modifiers.

I totally understand if Sharp output options are out of scope but spitballing here, a path API for Sharp operation options could look like this:

/f_gif[colours:16|dither:0.5|reuse:true]/buffalo.png --> .gif({ colours: 16, dither: 0.5, reuse: false })

/rotate_45[background:00ff00]/buffalo.png --> .rotate(45, { background: '00ff00' })

Additional information