Tests: Add tests for image format saving and loading #104442

Closed
Jesse Yurkovich wants to merge 6 commits from deadpin:image-tests into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.

This adds saving and loading tests for our supported image formats.

Saving - bf_imbuf_save.py
There are 2 template images which are loaded anew for each file save
attempt. One is an 8-bit RGBA image and the other 32-bit. This is
required as many formats use a variety of factors to determine which of
ibuf->rect or ibuf->rectfloat to use for processing. The templates
are constructed to have alpha transparency as well as values > 1 (or
clamped to 1 for the case of the 8-bit template).

Test flow:

  • Load in an appropriate template image
  • Save it to the desired format with the desired set of options
  • Compare against the reference image

Notes:

  • 98 references are used totaling ~3.6MB
  • 10-12 second test runtime
  • Templates can be reconstructed with the create-templates.blend file

Loading - bf_imbuf_load.py
Test flow:

  • Load in each of the reference images
  • Save them back out as .exr
  • Save additional metadata to a secondary file (alpha mode, colorspace etc)
  • Compare the saved out .exr with another set of reference .exrs
  • Compare the save out file metadata with set of reference metadata

Notes:

  • 98 exr references are used totaling ~10MB
  • 10-12 second test runtime as well

A HTML report is not implemented. The diff output organization is very
similar to the other tests so it should be somewhat easy to do in the
future if we want.

The standard set of environment variables are implemented for both:
BLENDER_TEST_UPDATE, BLENDER_VERBOSE, and BLENDER_TEST_COLOR

Test files
The SVN test files are attached.


There's a variety of images which are probably "incorrect" with current master.
Their reference comparisons will pass, so the tests won't fail, but they look incorrect in Blender or other software.
I believe most/all of these images will be corrected once OIIO is used for saving/loading.

In the provided SVN zip file, check the following for some examples:
reference/png-bw-16-25__from__rgba32.png --> color shift compared to other BW variants
reference/dpx-rgb-08-false__from__rgba08.dpx --> too dark
reference/dpx-*-true*.dpx --> broken alpha? (these have use_cineon_log = True)

This adds saving and loading tests for our supported image formats. **Saving - bf_imbuf_save.py** There are 2 template images which are loaded anew for each file save attempt. One is an 8-bit RGBA image and the other 32-bit. This is required as many formats use a variety of factors to determine which of `ibuf->rect` or `ibuf->rectfloat` to use for processing. The templates are constructed to have alpha transparency as well as values > 1 (or clamped to 1 for the case of the 8-bit template). Test flow: - Load in an appropriate template image - Save it to the desired format with the desired set of options - Compare against the reference image Notes: - 98 references are used totaling ~3.6MB - 10-12 second test runtime - Templates can be reconstructed with the create-templates.blend file **Loading - bf_imbuf_load.py** Test flow: - Load in each of the reference images - Save them back out as .exr - Save additional metadata to a secondary file (alpha mode, colorspace etc) - Compare the saved out .exr with another set of reference .exrs - Compare the save out file metadata with set of reference metadata Notes: - 98 exr references are used totaling ~10MB - 10-12 second test runtime as well A HTML report is not implemented. The diff output organization is very similar to the other tests so it should be somewhat easy to do in the future if we want. The standard set of environment variables are implemented for both: BLENDER_TEST_UPDATE, BLENDER_VERBOSE, and BLENDER_TEST_COLOR **Test files** The SVN test files are attached. ---- There's a variety of images which are probably "incorrect" with current master. Their reference comparisons will pass, so the tests won't fail, but they look incorrect in Blender or other software. I believe most/all of these images will be corrected once OIIO is used for saving/loading. In the provided SVN zip file, check the following for some examples: `reference/png-bw-16-25__from__rgba32.png` --> color shift compared to other BW variants `reference/dpx-rgb-08-false__from__rgba08.dpx` --> too dark `reference/dpx-*-true*.dpx` --> broken alpha? (these have use_cineon_log = True)
Brecht Van Lommel requested review from Brecht Van Lommel 2023-02-08 13:07:51 +01:00
Brecht Van Lommel added this to the Core project 2023-02-08 13:07:58 +01:00
Brecht Van Lommel requested changes 2023-02-17 15:40:22 +01:00
Brecht Van Lommel left a comment
Owner

Looks fine overall, only minor nitpicks.

Looks fine overall, only minor nitpicks.
@ -0,0 +7,4 @@
import bpy
sys.path.append(os.path.dirname(os.path.realpath(__file__)))

We're trying to move away from os.path towards pathlib. I think removing the few usages in the new code in this patch is relatively straightforward.

We're trying to move away from os.path towards pathlib. I think removing the few usages in the new code in this patch is relatively straightforward.
deadpin marked this conversation as resolved
@ -0,0 +34,4 @@
actual_metadata = f"{channels=} {is_float=} {colorspace=} {alpha_mode=}"
# Save actual metadata
with open(out_metadata_path, "w+") as meta:

Can just be "w"?

Or better out_metadata_path.write_text(out_metadata_path) when using pathlib.

Can just be `"w"`? Or better `out_metadata_path.write_text(out_metadata_path)` when using `pathlib`.
deadpin marked this conversation as resolved
@ -0,0 +57,4 @@
if failed and self.update:
# Update reference metadata if requested.
with open(ref_metadata_path, "w+") as meta:

Same comment.

Same comment.
deadpin marked this conversation as resolved
@ -0,0 +9,4 @@
args = None
class COLORS_ANSI:

Can we deduplicate this colored printing code with other test modules?

Can we deduplicate this colored printing code with other test modules?
deadpin marked this conversation as resolved
Author
Member

Sorry, I rebased this branch before knowing the rule not to. The additional 4 commits that came in are organized
accordingly though.

Sorry, I rebased this branch before knowing the rule not to. The additional 4 commits that came in are organized accordingly though.

No problem, it's not a hard rule and I only edited the wiki page to recommend it a few days ago.

No problem, it's not a hard rule and I only edited the wiki page to recommend it a few days ago.
Brecht Van Lommel approved these changes 2023-02-20 09:02:04 +01:00
Author
Member

@blender-bot build

@blender-bot build
Author
Member

@blender-bot build

@blender-bot build
Jesse Yurkovich closed this pull request 2023-02-21 07:28:44 +01:00
Bastien Montagne removed this from the Core project 2023-07-03 12:45:46 +02:00
Some checks failed
buildbot/vexp-code-patch-coordinator Build done.

Pull request closed

Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#104442
No description provided.