Expand description
image file helpers — port of LaTeXML::Util::Image
Image helpers — port of LaTeXML::Util::Image.
Perl counterpart: lib/LaTeXML/Util/Image.pm.
Provides filesystem search for image candidates, minimal header-based
image size detection (PNG / JPEG / EPS) and the graphicx sizer that
converts keyval option strings into box dimensions. The Rust port is
intentionally narrower than the Perl original — Image::Magick is not
used at all; LaTeXML::Post::Graphics carries out any heavy-duty image
operations in a post-processing pass.
Enums§
- Graphicx
Op - One graphicx transformation, as compiled from the option string.
Functions§
- apply_
graphicx_ ops - Apply a compiled transformation sequence to a natural size.
- image_
candidates - Perl:
image_candidates($path)(Util::Image L43-57). - image_
graphicx_ sizer - Perl:
image_graphicx_sizer($whatsit)(Util::Image L259-272). - natural_
display_ size_ pt - The figure’s TRUE natural (typeset) size in TeX pt, for the VECTOR formats
whose intrinsic size is a real physical dimension: a PDF page box, an EPS/PS
%%BoundingBox(both bp), or an SVG’s lengths/viewBox.Nonefor raster formats — a pixel count is not a physical size without a DPI — and when the geometry can’t be recovered. - natural_
display_ size_ pt_ of_ candidates natural_display_size_ptover a comma-joinedcandidatesstring (the<ltx:graphics candidates=…>attribute), resolving each candidate againstsource_dirand returning the first that yields a size.- parse_
bbox - Parse
"llx lly urx ury"from a BoundingBox comment body. - parse_
graphicx_ options - Compile a graphicx option string into the transformation sequence.
- read_
image_ dimensions - Read image dimensions (width, height) in pixels from a file. Supports PNG, JPEG, and EPS (PostScript BoundingBox).
- read_
pdf_ page_ box - Read a PDF’s page box (width, height) in bp — CropBox (pdfTeX’s default),
else MediaBox. Pure Rust, no external tool (this is what pdfTeX’s built-in
reader does). Shared with
LaTeXML::Post::Graphics. - read_
svg_ viewport_ px - SVG viewport size in CSS px, as a browser would take it: the
viewBoxextent when there is one, else the rootwidth/heightlengths. - svg_
attr_ len_ px - An SVG length attribute in CSS px. A unitless value is user units, i.e. px.
Nonefor anything that isn’t an absolute length (%,em,ex, …) — those are resolved against a viewport we don’t have, so the caller must fall back to the viewBox rather than treat the bare number as pixels. - svg_
attr_ value - Value of the
name="…"/name='…'attribute in an XML start tag. - svg_
root_ tag - The root
<svg …>start tag withinhead, quote-aware so a>inside an attribute value doesn’t end the tag early. Skipping to<svgalso steps over the<?xml …?>prolog, comments and any DOCTYPE — otherwise the prolog’s?>would be mistaken for the end of the start tag. - to_bp
- A TeX/graphicx length in bp. Port of Perl
to_bp+%BP_conversions(Util/Image.pmL198-210), including itstrue-prefix strip (truept) and its “unknown unit counts as bp” fallback. A value that is not a length at all yields 1, exactly as Perl’selse { return 1 }does.