diff --git a/src/doc/figures/orientation1.jpg b/src/doc/figures/orientation1.jpg new file mode 100644 index 0000000000..9606eafb7d Binary files /dev/null and b/src/doc/figures/orientation1.jpg differ diff --git a/src/doc/figures/orientation2.jpg b/src/doc/figures/orientation2.jpg new file mode 100644 index 0000000000..7015a0c511 Binary files /dev/null and b/src/doc/figures/orientation2.jpg differ diff --git a/src/doc/figures/orientation3.jpg b/src/doc/figures/orientation3.jpg new file mode 100644 index 0000000000..7b37dbc00e Binary files /dev/null and b/src/doc/figures/orientation3.jpg differ diff --git a/src/doc/figures/orientation4.jpg b/src/doc/figures/orientation4.jpg new file mode 100644 index 0000000000..49ec7b069f Binary files /dev/null and b/src/doc/figures/orientation4.jpg differ diff --git a/src/doc/figures/orientation5.jpg b/src/doc/figures/orientation5.jpg new file mode 100644 index 0000000000..cecff89a68 Binary files /dev/null and b/src/doc/figures/orientation5.jpg differ diff --git a/src/doc/figures/orientation6.jpg b/src/doc/figures/orientation6.jpg new file mode 100644 index 0000000000..017341568f Binary files /dev/null and b/src/doc/figures/orientation6.jpg differ diff --git a/src/doc/figures/orientation7.jpg b/src/doc/figures/orientation7.jpg new file mode 100644 index 0000000000..29e6f28c10 Binary files /dev/null and b/src/doc/figures/orientation7.jpg differ diff --git a/src/doc/figures/orientation8.jpg b/src/doc/figures/orientation8.jpg new file mode 100644 index 0000000000..c1f33fee4b Binary files /dev/null and b/src/doc/figures/orientation8.jpg differ diff --git a/src/doc/stdmetadata.rst b/src/doc/stdmetadata.rst index 17ea3e2a87..653a354671 100644 --- a/src/doc/stdmetadata.rst +++ b/src/doc/stdmetadata.rst @@ -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 @@ -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 diff --git a/src/libOpenImageIO/imagebufalgo_orient.cpp b/src/libOpenImageIO/imagebufalgo_orient.cpp index b4eec6e55c..f870eedf7d 100644 --- a/src/libOpenImageIO/imagebufalgo_orient.cpp +++ b/src/libOpenImageIO/imagebufalgo_orient.cpp @@ -363,7 +363,7 @@ 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 @@ -371,7 +371,7 @@ ImageBufAlgo::reorient(ImageBuf& dst, const ImageBuf& src, int nthreads) 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 diff --git a/testsuite/oiiotool-xform/ref/out.txt b/testsuite/oiiotool-xform/ref/out.txt index 985580eb9e..ec2b6f66b6 100644 --- a/testsuite/oiiotool-xform/ref/out.txt +++ b/testsuite/oiiotool-xform/ref/out.txt @@ -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" diff --git a/testsuite/oiiotool-xform/ref/reorient1.tif b/testsuite/oiiotool-xform/ref/reorient1.tif index 97099318b6..b0445a435d 100644 Binary files a/testsuite/oiiotool-xform/ref/reorient1.tif and b/testsuite/oiiotool-xform/ref/reorient1.tif differ diff --git a/testsuite/oiiotool-xform/ref/reorient2.tif b/testsuite/oiiotool-xform/ref/reorient2.tif index 4275ccb6cb..99036949dd 100644 Binary files a/testsuite/oiiotool-xform/ref/reorient2.tif and b/testsuite/oiiotool-xform/ref/reorient2.tif differ diff --git a/testsuite/oiiotool-xform/ref/reorient3.tif b/testsuite/oiiotool-xform/ref/reorient3.tif index 1dc5ff0f1f..7f0d0db47b 100644 Binary files a/testsuite/oiiotool-xform/ref/reorient3.tif and b/testsuite/oiiotool-xform/ref/reorient3.tif differ diff --git a/testsuite/oiiotool-xform/ref/reorient4.tif b/testsuite/oiiotool-xform/ref/reorient4.tif new file mode 100644 index 0000000000..9641f45ab7 Binary files /dev/null and b/testsuite/oiiotool-xform/ref/reorient4.tif differ diff --git a/testsuite/oiiotool-xform/ref/reorient5.tif b/testsuite/oiiotool-xform/ref/reorient5.tif new file mode 100644 index 0000000000..d9e1a97b86 Binary files /dev/null and b/testsuite/oiiotool-xform/ref/reorient5.tif differ diff --git a/testsuite/oiiotool-xform/ref/reorient6.tif b/testsuite/oiiotool-xform/ref/reorient6.tif new file mode 100644 index 0000000000..67cb4697d2 Binary files /dev/null and b/testsuite/oiiotool-xform/ref/reorient6.tif differ diff --git a/testsuite/oiiotool-xform/ref/reorient7.tif b/testsuite/oiiotool-xform/ref/reorient7.tif new file mode 100644 index 0000000000..3c734c016b Binary files /dev/null and b/testsuite/oiiotool-xform/ref/reorient7.tif differ diff --git a/testsuite/oiiotool-xform/ref/reorient8.tif b/testsuite/oiiotool-xform/ref/reorient8.tif new file mode 100644 index 0000000000..ea43e39324 Binary files /dev/null and b/testsuite/oiiotool-xform/ref/reorient8.tif differ diff --git a/testsuite/oiiotool-xform/run.py b/testsuite/oiiotool-xform/run.py index 19ed4d6fa7..f662e15462 100755 --- a/testsuite/oiiotool-xform/run.py +++ b/testsuite/oiiotool-xform/run.py @@ -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") @@ -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", "transpose.tif", "transpose-crop.tif", "cshift.tif", "out.txt" ] diff --git a/testsuite/oiiotool-xform/src/orientation1.tif b/testsuite/oiiotool-xform/src/orientation1.tif new file mode 100644 index 0000000000..92ebe00afb Binary files /dev/null and b/testsuite/oiiotool-xform/src/orientation1.tif differ diff --git a/testsuite/python-imagebufalgo/ref/out.txt b/testsuite/python-imagebufalgo/ref/out.txt index 98649f588a..2dc005bf9b 100644 --- a/testsuite/python-imagebufalgo/ref/out.txt +++ b/testsuite/python-imagebufalgo/ref/out.txt @@ -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 diff --git a/testsuite/python-imagebufalgo/run.py b/testsuite/python-imagebufalgo/run.py index 086e1c7b2b..bd031695ab 100755 --- a/testsuite/python-imagebufalgo/run.py +++ b/testsuite/python-imagebufalgo/run.py @@ -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", diff --git a/testsuite/python-imagebufalgo/src/test_imagebufalgo.py b/testsuite/python-imagebufalgo/src/test_imagebufalgo.py index 2210c94f16..c9af155c65 100755 --- a/testsuite/python-imagebufalgo/src/test_imagebufalgo.py +++ b/testsuite/python-imagebufalgo/src/test_imagebufalgo.py @@ -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"))