odc.geo.xr.compress

odc.geo.xr.compress(xx, /, *args, as_data_url=False, transparent=None, **kw)[source]

Save image to RAM in jpeg/png/webp format.

png_bytes = compress(xx)  # default is PNG
png_bytes = compress(xx, "png", 9) # compression settings

# - Make data url with JPEG quality of 85
# - Use black for transparent pixels (JPEG doesn't support transparency)
# - Result is an ASCII string
url = compress(xx, "jpeg", 85, as_data_url=True, transparent=(0,0,0))
Parameters:
  • xx – DataArray to compress

  • transparent (Optional[Tuple[int, int, int]]) – Pixel value to use for transparent pixels, useful for jpeg output.

Return type:

Union[str, bytes]