Upload plugin: "sizeOptimization" parameter in the config of plugin doesn't correctly apply to thumbnails and breakpoints. #20163
Labels
issue: bug
Issue reporting a bug
severity: low
If the issue only affects a very niche base of users and an easily implemented workaround can solve
source: core:upload
Source is core/upload package
status: pending reproduction
Waiting for free time to reproduce the issue, or more information
Bug report
Required System information
Describe the bug
"sizeOptimization" parameter in the config of plugin doesn't correctly apply to thumbnails and breakpoints.
Expected behavior
"sizeOptimization" (in the config of plugin) parameter should affect only original image and for all other calls of sharp() we need to apply quality 100 if our source image is a new one after our optimizations.
at this moment the value of the sharp "quality" is always 80 for jpeg/webp/jp2/tiff (by default), 100 for png, 50 avif/heif for thumbnails and breakpoints.
so if you apply quality 80 by "sizeOptimization: true" for original image (jpeg) and after you apply quality 80 (by sharp defaults) for dependent images like thumbnails and breakpoints then the quality of the images will be little bit bad because you apply two optimizations (by 80) twice.
so if you will use "sizeOptimization: false" then your original image (jpeg) will be with quality 100, and dependents will be with quality 80.
I guess that will be good to apply optimization only to original image and for dependent images we need to set 100 quality in the sharp() calls.
Also I think we need to set up default settings of sharp for quality by different formats when we use "sizeOptimization".
Code snippets
releases/4.23.1:
There is optimization:
strapi/packages/core/upload/server/services/image-manipulation.js
Line 99 in 655449a
Default quality 80 is applied:
strapi/packages/core/upload/server/services/image-manipulation.js
Line 50 in 655449a
v5/main:
There is optimization:
strapi/packages/core/upload/server/src/services/image-manipulation.ts
Line 122 in 2d8197c
Default quality 80 is applied:
strapi/packages/core/upload/server/src/services/image-manipulation.ts
Line 67 in 2d8197c
The text was updated successfully, but these errors were encountered: