-
-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Referring to the issue in the README, saving the image as JPEG will inevitably apply some level of compression. So decoding the image to retrieve the exact pixel intensities of the original image may not be possible unless using lossless formats like PNG
However, I found a little parameter of PIL save subsampling while doing the JPEG compression which tries to maintain the pixel intensity, still incurring some loss but not as big as without this parameter.
Given codebase without subsampling
Original implementation: https://github.com/ternaus/base64ToImageConverters/blob/main/image2base64/converters.py
Line number: 12
format: 'JPEG', quality=100
im.save(buffered, format=image_format, quality=quality)
Mean difference of the assertion test: 125.74196689386562
With Subsampling parameter set to 0
im.save(buffered, format=image_format, quality=quality, subsampling=0)
Mean difference of the assertion test: 53.83414475819539
The visual as well as numerical difference in clear. JPEG will definitely lead to losses. But subsampling=0 can preserve more details.



