Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def img_encode(img, format=".jpg"):
- new_img = img.convert('RGB')
- cv2_img = cv2.cvtColor(numpy.array(new_img), cv2.COLOR_RGB2BGR)
- r, b = cv2.imencode(format, cv2_img)
- if not r:
- raise Exception("unable to encode image")
- return b.tobytes()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement