pub struct PictureImage {
pub mimetype: String,
pub width: u32,
pub height: u32,
pub data: Vec<u8>,
pub dpi: u32,
pub display_size: Option<[f32; 2]>,
}Expand description
An extracted picture’s raw encoded bytes plus its mimetype and pixel size —
the docling.rs analogue of docling-core’s ImageRef.
Fields§
§mimetype: Stringe.g. image/png, image/jpeg.
width: u32§height: u32§data: Vec<u8>The image file bytes, exactly as embedded (PNG/JPEG/…).
dpi: u32Pixels per inch of the image relative to the page it came from —
docling-core’s ImageRef.dpi, which consumers use to map pixels back
to points. A crop rendered from a PDF page at s px/pt is 72·s
(docling: int(72 * images_scale), #519); an image embedded in an
office file has no render scale and keeps docling’s 72
(Self::DEFAULT_DPI).
display_size: Option<[f32; 2]>The size the picture is displayed at in its document, in inches
([width, height], #834): a DOCX drawing’s wp:extent, an ODT
frame’s svg:width / svg:height — not the bitmap’s pixel size
above, which docling’s ImageRef.size carries. None when the
format has no such extent (a PDF crop, a standalone image). The
Pandoc export writes it as the Image’s width / height
attributes, as Pandoc’s own readers do; docling’s JSON has no field
for it, so the JSON export leaves it out.
Implementations§
Source§impl PictureImage
impl PictureImage
Sourcepub const DEFAULT_DPI: u32 = 72
pub const DEFAULT_DPI: u32 = 72
docling’s ImageRef default when no render scale applies.
Sourcepub fn dpi_for_scale(scale: f32) -> u32
pub fn dpi_for_scale(scale: f32) -> u32
The dpi of an image rendered at scale pixels per PDF point
(72·scale, rounded — int() would floor 143.99… to 143).