···11+open Js_of_ocaml
22+33+let to_data_url img =
44+ let png = Viz.png_of_rgba img in
55+ let b64 = Js.to_string (Js.Unsafe.global##btoa (Js.bytestring png)) in
66+ "data:image/png;base64," ^ b64
+8
tessera-viz-jsoo/lib/viz_jsoo.mli
···11+(** Browser display helpers for tessera-viz images.
22+33+ Converts RGBA images to base64-encoded PNG data URLs
44+ for display in OCaml notebook cells. *)
55+66+val to_data_url : Viz.rgba_image -> string
77+(** Convert an RGBA image to a [data:image/png;base64,...] URL.
88+ Suitable for use as an [<img>] src attribute. *)