optimizt icon indicating copy to clipboard operation
optimizt copied to clipboard

Add quality parameter

Open marcjoancr opened this issue 2 years ago • 3 comments

Add a parameter in order to set the quality the images after optimized.

Example: optimizt path/to/dir --quality=50.

marcjoancr avatar Jun 25 '22 16:06 marcjoancr

Hey @marcjoancr!

We thought about adding such a parameter, but it's kind of unclear how to do this. As you may see in the README, Optimizt uses a bunch of libs, each of them is for its own image format.

So, they have a different set of flags. Not all of them have quality available. Actually, it's JPEG & WebP thing. And I do not thing that quality levels of the JPEG encoder are equal to quality levels of the WebP encoder. So, such a param would be obscure.

If you have an idea how to implement it without making an API unclear, please share.

igoradamenko avatar Jun 25 '22 18:06 igoradamenko

I do not have any knowledge about image optimization and encoders, I do not understant the problem, why don't you make the quality encoder for JPEG different for the others if that's what is blocking the development of the solution?

I'll repeat, I do not really know a lot about encoders and optimization.

marcjoancr avatar Jun 25 '22 22:06 marcjoancr

🤔

You see, right know Optimizt allows you to pick a folder or a set of images and it will process them all, no matter what formats they have. But behind the scenes Optimizt picks the right encoder for each image, because this is how the image world works: if you want to process images properly, you choose the right tool for the each format you have.

Let's say you want to order a complex dish in a restaurant, like, omelet, grilled vegetables, toasted garlic bread and a cup of Turkish coffee. Sounds nice, right? But then you say to the waiter: “Oh! Add two pinches of salt, please”. The waiter goes to the cook, and, well, the cook is kind of confused. Should they add salt into all of the dishes? Or into the omelet only? Or maybe into the coffee?

That's exactly the problem we have here. We can't add a global quality flag, because Optimizt won't understand where and how to use it. We could probably go in one of the two ways:

  1. Add prefixed flags. E.g. --jpeg-quality, --webp-quality, etc.
  2. Let the user pass flags for each encoder in a hardly readable JSON-like format. E.g. --jpeg="{'quality': 10}".

Also we may try to mix them somehow 🤔

But there is no way to add one and only quality flag.

Will something like --jpeg-quality solve your problem?

igoradamenko avatar Jun 26 '22 09:06 igoradamenko