diff options
author | Jesse Yurkovich <jesse.y@gmail.com> | 2022-07-30 09:17:41 +0300 |
---|---|---|
committer | Jesse Yurkovich <jesse.y@gmail.com> | 2022-07-30 09:17:41 +0300 |
commit | 8ae14bc1d74021bb1385c46fb637721b4d3dbb2d (patch) | |
tree | 1e7cb119f1bbbc6a78b013d6570b0da7f41e1b72 /source/blender | |
parent | cfd16c04f8316270b67c73775a5885d6bc4dc4e2 (diff) |
Fix 100035: Make UDIM detection less aggressive
There's been a handful of reports where "obviously" not a UDIM filenames
were detected as such during image open.[1]
This change makes the detection less aggressive by enforcing that the
4-digit sequence be delineated on both sides by one of the following 3
characters ., -, _
This fixes the problem for such filenames as:
"screenshot-1080p.png", "Image-1920x1080.png", "(1999) Photo.png", and
"antiguaChestnut_X_1240Wx814H.png"
[1] T97366 T98918 T99154 T100035
Differential Revision: https://developer.blender.org/D15573
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/image.cc | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/image_test.cc | 19 |
2 files changed, 17 insertions, 7 deletions
diff --git a/source/blender/blenkernel/intern/image.cc b/source/blender/blenkernel/intern/image.cc index c2b8ec95a46..ae5eead2547 100644 --- a/source/blender/blenkernel/intern/image.cc +++ b/source/blender/blenkernel/intern/image.cc @@ -3410,9 +3410,8 @@ void BKE_image_ensure_tile_token(char *filename) /* General 4-digit "udim" pattern. As this format is susceptible to ambiguity * with other digit sequences, we can leverage the supported range of roughly - * 1000 through 2000 to provide better detection. - */ - std::regex pattern(R"((^|.*?\D)([12]\d{3})(\D.*))"); + * 1000 through 2000 to provide better detection. */ + std::regex pattern(R"((.*[._-])([12]\d{3})([._-].*))"); if (std::regex_search(path, match, pattern)) { BLI_strncpy(filename, match.format("$1<UDIM>$3").c_str(), FILE_MAX); return; diff --git a/source/blender/blenkernel/intern/image_test.cc b/source/blender/blenkernel/intern/image_test.cc index 9c15fc62d21..7004d39c805 100644 --- a/source/blender/blenkernel/intern/image_test.cc +++ b/source/blender/blenkernel/intern/image_test.cc @@ -32,8 +32,12 @@ TEST(udim, image_ensure_tile_token) verify("test_1002_ao.png", "test_<UDIM>_ao.png"); verify("test.1002.ver0023.png", "test.<UDIM>.ver0023.png"); verify("test.ver0023.1002.png", "test.ver0023.<UDIM>.png"); - verify("1002test.png", "<UDIM>test.png"); - verify("test1002.png", "test<UDIM>.png"); + verify("test.1002.1.png", "test.<UDIM>.1.png"); + verify("test.1.1002.png", "test.1.<UDIM>.png"); + verify("test-2022-01-01.1002.png", "test-2022-01-01.<UDIM>.png"); + verify("1111_11.1002.png", "1111_11.<UDIM>.png"); + verify("2111_01.1002.png", "2111_01.<UDIM>.png"); + verify("2022_1002_100200.1002.png", "2022_1002_100200.<UDIM>.png"); /* UVTILE pattern detection. */ verify("uv-test.u2_v10.png", "uv-test.<UVTILE>.png"); @@ -44,8 +48,15 @@ TEST(udim, image_ensure_tile_token) verify("u2_v10uv-test.png", "<UVTILE>uv-test.png"); verify("u2_v10u_v-test.png", "<UVTILE>u_v-test.png"); - /* Incorrect patterns. */ - for (const char *incorrect : {"test.123.png", + /* Patterns which should not be detected as UDIMs. */ + for (const char *incorrect : {"1002.png", + "1002test.png", + "test1002.png", + "test(1002).png", + "(1002)test.png", + "test-1080p.png", + "test-1920x1080.png", + "test.123.png", "test.12345.png", "test.uv.png", "test.u1v.png", |