ProCreations's picture
download
raw
696 Bytes
"""Wrap a PNG into a minimal self-contained HTML file (data-URI) for logbook figure cells."""
import base64
import sys
def main(png_path, html_path, alt):
with open(png_path, "rb") as f:
b64 = base64.b64encode(f.read()).decode()
html = (
"<!doctype html><meta charset='utf-8'>"
f"<body style='margin:0;background:#fcfcfb'>"
f"<img src='data:image/png;base64,{b64}' alt='{alt}' "
"style='max-width:100%;height:auto;display:block'></body>"
)
with open(html_path, "w") as f:
f.write(html)
print(f"wrote {html_path}")
if __name__ == "__main__":
main(sys.argv[1], sys.argv[2], sys.argv[3] if len(sys.argv) > 3 else "figure")

Xet Storage Details

Size:
696 Bytes
·
Xet hash:
ee36cf59931294ee0896ed5c8a7bd2ed3e832ffc4b89923c8652ba8911ab6853

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.