I tried this code:
compression_params = [cv2.CV_IMWRITE_PNG_COMPRESSION, 9]
img = cv2.imread('img1.png', cv2.IMREAD_UNCHANGED)
cv2.imwrite('compress_img1.png', img, compression_params)
But I obtain this error:
AttributeError: module 'cv2' has no attribute 'CV_IMWRITE_PNG_COMPRESSION'
I'm working with python 3.5 and opencv 3.0