pythonopencvpython-imaging-librarylibjpeg

Find which libjpeg is being used by PIL / PILLOW WINDOWS


I want to know which version of libjpeg is used with my version of Pillow 9.1.1 since converting the pillow image to numpy array and reading it with cv2 give me different results. The images look the same but have different values for certain pixels, and I already considered the fact that cv2 reads as BGR instead of RGB. But even after the color conversion the images continue to be different. Similar situation to this question Find which libjpeg is being used by PIL / PILLOW but I need to know the way of finding the version of libjpeg on Windows . Also, I am basing my idea that the libjpeg version is different from this issue https://stackoverflow.com/a/55096766/19284671 again, similar situation.


Solution

  • In this research paper, we described mismatches in libjpeg output and I can confirm, it is a mess. PIL and cv2 use libjpeg, but you can't rely on which libjpeg version is used.

    As a solution, you could actually be interested in my Python package jpeglib, an envelope over libjpeg. Importantly, you can choose, which libjpeg / libjpeg--turbo / mozjpeg version to use, in runtime of your Python code! There are wheels prebuilt for major platforms, so installation is swift.

    You can use it for JPEG compression/decompression, as well as working with DCT coefficients (not sure how deep in JPEG you are). Note that the package is still in beta, a production release is planned at late 2022.