1#!/usr/bin/env python
2
3# location of oiio-images directory
4oiio_images = OIIO_TESTSUITE_IMAGEDIR
5
6# Just for simplicity, make a checkerboard with a solid alpha
7command += oiiotool (" --pattern checker 128x128 4 --ch R,G,B,=1.0"
8            + " -d uint8 -o " + oiio_relpath("checker.tif") )
9
10# Basic test - recreate the grid texture
11command += maketx_command (oiio_images + "/grid.tif", "grid.tx", showinfo=True)
12
13# Test --resize (to power of 2) with the grid, which is 1000x1000
14command += maketx_command (oiio_images + "/grid.tif", "grid-resize.tx",
15                           "--resize", showinfo=True)
16
17# Test -d to set output data type
18command += maketx_command ("checker.tif", "checker-uint16.tx",
19                           "-d uint16", showinfo=True)
20
21# Test --nchannels to restrict the number of channels
22command += maketx_command ("checker.tif", "checker-1chan.tx",
23                           "--nchannels 1", showinfo=True)
24
25# Test --tiles to set a non-default tile size
26command += maketx_command ("checker.tif", "checker-16x32tile.tx",
27                           "--tile 16 32", showinfo=True)
28
29# Test --separate and --compression
30command += maketx_command ("checker.tif", "checker-seplzw.tx",
31                           "--separate --compression lzw", showinfo=True)
32
33# Test --wrap
34command += maketx_command ("checker.tif", "checker-clamp.tx",
35                           "--wrap clamp", showinfo=True)
36
37# Test --swrap and --twrap
38command += maketx_command ("checker.tif", "checker-permir.tx",
39                           "--swrap periodic --twrap mirror", showinfo=True)
40
41# Test --nomipmap
42command += maketx_command ("checker.tif", "checker-nomip.tx",
43                           "--nomipmap", showinfo=True)
44
45# Test --Mcamera, --Mscreen
46command += maketx_command ("checker.tif", "checker-camera.tx",
47                           "--Mcamera 1 0 0 0 0 2 0 0 0 0 1 0 0 0 0 1 --Mscreen 3 0 0 0 0 3 0 0 0 0 3 0 1 2 3 1",
48                           showinfo=True)
49
50# Test --opaque-detect (should drop the alpha channel)
51command += maketx_command ("checker.tif", "checker-opaque.tx",
52                           "--opaque-detect", showinfo=True)
53
54# Test --monochrome-detect (first create a monochrome image)
55command += oiiotool (" --pattern constant:color=.25,.25,.25 256x256 3 "
56                    + " -d uint8 -o " + oiio_relpath("gray.tif"))
57command += maketx_command ("gray.tif", "gray-mono.tx",
58                           "--monochrome-detect", showinfo=True)
59
60# Test --monochrome-detect on something that is NOT monochrome
61command += oiiotool (" --pattern constant:color=.25,.2,.15 256x256 3 "
62                    + " -d uint8 -o " + oiio_relpath("pink.tif"))
63command += maketx_command ("pink.tif", "pink-mono.tx",
64                           "--monochrome-detect", showinfo=True)
65
66# Test --prman : should save 'separate' planarconfig, and funny 64x32 tiles
67# since we are specifying 16 bits, and it should save as 'int16' even though
68# we asked for unsigned.
69command += maketx_command ("checker.tif", "checker-prman.tx",
70                           "-d uint16 --prman", showinfo=True)
71
72# Test --fixnan : take advantage of the bad.exr images in
73# testsuite/oiiotool-fixnan.  (Use --nomipmap to cut down on stats output)
74# FIXME: would also like to test --checknan, but the problem with that is
75# that is actually FAILS if there's a nan.
76command += maketx_command (OIIO_TESTSUITE_ROOT+"/oiiotool-fixnan/src/bad.exr",
77                           "nan.exr", "--fixnan box3 --nomipmap",
78                           showinfo=True, showinfo_extra="--stats")
79
80# Test --format to force exr even though it can't be deduced from the name.
81command += maketx_command ("checker.tif", "checker-exr.pdq",
82                           "--format exr", showinfo=True)
83
84# Test that we cleanly replace any existing SHA-1 hash and ConstantColor
85# hint in the ImageDescription of the input file.
86command += oiiotool (" --pattern constant:color=1,0,0 64x64 3 "
87            + " --caption \"foo SHA-1=1234abcd ConstantColor=[0.0,0,-0.0] bar\""
88            + " -d uint8 -o " + oiio_relpath("small.tif") )
89command += info_command ("small.tif", safematch=1);
90command += maketx_command ("small.tif", "small.tx",
91                           "--oiio --constant-color-detect", showinfo=True)
92
93# Test that the oiio:SHA-1 hash is stable, and that that changing filter and
94# using -hicomp result in different images and different hashes.
95command += maketx_command (oiio_images + "/grid.tif", "grid-lanczos3.tx",
96                           extraargs = "-filter lanczos3")
97command += maketx_command (oiio_images + "/grid.tif", "grid-lanczos3-hicomp.tx",
98                           extraargs = "-filter lanczos3 -hicomp")
99command += info_command ("grid.tx",
100                         extraargs="--metamatch oiio:SHA-1")
101command += info_command ("grid-lanczos3.tx",
102                         extraargs="--metamatch oiio:SHA-1")
103command += info_command ("grid-lanczos3-hicomp.tx",
104                         extraargs="--metamatch oiio:SHA-1")
105
106# Regression test -- at one point, we had a bug where we were botching
107# the poles of OpenEXR env maps, adding energy.  Check it by creating an
108# all-white image, turning it into an env map, and calculating its
109# statistics (should be 1.0 everywhere).
110command += oiiotool (" --pattern constant:color=1,1,1 4x2 3 "
111            + " -d half -o " + oiio_relpath("white.exr"))
112command += maketx_command ("white.exr", "whiteenv.exr",
113                           "--envlatl")
114command += oiiotool ("--stats whiteenv.exr")
115
116#Test --bumpslopes to export a 6 channels height map with gradients
117command += oiiotool (" --pattern noise 64x64 1"
118           + " -d half -o " + oiio_relpath("bump.exr"))
119command += maketx_command ("bump.exr", "bumpslope.exr",
120                           "--bumpslopes -d half", showinfo=True)
121
122
123outputs = [ "out.txt" ]
124
125
126
127# To do:  --filter --checknan --fullpixels
128#         --prman-metadata --ignore-unassoc
129#         --mipimage
130#         --envlatl TIFF, --envlatl EXR
131#         --colorconvert --unpremult -u --fovcot
132