Skip to main content

Module image

Module image 

Source
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§

GraphicxOp
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. None for 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_pt over a comma-joined candidates string (the <ltx:graphics candidates=…> attribute), resolving each candidate against source_dir and 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 viewBox extent when there is one, else the root width/height lengths.
svg_attr_len_px
An SVG length attribute in CSS px. A unitless value is user units, i.e. px. None for 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 within head, quote-aware so a > inside an attribute value doesn’t end the tag early. Skipping to <svg also 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.pm L198-210), including its true-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’s else { return 1 } does.