algoo / preview-generator

generates previews of files with cache management
https://pypi.org/project/preview-generator/
MIT License
224 stars 49 forks source link

Feat: Does it support adjusting the quality of the generated image? #269

Open a523 opened 2 years ago

a523 commented 2 years ago

Feature description and goals

We have a requirement to generate preview images for mobile use. By default , the user accesses a low quality compressed image, until he click the ’raw image‘ button. So, I want to use the project not only to generate preview images but also to generate the compressed images, If the raw file is a image. This way, I don't have to look for additional compressed libraries, because I think they should have almost the same dependencies, and I want to put them in the one project of mine. That mean is I don't want to change the width and height of the image, but I want to change the quality (file size) of it

Prerequisites

raphj commented 2 years ago

Hello @a523, thank you for your feature request. Seems like it would be a useful thing to have.

@inkhey it seems like we could add a quality parameter to PreviewManager.get_jpeg_preview, what do you think?

You'd still need to pass the correct width and height though.

inkhey commented 2 years ago

it's a good idea, but depending on the builder behind the parameter may have different meaning.

According to the current pillow builder, there is already few parameters that make sense for jpeg:

and maybe:

https://github.com/algoo/preview-generator/blob/ee5b0ee2dc4f972a517dc15f5b1e250648d2f777/preview_generator/preview/builder/image__pillow.py#L14-L28