Commit 5c66cf8
committed
feat(oiiotool): allow easy splitting of subimages by name (#4874)
Say you need to take a multi-part exr file and split it into separate
files for each part. (Note: what OpenEXR calls "parts", OIIO calls
"subimages.") You could do this
oiiotool multipart.exr --sisplit -o:all=1 "part.%04d.exr"
But this would name the parts part.0001.exr, part.0002.exr, etc. Maybe
you would prefer to split them into files that contain the subimage name
rather than just the inscrutible index number (which may also not be
consistent across files)? You could try this dance to loop over the
subimages and write each one with a name extracted from its metadata:
oiiotool multipart.exr --for i {TOP.SUBIMAGES} --dup --subimage {i} -o
"subimage_{TOP.'oiio:subimagename'}.exr
That works, but that's a little awkward and hard to remember off the top
of your head. Perhaps instead we would prefer a simpler version:
oiiotool multipart.exr --sisplit -o:all=1
"part.{TOP.'oiio:subimagename'}.exr"
This PR makes that last command work. It actually only required a small
change, which is that the function that handles the `-o` command needs
to defer the evaluation of the expression subsitution in the filename to
occur separately for each subimage being output, rather than just once
for the whole `-o:all=1` (which would have baked the FIRST subimage name
into all the output file names).
Docs are updated to give examples of how to do this.
Also fixed a silly typo in the test script.
Signed-off-by: Larry Gritz <[email protected]>1 parent 605504c commit 5c66cf8
File tree
4 files changed
+39
-12
lines changed- src
- doc
- oiiotool
- testsuite/oiiotool-subimage
- ref
4 files changed
+39
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
862 | 862 | | |
863 | 863 | | |
864 | 864 | | |
865 | | - | |
866 | | - | |
| 865 | + | |
| 866 | + | |
867 | 867 | | |
868 | | - | |
| 868 | + | |
869 | 869 | | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
870 | 876 | | |
871 | 877 | | |
872 | 878 | | |
| |||
1492 | 1498 | | |
1493 | 1499 | | |
1494 | 1500 | | |
1495 | | - | |
1496 | | - | |
1497 | | - | |
1498 | | - | |
1499 | | - | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
| 1505 | + | |
| 1506 | + | |
| 1507 | + | |
1500 | 1508 | | |
1501 | 1509 | | |
1502 | 1510 | | |
1503 | 1511 | | |
1504 | 1512 | | |
1505 | 1513 | | |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
1506 | 1520 | | |
1507 | 1521 | | |
1508 | 1522 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5555 | 5555 | | |
5556 | 5556 | | |
5557 | 5557 | | |
| 5558 | + | |
| 5559 | + | |
| 5560 | + | |
5558 | 5561 | | |
5559 | 5562 | | |
5560 | 5563 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
3 | 11 | | |
4 | 12 | | |
5 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
27 | 29 | | |
28 | 30 | | |
29 | | - | |
30 | | - | |
| 31 | + | |
| 32 | + | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
| |||
0 commit comments