Guest User

Untitled

a guest
Jan 21st, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. # if you have iterm2 for osx (www.iterm2.com) this is a like print(...) for images in the console
  2.  
  3. import base64
  4. import cStringIO
  5. import numpngw
  6. import numpy as np
  7.  
  8. def show_image(a):
  9. if a.dtype != np.uint8:
  10. a = a.astype(np.uint8)
  11. png_array = cStringIO.StringIO()
  12. numpngw.write_png(png_array, a)
  13. encoded_png_array = base64.b64encode(png_array.getvalue())
  14. png_array.close()
  15. image_seq = '\033]1337;File=[width=auto;height=auto;inline=1]:'+encoded_png_array+'\007'
  16. print(image_seq)
Add Comment
Please, Sign In to add comment