Skip to content

[New] Support saving images separately#252

Open
adombeck wants to merge 2 commits into
mainfrom
store-images-separately
Open

[New] Support saving images separately#252
adombeck wants to merge 2 commits into
mainfrom
store-images-separately

Conversation

@adombeck

@adombeck adombeck commented May 19, 2026

Copy link
Copy Markdown
Contributor

Description

The HTML log file can become very large and take a long time to load. This PR allows saving images separately and load them on demand.

log_image() can now save images separately and reference them by relative URL instead of embedding them as inline base64. This reduces the overall file sizes, because base64 is 33% larger than binary, and it keeps the HTML log small and lets the browser load images on demand rather than parsing megabytes of inline base64.

The feature is opt-in: set the Robot Framework variable ${YARF_IMAGE_DIR} to the directory where images should be saved. When the variable is not set, log_image() falls back to inline base64 embedding as before.

Documentation

The new ${YARF_IMAGE_DIR} variable is documented in the docstring of log_image().

Tests

We've been using this patch for some weeks/months now and didn't experience any issues. It reduces the size of the log.html file from > 100 MB to ~6 MB and allows it to be opened within a second instead of over 10 seconds.

Test cases were added.

@adombeck adombeck force-pushed the store-images-separately branch 7 times, most recently from cfcdf97 to 0c6a32a Compare May 21, 2026 13:55
log_image() can now save images separately and reference them by
relative URL instead of embedding them as inline base64. This reduces
the overall file sizes, because base64 is 33% larger than binary, and it
keeps the HTML log small and lets the browser load images on demand
rather than parsing megabytes of inline base64.

The feature is opt-in: set the Robot Framework variable
${YARF_IMAGE_DIR} to the directory where images should be saved.
When the variable is not set, log_image() falls back to inline base64
embedding as before.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds opt-in image file saving to log_image() in the Robot Framework image utility. When ${YARF_IMAGE_DIR} is set, images are saved as WebP files and referenced by relative URL (from ${OUTPUT_DIR}), keeping log.html small. When unset, behavior is unchanged (inline base64 WebP).

Changes:

  • New _get_images_dir() helper that reads ${YARF_IMAGE_DIR} via BuiltIn() and ensures the directory exists, handling RobotNotRunningError.
  • log_image() branches: save WebP to disk with a UUID filename and emit a relative <img src="..."> (relative to ${OUTPUT_DIR} when available, otherwise absolute), or fall back to the existing inline base64 path.
  • Unit tests for the new helper, the file-saving path (with and without ${OUTPUT_DIR}), and the base64 fallback path.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
yarf/rf_libraries/libraries/image/utils.py Adds _get_images_dir() and the file-saving branch in log_image().
yarf/rf_libraries/libraries/image/tests/test_utils.py Adds tests covering the new directory helper and both log_image branches.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@adombeck adombeck marked this pull request as ready for review May 28, 2026 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants