markdown.renderer.utils.image_layout

markdown.renderer.utils

image_layout(tss, width, class_attr, img_w, img_h, cell_w, cell_h) -> cols, pad_str, rows

Compute display layout for an inline PNG image

Resolves an image's display width in columns from its size class (small/medium in class_attr, else the default w), reading values from the image TSS object: fractions (<1) of the content width or absolute columns. When the terminal cell pixel width is known, the result is capped at the image's natural size so small images are never upscaled. Returns the column count, the left padding string that centers the image, and the estimated row count (true cell aspect ratio when both cell dimensions are known, 2:1 otherwise).