Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. def img_encode(img, format=".jpg"):
  2. new_img = img.convert('RGB')
  3. cv2_img = cv2.cvtColor(numpy.array(new_img), cv2.COLOR_RGB2BGR)
  4. r, b = cv2.imencode(format, cv2_img)
  5. if not r:
  6. raise Exception("unable to encode image")
  7. return b.tobytes()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement