Using jpegtran to rotate progressive jpegs: invalid SOS parameter for sequential jpeg

1.8k views Asked by At

My app tries to rotate images based on exif data.

I keep getting requests about jpegtran complaining about ’invalid SOS parameter for sequential jpeg” and jhead aborting operation. Apparently this is not even a fatal warning, and many forums give instructions on how to ignore it?

Invalid SOS parameters for sequential JPEG

Any ideas on how to get jpegtran to completely ignore this warning and process the images anyway? I have an issue with sample images here https://github.com/savolai/JPEG-Autorotate/issues/1

I thought already to first convert the image to non-progressive using jpegtran, but it complains even then and refuses to do it. .\jpegtran.exe .\testimages\invalid-sos-parameters-progressive-jpeg\20180516_14530 8.jpg > .\testimages\invalid-sos-parameters-progressive-jpeg\nonprog.jpg

Does anyone know any other binaries or ways to get jpegtran.exe to ignore the error? Or do you know if mozjpeg jpegtran is more lax about this?

https://github.com/mozilla/mozjpeg/blob/master/BUILDING.md

1

There are 1 answers

2
user3344003 On BEST ANSWER

I suspect that the source of the problem is that the spectral selection fields in the SOS marker are set to zero. These fields are meaningless in sequential JPEG but the standard says the values should be set to 0 and 63. Some JPEG references one sees on the internet say these values are ignored. Probably some encoders do not set them.

You might want to run a JPEG dumping program on your images to see if your spectral selection values are set to zero and 63. If they are not, you can write a relatively simple filter program that copies the JPEG stream while changing the spectral selection values.

I expect that the JPEGTRAN source code is online. If I am correct that it is making this needless check, you could build your own version with this commented out.