Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added src/doc/figures/orientation1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/doc/figures/orientation2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/doc/figures/orientation3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/doc/figures/orientation4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/doc/figures/orientation5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/doc/figures/orientation6.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/doc/figures/orientation7.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/doc/figures/orientation8.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 26 additions & 10 deletions src/doc/stdmetadata.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,22 @@ Description of the image
Display hints
=============

.. |orient1img| image:: figures/orientation1.jpg
:height: 1 in
.. |orient2img| image:: figures/orientation2.jpg
:height: 1 in
.. |orient3img| image:: figures/orientation3.jpg
:height: 1 in
.. |orient4img| image:: figures/orientation4.jpg
:height: 1 in
.. |orient5img| image:: figures/orientation5.jpg
:width: 1 in
.. |orient6img| image:: figures/orientation6.jpg
:width: 1 in
.. |orient7img| image:: figures/orientation7.jpg
:width: 1 in
.. |orient8img| image:: figures/orientation8.jpg
:width: 1 in

.. option:: "Orientation" : int

Expand All @@ -83,16 +99,16 @@ Display hints
`"Orientation"` field can suggest that it should be displayed with
a different orientation, according to the TIFF/EXIF conventions:

=== ==========================================================================
1 normal (top to bottom, left to right)
2 flipped horizontally (top to bottom, right to left)
3 rotated :math:`180^\circ` (bottom to top, right to left)
4 flipped vertically (bottom to top, left to right)
5 transposed (left to right, top to bottom)
6 rotated :math:`90^\circ` clockwise (right to left, top to bottom)
7 transverse (right to left, bottom to top)
8 rotated :math:`90^\circ` counter-clockwise (left to right, bottom to top)
=== ==========================================================================
=== ============ ==========================================================================
1 |orient1img| normal (top to bottom, left to right)
2 |orient2img| flipped horizontally (top to bottom, right to left)
3 |orient3img| rotated :math:`180^\circ` (bottom to top, right to left)
4 |orient4img| flipped vertically (bottom to top, left to right)
5 |orient5img| transposed (left to right, top to bottom)
6 |orient6img| rotated :math:`90^\circ` clockwise (right to left, top to bottom)
7 |orient7img| transverse (right to left, bottom to top)
8 |orient8img| rotated :math:`90^\circ` counter-clockwise (left to right, bottom to top)
=== ============ ==========================================================================

.. option:: "PixelAspectRatio" : float

Expand Down
4 changes: 2 additions & 2 deletions src/libOpenImageIO/imagebufalgo_orient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,15 +363,15 @@ ImageBufAlgo::reorient(ImageBuf& dst, const ImageBuf& src, int nthreads)
case 3: ok = ImageBufAlgo::rotate180(dst, src, ROI(), nthreads); break;
case 4: ok = ImageBufAlgo::flip(dst, src, ROI(), nthreads); break;
case 5:
ok = ImageBufAlgo::rotate270(tmp, src, ROI(), nthreads);
ok = ImageBufAlgo::rotate90(tmp, src, ROI(), nthreads);
if (ok)
ok = ImageBufAlgo::flop(dst, tmp, ROI(), nthreads);
else
dst.errorfmt("{}", tmp.geterror());
break;
case 6: ok = ImageBufAlgo::rotate90(dst, src, ROI(), nthreads); break;
case 7:
ok = ImageBufAlgo::flip(tmp, src, ROI(), nthreads);
ok = ImageBufAlgo::flop(tmp, src, ROI(), nthreads);
if (ok)
ok = ImageBufAlgo::rotate90(dst, tmp, ROI(), nthreads);
else
Expand Down
10 changes: 10 additions & 0 deletions testsuite/oiiotool-xform/ref/out.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@ Comparing "reorient2.tif" and "ref/reorient2.tif"
PASS
Comparing "reorient3.tif" and "ref/reorient3.tif"
PASS
Comparing "reorient4.tif" and "ref/reorient4.tif"
PASS
Comparing "reorient5.tif" and "ref/reorient5.tif"
PASS
Comparing "reorient6.tif" and "ref/reorient6.tif"
PASS
Comparing "reorient7.tif" and "ref/reorient7.tif"
PASS
Comparing "reorient8.tif" and "ref/reorient8.tif"
PASS
Comparing "transpose.tif" and "ref/transpose.tif"
PASS
Comparing "transpose-crop.tif" and "ref/transpose-crop.tif"
Expand Down
Binary file modified testsuite/oiiotool-xform/ref/reorient1.tif
Binary file not shown.
Binary file modified testsuite/oiiotool-xform/ref/reorient2.tif
Binary file not shown.
Binary file modified testsuite/oiiotool-xform/ref/reorient3.tif
Binary file not shown.
Binary file added testsuite/oiiotool-xform/ref/reorient4.tif
Binary file not shown.
Binary file added testsuite/oiiotool-xform/ref/reorient5.tif
Binary file not shown.
Binary file added testsuite/oiiotool-xform/ref/reorient6.tif
Binary file not shown.
Binary file added testsuite/oiiotool-xform/ref/reorient7.tif
Binary file not shown.
Binary file added testsuite/oiiotool-xform/ref/reorient8.tif
Binary file not shown.
18 changes: 11 additions & 7 deletions testsuite/oiiotool-xform/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,15 @@ def make_test_pattern1 (filename, xres=288, yres=216) :
command += oiiotool ("image.tif --rotate180 -o flipflop.tif")
command += oiiotool ("image.tif --crop 160x120+30+30 --rotate180 -o flipflop-crop.tif")

# Tricky: make image, rotate, set Orientation, and then re-orient.
# Make it half size so it can't accidentally match to another test image
# for the rotation tests.
command += oiiotool ("image.tif --resample 160x120 --rotate90 --orientccw --reorient -o reorient1.tif")
command += oiiotool ("image.tif --resample 160x120 --rotate180 --orient180 --reorient -o reorient2.tif")
command += oiiotool ("image.tif --resample 160x120 --rotate270 --orientcw --reorient -o reorient3.tif")
# test reorient
command += oiiotool ("src/orientation1.tif --reorient -o reorient1.tif")
command += oiiotool ("src/orientation1.tif --orientation 2 --reorient -o reorient2.tif")
command += oiiotool ("src/orientation1.tif --orientation 3 --reorient -o reorient3.tif")
command += oiiotool ("src/orientation1.tif --orientation 4 --reorient -o reorient4.tif")
command += oiiotool ("src/orientation1.tif --orientation 5 --reorient -o reorient5.tif")
command += oiiotool ("src/orientation1.tif --orientation 6 --reorient -o reorient6.tif")
command += oiiotool ("src/orientation1.tif --orientation 7 --reorient -o reorient7.tif")
command += oiiotool ("src/orientation1.tif --orientation 8 --reorient -o reorient8.tif")

# test transpose
command += oiiotool ("image.tif --transpose -o transpose.tif")
Expand Down Expand Up @@ -164,7 +167,8 @@ def make_test_pattern1 (filename, xres=288, yres=216) :
"flipflop.tif", "flipflop-crop.tif",
"rotate90.tif", "rotate90-crop.tif",
"rotate270.tif", "rotate270-crop.tif",
"reorient1.tif", "reorient2.tif", "reorient3.tif",
"reorient1.tif", "reorient2.tif", "reorient3.tif", "reorient4.tif",
"reorient5.tif", "reorient6.tif", "reorient7.tif", "reorient8.tif",
Comment on lines +170 to +171

@lgritz lgritz Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm slightly worried about the ways this can fail, since in order to support multiple references when they differ per-platform, we consider a test to pass if an output we are checking matches any of the reference images. So if orientation 2 were to break and started making the image that should be orientation 4 instead, I think this would still pass?

Here is an idea, what do you think?

After you make the reorient?.tif images, assemble them into one big image using oiiotool --mosaic, and compare THAT (not the individual reoriented images) to a reference image. Then any individual reorient images being wrong will certainly be a failure and can't pass by coincidentally matching a different reorientation.

"transpose.tif", "transpose-crop.tif",
"cshift.tif",
"out.txt" ]
Expand Down
Binary file added testsuite/oiiotool-xform/src/orientation1.tif
Binary file not shown.
2 changes: 1 addition & 1 deletion testsuite/python-imagebufalgo/ref/out.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Comparing "flip.tif" and "../../../testsuite/oiiotool-xform/ref/flip.tif"
PASS
Comparing "flop.tif" and "../../../testsuite/oiiotool-xform/ref/flop.tif"
PASS
Comparing "reorient1.tif" and "../../../testsuite/oiiotool-xform/ref/reorient1.tif"
Comparing "reorient8.tif" and "../../../testsuite/oiiotool-xform/ref/reorient8.tif"
PASS
Comparing "transpose.tif" and "../../../testsuite/oiiotool-xform/ref/transpose.tif"
PASS
Expand Down
2 changes: 1 addition & 1 deletion testsuite/python-imagebufalgo/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"rotate90.tif", "rotate180.tif", "rotate270.tif",
"rotated.tif", "rotated-offcenter.tif",
"warped.tif",
"flip.tif", "flop.tif", "reorient1.tif",
"flip.tif", "flop.tif", "reorient8.tif",
"transpose.tif",
"cshift.tif", "cadd1.exr", "cadd2.exr", "add.exr",
"sub.exr", "csub2.exr",
Expand Down
11 changes: 4 additions & 7 deletions testsuite/python-imagebufalgo/src/test_imagebufalgo.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,10 @@ def test_iba (func: Callable[..., oiio.ImageBuf], *args, **kwargs) -> oiio.Image
write (b, "flop.tif")

# reorient
image_small = ImageBuf()
ImageBufAlgo.resample (image_small, ImageBuf(OIIO_TESTSUITE_ROOT+"/oiiotool/src/image.tif"), roi=oiio.ROI(0,160,0,120))
image_small = ImageBufAlgo.rotate90 (image_small)
image_small.specmod().attribute ("Orientation", 8)
b = test_iba (ImageBufAlgo.reorient, image_small)
write (b, "reorient1.tif")
image_small = ImageBuf()
orient1 = ImageBuf(OIIO_TESTSUITE_ROOT + "/oiiotool-xform/src/orientation1.tif")
orient1.specmod().attribute ("Orientation", 8)
b = test_iba (ImageBufAlgo.reorient, orient1)
write (b, "reorient8.tif")

# transpose
b = test_iba (ImageBufAlgo.transpose, ImageBuf(OIIO_TESTSUITE_ROOT+"/oiiotool/src/image.tif"))
Expand Down
Loading