tjko / jpegoptim

jpegoptim - utility to optimize/compress JPEG files
http://www.iki.fi/tjko/projects.html
GNU General Public License v3.0
1.56k stars 116 forks source link

adding arithmetic coding support #60

Closed ianamk closed 2 years ago

ianamk commented 6 years ago

seeing how the arithmetic coding patent has ended and libjpeg-turbo and mozjepeg both support arithmetic coding how about a switch that replaces huffman with arithmetic coding I just tested a few arithmetic coded jpegs on win7 and while Firefox and IE didn't read them irfanview and xnview both decoded them properly as both Firefox and Chrome use libjpeg-turbo I expect future versions will support arithmeticly encoded images also jpegoptim could be a handy tool for lossless conversion of jpeg's from huffman to arithmetic and back

tjko commented 4 years ago

I added experimental support for this: 3717ac83434b9ae7d5d6697a1270cd566d9f8033

However, seems libjpeg-turbo isn't always compiled with support for arithmetic dogin. At leas on Debian this is evident:

# ./jpegoptim --all-arith test.jpg
test.jpg 95x135 24bit N JFIF  [OK]  [Compress ERROR: Requested feature was omitted at compile time]
ianamk commented 4 years ago

I just compiled it with mingw64 under windows with both libjpeg-turbo and mozjpeg and I am getting the same error I don't think this is a libjpeg issue as I tested cjpeg from mozjpeg I build and it did encode an arithmetic jpeg. I did cjpeg -arithmetic file.jpg >file2.jpg the output file was arithmetically encoded jpeg

tjko commented 2 years ago

Whether arithmetic coding works seems to depend on the libjpeg version. It seems to work fine with libjpeg9 on Debian/Raspian...