For the complete documentation index, see llms.txt. This page is also available as Markdown.

Insert local image

Embed a PNG or JPEG inside a cell. Use the path-based variant when the image lives on disk, or the buffer-based variant when the bytes are already in memory (uploads, S3, streamed data, …).

Function Prototype

insertImage(int $row, int $column, string $localImagePath, double $widthScale = 1.0, double $heightScale = 1.0): self

insertImageBuffer(int $row, int $column, string $bytes, ?array $options = null): self

int $row

cell row

int $column

cell column

string $localImagePath

Path to a PNG or JPEG file.

double $widthScale

Scale the image on the X axis; the default is 1, maintaining the original width; when the value is 0.5, the image width becomes 1/2 of the original.

double $heightScale

Scale the image on the Y axis; the default is 1, maintaining the original height; when the value is 0.5, the image height becomes 1/2 of the original.

string $bytes

Raw image bytes, e.g. the return value of file_get_contents() or a stream read.

array $options (optional, for insertImageBuffer)

All keys are optional:

  • x_offset int — horizontal pixel offset

  • y_offset int — vertical pixel offset

  • x_scale double — horizontal scale factor (default 1.0)

  • y_scale double — vertical scale factor (default 1.0)

  • object_position int — anchor mode (default 2)

  • url string — hyperlink the image points to

  • description string — accessibility / alt-text description

Example — path

Example — buffer

Last updated