'Is there a way to match all pixel values between Pillow and cv2 (opencv-python) in Python?

Given a .jpg image file - "cat.jpg",

x1 = PIL.Image.open("cat.jpg")

x2 = cv2.imread("cat.jpg")

When x1 and x2 are converted to numpy array, the pixel values are not matched exactly. (though they are from a common image.)

Is there a way to match the pixel values in 100%?

For example, is there a way to reproduce the behavior of cv2 by using only Pillow?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source