Created
November 3, 2017 13:07
-
-
Save eruffaldi/106364fd0785376bde09ccd86bbd849e to your computer and use it in GitHub Desktop.
Python inline image with iterm2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import base64 | |
import sys | |
#https://www.iterm2.com/utilities/imgls | |
def encode_iterm2_image(data,height=None): | |
if height is None: | |
height = "auto" | |
else: | |
height = "%spx" % height | |
return ("\x1B]1337;File=loss.jpg;width=auto;height=%s;inline=1;size=%dpreserveAspectRatio=1:" % (height,len(data))) + base64.b64encode(data) | |
print encode_iterm2_image(open(sys.argv[1],"rb").read(),100) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment