python OpenCV jpeg compression in memory

You can use imencode:

encode_param = [int(cv2.IMWRITE_JPEG_QUALITY), 90]
result, encimg = cv2.imencode('.jpg', img, encode_param)

(The default value for IMWRITE_JPEG_QUALITY is 95.)

You can decode it back with:

decimg = cv2.imdecode(encimg, 1)

Snippet from here

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)