I have a big issue trying to convert a large scientific image (7 Mb) 16bit PNG image to JPG in order to compress it and check for any eventual artifact in Python. The original image can be found at: https://postimg.cc/p5PQG8ry Reading other answers here I have tried Pillow and OpenCV without any success the only thing I obtain is a white sheet. What I'm doing wrong? The commented line was an attempt from Read 16-bit PNG image file using Python but seems not working for me generating a data type error.
import numpy as np
from PIL import Image
import cv2
image = cv2.imread('terzafoto.png', -cv2.IMREAD_ANYDEPTH)
cv2.imwrite('terza.jpg', image)
im = Image.open('terzafoto.png').convert('RGB')
im.save('terzafoto.jpg', format='JPEG', quality=100)
#im = Image.fromarray(np.array(Image.open('terzafoto.jpg')).astype("uint16")).convert('RGB')