[New] Support saving images separately#252
Open
adombeck wants to merge 2 commits into
Open
Conversation
cfcdf97 to
0c6a32a
Compare
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.
0c6a32a to
32d9957
Compare
Contributor
There was a problem hiding this comment.
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}viaBuiltIn()and ensures the directory exists, handlingRobotNotRunningError. 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.