danielgtaylor / jpeg-archive

Utilities for archiving JPEGs for long term storage.
1.17k stars 121 forks source link

[bug] Binary search doesn't end after optimal quality setting is found #132

Open xiota opened 6 months ago

xiota commented 6 months ago

Using the package provided by Arch Linux, the early stop code doesn't work.

https://github.com/danielgtaylor/jpeg-archive/blob/5b56afa11872fc4b9f68c5a3dcf2ec5afe869504/jpeg-recompress.c#L441-L443

$ pacman -Si jpeg-archive | grep -E '^(Repository|Name|Version|URL|Build)'
Repository      : extra
Name            : jpeg-archive
Version         : 2.2.0-3
URL             : https://github.com/danielgtaylor/jpeg-archive/
Build Date      : Fri 04 Nov 2022 05:42:19 PM UTC

$ jpeg-recompress -V
2.2.0

$ jpeg-recompress -l 15 test1.jpg t1.jpg

Metadata size is 12kb
ssim at q=67 (40 - 95): 0.999363
ssim at q=81 (68 - 95): 0.999838
ssim at q=88 (82 - 95): 0.999934
ssim at q=84 (82 - 87): 0.999897
ssim at q=86 (85 - 87): 0.999932
ssim at q=85 (85 - 85): 0.999898
ssim at q=85 (85 - 85): 0.999898
ssim at q=85 (85 - 85): 0.999898
ssim at q=85 (85 - 85): 0.999898
ssim at q=85 (85 - 85): 0.999898
ssim at q=85 (85 - 85): 0.999898
ssim at q=85 (85 - 85): 0.999898
ssim at q=85 (85 - 85): 0.999898
ssim at q=85 (85 - 85): 0.999898
Final optimized ssim at q=85: 0.999809
New size is 8% of original (saved 9460 kb)

$ jpeg-recompress -l 15 test2.jpg t2.jpg

Metadata size is 0kb
ssim at q=67 (40 - 95): 0.999380
ssim at q=81 (68 - 95): 0.999844
ssim at q=88 (82 - 95): 0.999935
ssim at q=84 (82 - 87): 0.999899
ssim at q=86 (85 - 87): 0.999933
ssim at q=85 (85 - 85): 0.999900
ssim at q=85 (85 - 85): 0.999900
ssim at q=85 (85 - 85): 0.999900
ssim at q=85 (85 - 85): 0.999900
ssim at q=85 (85 - 85): 0.999900
ssim at q=85 (85 - 85): 0.999900
ssim at q=85 (85 - 85): 0.999900
ssim at q=85 (85 - 85): 0.999900
ssim at q=85 (85 - 85): 0.999900
Final optimized ssim at q=85: 0.999818
New size is 7% of original (saved 12964 kb)

Also, what is the status of this project? I have found a few other bugs. Would pull requests with bug fixes actually be reviewed and accepted?