Skip to content

write_jpeg builtin

write_jpeg(path, model, *, quality=95)

Writes a 2D BlockModel as a JPEG with a .jgw world file.

JPEG is lossy and 8-bit: values come back close to, not equal to, what was written, even at quality=100. Scale or classify data to 0-255 first.

Parameters:

Name Type Description Default
path str or Path

The .jpg file; the world file and sidecar go next to it.

required
model BlockModel

A regular grid with nz = 1, rotated by azimuth only, with one column (grayscale) or three (red, green, blue) of whole numbers from 0 to 255 and no nulls. A CRS goes to the SRS of a <path>.aux.xml sidecar, which is removed when the model has none.

required
quality int

JPEG quality from 1 to 100. Chroma is never subsampled.

95

Raises:

Type Description
InvalidInput

For nulls, masked, sub-blocked or 3D models, dip or rake rotations, values outside 0-255 or with a fraction, and other column counts.

Used in