Cover and images
// The cover: before the first section.
$book->cover('/path/to/cover.jpg', alt: '表紙');
// Illustrations: write once, place by putting the Image in a body.
$map = $book->image('/path/to/map.png', alt: '王都の地図');
$book->section('第三話', [' 地図を広げた。', $map, ' ここが王都だ。']);
Formats
JPEG, PNG, GIF and WebP. The format is judged from the file's leading bytes, not
its name. SVG is refused (ME-IMG-5001), because an SVG can carry script.
A file whose header is damaged is refused with ME-IMG-5002; one that cannot be
read at all with ME-SIO-3002.
The cover
cover() writes the image and a cover page that opens the book, and marks the
image as the cover so reading systems can show it on the shelf. The cover page keeps
the picture's proportions on any screen — portrait or landscape, it is never
cropped or stretched.
It must come before the first section(); see
Core concepts.
Illustrations
image()writes the file into the archive immediately, copying it in chunks — it is never loaded whole, so a large image costs no memory.- It returns an
Image. Put it in any later section body to place it there, as a block of its own, centred, scaled down to fit the page and never split across pages. - The same file given twice is stored once: you get the first
Imageback. - One
Imagecan be placed any number of times. - An
Imagebelongs to theDocumentthat made it; placing it in another throws aLogicException.
Alt text
alt: is what a screen reader says and what a reader shows when it cannot show
the picture. An empty alt marks the image as decorative. For a cover,
'表紙' or the title is enough.