vite-plugin-image-optimizer icon indicating copy to clipboard operation
vite-plugin-image-optimizer copied to clipboard

Convert to different image formats

Open VictorCam opened this issue 1 year ago • 5 comments

Describe the feature you'd like to request

It would be really great if you could convert an image into a different image formats for production

for example converting a png image into another format available in sharp like webp/avif/etc...

I think this would be great to save people the time when doing the conversion, and to save some additional space.

Describe the solution you'd like

maybe a toFormat option in the config file since that is the name of the method in the sharp package. Where you can specify as a string what format you would like to image to be converted to.

Additional context

https://sharp.pixelplumbing.com/api-output#toformat

Thank You!

Validations

  • [X] Read the docs.
  • [X] Check that there isn't already an issue that requests the same feature to avoid creating a duplicate.

VictorCam avatar Jun 08 '23 02:06 VictorCam

Hey @VictorCam thank you for the suggestion, this is being looked at the PR raised by @netolicak. You can follow the progress https://github.com/FatehAK/vite-plugin-image-optimizer/pull/23

FatehAK avatar Jul 21 '23 13:07 FatehAK

Sound good. Thank you!

VictorCam avatar Jul 22 '23 16:07 VictorCam

An extremely necessary option.

tuber84 avatar Sep 21 '23 20:09 tuber84

I need that)

sergey-yarchuk-4ib avatar Oct 02 '23 12:10 sergey-yarchuk-4ib

It could be awesome if the plugin generates various outputs and automatically choose the best file at runtime based on file size and format.

  1. The plugin could generate automatically avif, webp, png and jpg (only if the pictures don't contains alpha channel)
  2. We remove useless file based on sizes and original file size (example: it's useless to keep a webp file if the png file is smaller / it's useless to keep "optimized" file if the original one is smaller)
  3. At runtime, we test the Avif and webp compatibility, based on these tests, we resolve the smallest file

Maxou44 avatar Mar 01 '24 00:03 Maxou44

Lighthouse keeps on complaining and wanting me to use webp. I am not sure if every browser supports webp but it seems most do? I am trying to figure out how to use this plugin along with others to make webp. Any chance this issue is being worked on still? Thanks

quetzalsly avatar Oct 30 '24 11:10 quetzalsly