inspect_image
inspect_image
Parameters
file_path | |||
coordinate_space | |||
grid | |||
crop | |||
probes | |||
theme | "auto""light""dark""auto" | ||
sample_pixels |
Coordinate space
coordinate_space(0, 0)
viewbox | xywidthheightwidthheight | ||
pad | toprightbottomleftpadding |
padviewbox(image_width + pad.left + pad.right) x (image_height + pad.top + pad.bottom)(pad.left, pad.top)
viewboxpadimage_width_in_active = viewbox.width - pad.left - pad.right
Grid overlay
grid
x_divisions | spacing | ||
y_divisions | spacing | ||
spacing | x_divisionsy_divisions | ||
show_labels |
x_divisions: 10
spacing: 50
Crop
crop
x | |||
y | |||
width | |||
height | |||
zoom |
Probes
probes
x | |||
y | |||
id | |||
label | |||
color | "#ff0000" |
"in_canvas": false
Output
dimensions— source image pixel dimensions ( width, height). Always present. coordinate_space— the active coordinate space: type( "image"or "viewbox"), origin, size, and when using a viewbox, padand image_region. Always present. grid— grid configuration as applied: division or spacing values plus x_valuesand y_valuesarrays. Present when grid mode is active. crop— crop region and zoom factor. Present when crop mode is active. probes— per-probe results: id, x, y, in_image, in_canvas, and optionally pixel(hex color when sample_pixelsis true and in_imageis true). Present when probes are provided.
Mode composition
crop + grid — zoom into a region and read precise coordinates from grid labels crop + probe — verify fine placement within a zoomed region grid + probe — coarse verification on the full image crop + grid + probe — all three together for the most detailed inspection
Typical workflow
Grid — get the lay of the land inspect_image(file_path: "figure.png", grid: {x_divisions: 10, y_divisions: 10})Crop + grid — zoom into the region of interest inspect_image( file_path: "figure.png", crop: {x: 80, y: 100, width: 140, height: 100}, grid: {x_divisions: 5, y_divisions: 5} )Probe — verify candidate coordinates inspect_image( file_path: "figure.png", probes: [{id: "tip", x: 112, y: 160}, {id: "base", x: 185, y: 118}] )Author the SVG overlay using validated coordinates snap— verify the final rendered result once
snap
ViewBox workflow
Grid with coordinate space — labels match the overlay's viewBox inspect_image( file_path: "figure.png", coordinate_space: {pad: {top: 0, right: 220, bottom: 0, left: 0}}, grid: {x_divisions: 10, y_divisions: 10} )Probe in padding area — verify a callout label lands in the right spot inspect_image( file_path: "figure.png", coordinate_space: {pad: {top: 0, right: 220, bottom: 0, left: 0}}, probes: [{id: "label", x: 560, y: 80}] )
Pixel sampling
sample_pixels: truein_image: truepixel"#rrggbb"pixel
inspect_image(
file_path: "figure.png",
probes: [{id: "bg", x: 10, y: 10}, {id: "feature", x: 250, y: 375}],
sample_pixels: true
)Practical tips
Grid-first workflow : start with a coarse grid to identify regions, then crop + finer grid to read precise coordinates, then probes to verify before authoring markup. Use coordinate space for SVG overlays : when annotating figures with Stencila's SVG overlay system, pass the same viewboxand padvalues so grid labels and probe coordinates match the overlay coordinate system directly. Auto theme handles most cases : the "auto"theme analyzes image luminance and chooses contrasting grid/label colors. Use "light"or "dark"only if auto-detection picks poorly for a specific image. Crop regions preserve source coordinates : labels on cropped output show active-coordinate-space values, not crop-local values — coordinates read from a cropped view can be used directly in overlay markup. Probes are cheaper than snap : verifying coordinates with inspect_imageprobes is much faster than a full snapround-trip through the browser. Reserve snapfor final rendered verification. Spacing-based grids for regular intervals : use spacingwhen you want grid lines at round-number intervals (e.g. every 50 units). Use x_divisions/ y_divisionswhen you want a fixed number of divisions regardless of canvas size. Supported formats : PNG, JPEG, GIF (first frame only), and TIFF. SVG source images are not supported.