March 2018
Beginner to intermediate
306 pages
9h 54m
English
Here are the steps for this recipe:
img = cv2.imread('../data/Lena.png')
# save image with lower compression—bigger file size but faster decodingcv2.imwrite('../data/Lena_compressed.png', img, [cv2.IMWRITE_PNG_COMPRESSION, 0])# check that image saved and loaded again image is the same as original onesaved_img = cv2.imread(params.out_png)assert saved_img.all() == img.all()
# save image with lower quality—smaller file sizecv2.imwrite('../data/Lena_compressed.jpg', img, [cv2.IMWRITE_JPEG_QUALITY, 0])