webp-sh / webp_server_go

Go version of WebP Server. A tool that will serve your JPG/PNG/BMP/SVGs as WebP/AVIF format with compression, on-the-fly.

Home Page:https://docs.webp.sh

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Variable Compression Size Depending on File Size

mitchba98 opened this issue · comments

Heyo, thanks for the fantastic tool.

We have a requirement where we need to compress a range of files which range from user-uploaded pictures, to high-res renders of furniture.

Some of the high-res images can be scaled down by a compression factor of 20, and the result is great. This is when the original size can be in the MBs (3-5MBs)

Some of the images are already low resolution (<100kbs) , and can't be scaled down much (or at all), without incurring some significant quality drops.

Can we set a dynamic compression size based on the size of the original image? Or is there another solution that can be suggested?

Cheers.

Some of the high-res images can be scaled down by a compression factor of 20

Here "compression factor" do you mean QUALITY in config.json?

And what you want is to set different quality settings based on original image size
Or bypass convert if original image size is small enough?

If you mean the former one, we're currently building a SaaS based on WebP Server Go called WebP Cloud, and supports passing ?quality= to override the quality for each image, related docs: https://docs.webp.se/webp-cloud/feature/ , if you're showing images for public, maybe you can have a try on that service.(However this currently cannot automatically change based on original image size)

Hey Nova, thanks - yes we want to set different quality settings based on original image size.

Ideally with no query paramaters - something like being able to set a 'target size' and the server will compress the image by X to achieve close to target size (or bypass convert if not necessary)

Thanks

something like being able to set a 'target size'

That seems hard to archive, because we cannot predict the target file size before doing the compression.

But different compression rate based on original file size can be a lot easier to archive, we're planning to add this function on our WebP Cloud, if we've done that, would you like to be early user for that feature?

@mitchba98
I added some changes to support skipping compression for files smaller than the configured value.
#270

Thanks for that. I forked the repo and made some changes locally, so that should suffice for now.

@mitchba98
Glad to know it's helpful for you.
Let me know if you need any more support or customization! 😄
You can contact me directly in that case. 🙇