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.

6 Commits

Author SHA1 Message Date
1318c60c75 Make sure the load test fails if it cannot find any files to test which is most likely a mistake.
Some checks failed
buildbot/vexp-code-patch-coordinator Build done.
2023-02-19 16:36:20 -08:00
22c8d548d5 Formatting with autopep8 2023-02-19 16:36:20 -08:00
a19dc3c8cb Feedback: Eliminate print_message duplication 2023-02-19 16:36:20 -08:00
6ecb3cbb2f Feedback: Take advantage of pathlib in more places 2023-02-19 16:36:20 -08:00
151e2b726a Re-enable CINEON now that we bumped the OIIO version 2023-02-19 16:36:20 -08:00
7c45daa405 Tests: Add tests for image format saving and loading
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

----
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)

Differential Revision: https://developer.blender.org/D16657
2023-02-19 16:36:20 -08:00