danielgtaylor / jpeg-archive

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

jpeg-recompress segmentation faults on this image #99

Open biltongza opened 6 years ago

biltongza commented 6 years ago

I use the Lightroom plugin from https://github.com/ftischhauser/JPEGOptimizer/ which uses jpeg-recompress. As part of my export process I have jpeg recompression enabled, and it is failing reliably on one of my images.

This is the commandline:

jpeg-recompress.exe  --accurate --method smallfry --quality medium --strip --subsample disable --ppm <input> <output>

The input is getting piped from Image Magick in PPM format, but I ran that separately and stored its output in a file which is here: https://drive.google.com/open?id=1-oLaNY4utIS4-sxOoZz5TlgsWL-Mmngv

The crash is happening here: https://github.com/danielgtaylor/jpeg-archive/blob/8da4bf76b6c3c0e11e4941294bfc1857c119419b/src/smallfry.c#L103

SSIM, MPE, and MS-SSIM all work fine with this image, it is just SmallFry that causes the crash it seems.

rsuzuki0 commented 5 years ago

I run a similar operation on Mac and observed the same problem since earlier version and with the current version. The problem only occurs with smallfry. The problem happens with maybe about one out of 20 images, exported from Lightroom.

jlebar commented 4 years ago

I think this is a dupe of #24.

I'm seeing if I can't figure it out to fix it, and if I can't, I will send a PR to add a warning to the docs about smallfry being broken.

biltongza commented 4 years ago

Yeah, it seems smallfry doesn't handle image dimensions that are not even. Even jpegmini crashed on it.

zvezdochiot commented 1 year ago

Hi all.

https://github.com/ImageProcessing-ElectronicPublications/jpeg-recompress version 2.5.5:

$ jpeg-recompress test.ppm test.ppm.jpg
Metadata size is 0kb
SUM at q=69 (40 - 98): UM 0.627327
SUM at q=84 (70 - 98): UM 0.776524
SUM at q=76 (70 - 83): UM 0.704028
SUM at q=80 (77 - 83): UM 0.730112
SUM at q=82 (81 - 83): UM 0.749563
Final optimized SUM at q=83: UM 0.765446
New size is 6% of original (saved 48629 kb)

$ webp-compress test.ppm test.ppm.webp
SUM at q=50 (1 - 99): UM 0.412953
SUM at q=75 (51 - 99): UM 0.473512
SUM at q=87 (76 - 99): UM 0.595191
SUM at q=93 (88 - 99): UM 0.724414
SUM at q=96 (94 - 99): UM 0.819576
SUM at q=94 (94 - 95): UM 0.770715
Final optimized SUM at q=94: UM 0.770715
New size is 3% of original (saved 49833 kb)

$ ls -l test.*
-rw-r--r-- 1 zvezdochiot zvezdochiot 53128877 дек 14 15:37 test.ppm
-rw-r--r-- 1 zvezdochiot zvezdochiot  3331959 дек 14 15:38 test.ppm.jpg
-rw-r--r-- 1 zvezdochiot zvezdochiot  2099122 дек 14 15:39 test.ppm.webp

No problems. :+1:

PS: SUM = (SSIM + SMALLFRY + SHBAD + NHW) / 4