import cv2
img_path = 'C:/Users/WZChan/Desktop/test_600x350.jpg'
color_img = cv2.imread(img_path)
print color_img.shape
gray_img = cv2.imread(img_path, cv2.IMREAD_GRAYSCALE)
print gray_img.shape
cv2.imwrite('C:/Users/WZChan/Desktop/test_grayscale.jpg', gray_img)
reload_grayscale = cv2.imread('C:/Users/WZChan/Desktop/test_grayscale.jpg')
print reload_grayscale
#IMWRITE_JEPG_QUALITY:0~100 DEFAULT:95
cv2.imwrite('C:/Users/WZChan/Desktop/test_600x350_imwrite.jpg', color_img, (cv2.IMWRITE_JPEG_QUALITY, 80))
#IMWRITE_PNG_COMPRESSION:0~9 DEFAULT:3
cv2.imwrite('C:/Users/WZChan/Desktop/test_600x350_imwrite.png', color_img, (cv2.IMWRITE_PNG_COMPRESSION, 5))
img_cv2.jpg
img_pyplot.jpg