1.. _chap-oiiotool: 2 3`oiiotool`: the OIIO Swiss Army Knife 4##################################### 5 6.. highlight:: bash 7 8.. |nbsp| unicode:: U+00A0 .. NO-BREAK SPACE 9 10.. |spc| replace:: |nbsp| |nbsp| |nbsp| 11 12 13 14Overview 15======== 16 17 18The :program:`oiiotool` program will read images (from any file format for 19which an ImageInput plugin can be found), perform various operations on 20them, and write images (in any format for which an ImageOutput plugin can be 21found). 22 23The :program:`oiiotool` utility is invoked as follows: 24 25 `oiiotool` *args* 26 27:program:`oiiotool` maintains an *image stack*, with the top image in the 28stack also called the *current image*. The stack begins containing no 29images. 30 31:program:`oiiotool` arguments consist of image names, or commands. When an 32image name is encountered, that image is pushed on the stack and becomes the 33new *current image*. 34 35Most other commands either alter the current image (replacing it with the 36alteration), or in some cases will pull more than one image off the stack 37(such as the current image and the next item on the stack) and then push a 38new result image onto the stack. 39 40Argument order matters! 41----------------------- 42 43:program:`oiiotool` processes operations *in order*. Thus, the order of 44operations on the command line is extremely important. For example, 45 46.. code-block:: 47 48 oiiotool in.tif -resize 640x480 -o out.tif 49 50has the effect of reading :file:`in.tif` (thus making it the *current 51image*), resizing it (taking the original off the stack, and placing the 52resized result back on the stack), and then writing the new current image to 53the file :file:`out.tif`. Contrast that with the following subtly-incorrect 54command:: 55 56 oiiotool in.tif -o out.tif -resize 640x480 57 58has the effect of reading :file:`in.tif` (thus making it the *current 59image*), saving the current image to the file :file:`out.tif` (note that it 60will be an exact copy of :file:`in.tif`), resizing the current image, and 61then... exiting. Thus, the resized image is never saved, and :file:`out.tif` 62will be an unaltered copy of :file:`in.tif`. 63 64Optional arguments 65----------------------- 66 67Some commands stand completely on their own (like `--flip`), others take one 68or more subsequuent command line arguments (like `--resize` or `-o`):: 69 70 oiiotool foo.jpg --flip --resize 640x480 -o out.tif 71 72 73A few commands take optional modifiers for options that are so rarely-used 74or confusing that they should not be required arguments. In these cases, 75they are appended to the command name, after a colon (`:`), and with a 76*name=value* format. Multiple optional modifiers can be chained together, 77with colon separators. As an example: 78 79.. code-block:: none 80 81 oiiotool in.tif --text:x=400:y=600:color=1,0,0 "Hello" -o out.tif 82 \____/\____/\____/\__________/ \____/ 83 | | | | | 84 command -------+ | | | +----- required argument 85 | | | 86 optional modifiers ---------+-----+--------+ 87 (separated by ':') 88 89 90Frame sequences 91----------------------- 92 93It is also possible to have :program:`oiiotool` operate on numbered 94sequences of images. In effect, this will execute the :program:`oiiotool` 95command several times, making substitutions to the sequence arguments in 96turn. 97 98Image sequences are specified by having filename arguments to oiiotool use 99either a numeric range wildcard (designated such as `1-10#` or a 100`printf`-like notation `1-10%d`), or spelling out a more complex pattern 101with `--frames`. For example:: 102 103 oiiotool big.1-3#.tif --resize 100x100 -o small.1-3#.tif 104 105 oiiotool big.1-3%04d.tif --resize 100x100 -o small.1-3%04d.tif 106 107 oiiotool --frames 1-3 big.#.tif --resize 100x100 -o small.#.tif 108 109 oiiotool --frames 1-3 big.%04d.tif --resize 100x100 -o small.%04d.tif 110 111Any of those will be the equivalent of having issued the following sequence 112of commands:: 113 114 oiiotool big.0001.tif --resize 100x100 -o small.0001.tif 115 oiiotool big.0002.tif --resize 100x100 -o small.0002.tif 116 oiiotool big.0003.tif --resize 100x100 -o small.0003.tif 117 118The frame range may be forwards (`1-5`) or backwards (`5-1`), and may give a 119step size to skip frames (`1-5x2` means 1, 3, 5) or take the complement of 120the step size set (`1-5y2` means 2, 4) and may combine subsequences with a 121comma. 122 123If you are using the `#` or `@` wildcards, then the wildcard characters 124themselves specify how many digits to pad with leading zeroes, with `#` 125indicating 4 digits and `@` indicating one digit (these may be combined: 126`#@@` means 6 digits). An optional `--framepadding` can also be used to 127override the number of padding digits. For example:: 128 129 oiiotool --framepadding 3 --frames 3,4,10-20x2 blah.#.tif 130 131would match `blah.003.tif`, `blah.004.tif`, `blah.010.tif`, `blah.012.tif`, 132`blah.014.tif`, `blah.016.tif`, `blah.018.tif`, `blah.020.tif`. 133 134Alternately, you can use the `printf` notation, such as:: 135 136 oiiotool --frames 3,4,10-20x2 blah.%03d.tif 137 138Two special command line arguments can be used to disable numeric wildcard 139expansion: `--wildcardoff` disables numeric wildcard expansion for 140subsequent command line arguments, until `--wildcardon` re-enables it for 141subsequent command line arguments. Turning wildcard expansion off for 142selected arguments can be helpful if you have arguments that must contain 143the wildcard characters themselves. For example:: 144 145 oiiotool input.@@@.tif --wildcardoff --sattrib Caption "lg@openimageio.org" \ 146 --wildcardon -o output.@@@.tif 147 148 149In this example, the `@` characters in the filenames should be expanded into 150numeric file sequence wildcards, but the `@` in the caption (denoting an 151email address) should not. 152 153Stereo wildcards 154----------------------- 155 156:program:`oiiotool` can also handle image sequences with separate left and 157right images per frame using `views`. The `%V` wildcard will match the full 158name of all views and `%v` will match the first character of each view. View 159names default to "left" and "right", but may be overridden using the 160`--views` option. For example:: 161 162 oiiotool --frames 1-5 blah_%V.#.tif 163 164would match `blah_left.0001.tif`, `blah_right.0001.tif`, 165`blah_left.0002.tif`, `blah_right.0002.tif`, `blah_left.0003.tif`, 166`blah_right.0003.tif`, `blah_left.0004.tif`, `blah_right.0004.tif`, 167`blah_left.0005.tif`, `blah_right.0005.tif`, and 168 169.. code-block:: 170 171 oiiotool --frames 1-5 blah_%v.#.tif 172 173would match `blah_l.0001.tif`, `blah_r.0001.tif`, `blah_l.0002.tif`, 174`blah_r.0002.tif`, `blah_l.0003.tif`, `blah_r.0003.tif`, `blah_l.0004.tif`, 175`blah_r.0004.tif`, `blah_l.0005.tif`, `blah_r.0005.tif`, but 176 177.. code-block:: 178 179 oiiotool --views left --frames 1-5 blah_%v.#.tif 180 181would only match `blah_l.0001.tif`, `blah_l.0002.tif`, `blah_l.0003.tif`, 182`blah_l.0004.tif`, `blah_l.0005.tif`. 183 184Expression evaluation and substitution 185---------------------------------------------- 186 187:program:`oiiotool` can perform *expression evaluation and substitution* on 188command-line arguments. As command-line arguments are needed, they are 189scanned for containing braces `{ }`. If found, the braces and any text they 190enclose will be evaluated as an expression and replaced by its result. The 191contents of an expression may be any of: 192 193* *number* 194 195 A numerical value (e.g., 1 or 3.14159). 196 197* *imagename.metadata* 198 199 The named metadata of an image. 200 201 The *imagename* may be one of: `TOP` (the top or current image), `IMG[i]` 202 describing the i-th image on the stack (thus `TOP` is a synonym for 203 `IMG[0]`, the next image on the stack is `IMG[1]`, etc.), or `IMG[name]` 204 to denote an image named by filename or by label name. Remember that the 205 positions on the stack (including `TOP`) refer to *at that moment*, with 206 successive commands changing the contents of the top image. 207 208 The *metadata* may be any of: 209 210 * the name of any standard metadata of the specified image (e.g., 211 `ImageDescription`, or `width`) 212 * `filename` : the name of the file (e.g., `foo.tif`) 213 * `file_extension` : the extension of the file (e.g., `tif`) 214 * `geom` : the pixel data size in the form `640x480+0+0`) 215 * `full_geom` : the "full" or "display" size) 216 * `MINCOLOR` : the minimum value in each channel (channels are 217 comma-separated) 218 * `MAXCOLOR` : the maximum value in each channel (channels are 219 comma-separated) 220 * `AVGCOLOR` : the average pixel value of the image (channels are 221 comma-separated) 222 223* *imagename.'metadata'* 224 225 If the metadata name is not a "C identifier" (initial letter followed by 226 any number of letter, number, or underscore), it is permissible to use 227 single or double quotes to enclose the metadata name. For example, suppose 228 you want to retrieve metadata named "foo/bar", you could say 229 230 .. code-block:: 231 232 {TOP.'foo/bar'} 233 234 Without the quotes, it might try to retrieve `TOP.foo` (which doesn't 235 exist) and divide it by `bar`. 236 237* Arithmetic 238 239 Sub-expressions may be joined by `+`, `-`, `*`, `/`, `//`, and `%` for 240 arithmetic operations. (Note that like in Python 3, `/` is floating point 241 division, while `//` signifies integer division.) Parentheses are 242 supported, and standard operator precedence applies. 243 244* Special variables 245 246 * `FRAME_NUMBER` : the number of the frame in this iteration of 247 wildcard expansion. 248 * `FRAME_NUMBER_PAD` : like `FRAME_NUMBER`, but 0-padded based 249 on the value set on the command line by `--framepadding`. 250 251 252To illustrate how this works, consider the following command, which trims 253a four-pixel border from all sides and outputs a new image prefixed with 254"cropped_", without needing to know the resolution or filename of the 255original image:: 256 257 oiiotool input.exr -cut "{TOP.width-2*4}x{TOP.height-2*4}+{TOP.x+4}+{TOP.y+4}" \ 258 -o cropped_{TOP.filename} 259 260If you should come across filenames that contain braces (these are vary 261rare, but have been known to happen), you temporarily disable expression 262evaluation with the `--evaloff` end `--evalon` flags. For example:: 263 264 $ oiiotool --info "{weird}.exr" 265 > oiiotool ERROR: expression : syntax error at char 1 of `weird' 266 267 $ oiiotool --info --evaloff "{weird}.exr" 268 > {weird.exr} : 2048 x 1536, 3 channel, half openexr 269 270 271.. _sec-oiiotool-subimage-modifier: 272 273Dealing with multi-subimage/multi-part files 274---------------------------------------------- 275 276 277Some file formats allow storing multiple images in one file (notably 278OpenEXR, which calls them "multi-part"). There are some special behaviors to 279be aware of for multi-subimage files. 280 281Using :program:`oiiotool` for a simple input-to-output copy will preserve 282all of the subimages (assuming that the output format can accommodate 283multiple subimages):: 284 285 oiiotool multipart.exr -o another.exr 286 287Most :program:`oiiotool` commands by default work on just the *first* 288subimage of their input, discarding the others. For example:: 289 290 oiiotool multipart.exr --colorconvert lnf aces -o out.exr 291 292In this example, only the first subimage in `multipart.exr` will be color 293transformed and output to `out.exr`. Any other subimages in the input will 294not be used or copied. 295 296Using the `-a` command tells :program:`oiiotool` to try to preserve all 297subimges from the inputs and apply all computations to all subimages:: 298 299 oiiotool -a multipart.exr --colorconvert lnf aces -o out.exr 300 301Now all subimages of `multipart.exr` will be transformed and output. 302 303But that might not be enough. Perhaps there are some subimages that need the 304color conversion, and others that do not. Many :program:`oiiotool` commands 305take an optional modifier `:subimages=...` that can restrict the operation 306to certain subimages. The argument is a comma-separated list of any of the 307following: (a) an integer index of a subimage to include, or a minus sign 308(`-`) followed by an integer index of a subimage to exclude; (b) the name 309(as returned by the metadata "oiio:subimagename") of a subimage to include, 310or to exclude if preceded by a `-`; (c) the special string "all", meaning all 311subimages. Examples:: 312 313 # Color convert only subimages 0, 3, and 4, leave the rest as-is 314 oiiotool -a multipart.exr --colorconvert:subimages=0,3,4 lnf aces -o out.exr 315 316 # Color convert all subimages EXCEPT the one named "normal" 317 oiiotool -a multipart.exr --colorconvert:subimages=-normal lnf aces -o out.exr 318 319 320 321:program:`oiiotool` Tutorial / Recipes 322====================================== 323 324This section will give quick examples of common uses of :program:`oiiotool` 325to get you started. They should be fairly intuitive, but you can read the 326subsequent sections of this chapter for all the details on every command. 327 328Printing information about images 329--------------------------------- 330 331To print the name, format, resolution, and data type of an image (or many 332images):: 333 334 oiiotool --info *.tif 335 336 337To also print the full metadata about each input image, use both 338`--info` and `-v`:: 339 340 oiiotool --info -v *.tif 341 342or:: 343 344 oiiotool --info:verbose=1 *.tif 345 346To print info about all subimages and/or MIP-map levels of each input image, 347use the `-a` flag:: 348 349 oiiotool --info -v -a mipmap.exr 350 351To print statistics giving the minimum, maximum, average, and standard 352deviation of each channel of an image, as well as other information about 353the pixels:: 354 355 oiiotool --stats img_2012.jpg 356 357The `--info`, `--stats`, `-v`, and `-a` flags may be used in any 358combination. 359 360 361Converting between file formats 362------------------------------- 363 364It's a snap to convert among image formats supported by OpenImageIO (i.e., 365for which ImageInput and ImageOutput plugins can be found). The 366:program:`oiiotool` utility will simply infer the file format from the file 367extension. The following example converts a PNG image to JPEG:: 368 369 oiiotool lena.png -o lena.jpg 370 371The first argument (`lena.png`) is a filename, causing :program:`oiiotool` to 372read the file and makes it the current image. The `-o` command 373outputs the current image to the filename specified by the next 374argument. 375 376Thus, the above command should be read to mean, "Read `lena.png` into the 377current image, then output the current image as `lena.jpg` (using whatever 378file format is traditionally associated with the `.jpg` extension)." 379 380 381Comparing two images 382-------------------- 383 384To print a report of the differences between two images of the same 385resolution: 386 387.. code-block:: bash 388 389 oiiotool old.tif new.tif --diff 390 391If you also want to save an image showing just the differences: 392 393.. code-block:: bash 394 395 oiiotool old.tif new.tif --diff --absdiff -o diff.tif 396 397 398This looks complicated, but it's really simple: read `old.tif`, read 399`new.tif` (pushing `old.tif` down on the image stack), report the 400differences between them, subtract `new.tif` from `old.tif` and replace them 401both with the difference image, replace that with its absolute value, then 402save that image to `diff.tif`. 403 404Sometimes you want to compare images but allow a certain number of small 405difference, say allowing the comparison to pass as long as no more than 4061% of pixels differs by more than 1/255, and as long as no single pixel 407differs by more than 2/255. You can do this with thresholds:: 408 409 410 oiiotool old.tif new.tif --fail 0.004 -failpercent 1 --hardfail 0.008 --diff 411 412 413 414Changing the data format or bit depth 415------------------------------------- 416 417Just use the `-d` option to specify a pixel data format for all subsequent 418outputs. For example, assuming that `in.tif` uses 16-bit unsigned integer 419pixels, the following will convert it to an 8-bit unsigned pixels:: 420 421 oiiotool in.tif -d uint8 -o out.tif 422 423For formats that support per-channel data formats, you can override the 424format for one particular channel using `-d CHNAME=TYPE`. For example, 425assuming `rgbaz.exr` is a `float` RGBAZ file, and we wish to convert it to 426be `half` for RGBA, and `float` for Z. That can be accomplished with the 427following command:: 428 429 oiiotool rgbaz.tif -d half -d Z=float -o rgbaz2.exr 430 431 432Changing the compression 433------------------------ 434 435The following command converts writes a TIFF file, specifically using LZW 436compression:: 437 438 oiiotool in.tif --compression lzw -o compressed.tif 439 440The following command writes its results as a JPEG file at a compression 441quality of 50 (pretty severe compression), illustrating how some compression 442methods allow a quality metric to be optionally appended to the name:: 443 444 iconvert --compression jpeg:50 50 big.jpg small.jpg 445 446 447Converting between scanline and tiled images 448-------------------------------------------- 449 450Convert a scanline file to a tiled file with 16x16 tiles:: 451 452 oiiotool s.tif --tile 16 16 -o t.tif 453 454Convert a tiled file to scanline:: 455 456 oiiotool t.tif --scanline -o s.tif 457 458 459 460 461Adding captions or metadata 462--------------------------- 463 464Add a caption to the metadata:: 465 466 oiiotool foo.jpg --caption "Hawaii vacation" -o bar.jpg 467 468Add keywords to the metadata:: 469 470 oiiotool foo.jpg --keyword "volcano,lava" -o bar.jpg 471 472Add other arbitrary metadata:: 473 474 oiiotool in.exr --attrib "FStop" 22.0 \ 475 --attrib "IPTC:City" "Berkeley" -o out.exr 476 477 oiiotool in.exr --attrib:type=timecode smpte:TimeCode "11:34:04:00" \ 478 -o out.exr 479 480 oiiotool in.exr --attrib:type=int[4] FaceBBox "140,300,219,460" \ 481 -o out.exr 482 483 484 485Changing image boundaries 486------------------------- 487 488Change the origin of the pixel data window:: 489 490 oiiotool in.exr --origin +256+80 -o offset.exr 491 492Change the display window:: 493 494 oiiotool in.exr --fullsize 1024x768+16+16 -o out.exr 495 496Change the display window to match the data window:: 497 498 oiiotool in.exr --fullpixels -o out.exr 499 500Crop (trim) an image to a 128x128 region whose upper left corner is at 501location (900,300), leaving the remaining pixels in their original positions 502on the image plane (i.e., the resulting image will have origin at 900,300), 503and retaining its original display window:: 504 505 oiiotool in.exr --crop 128x128+900+300 -o out.exr 506 507Cut (trim and extract) a 128x128 region whose upper left corner is at 508location (900,300), moving the result to the origin (0,0) of the image plane 509and setting the display window to the new pixel data window:: 510 511 oiiotool in.exr --cut 128x128+900+300 -o out.exr 512 513 514 515Scale the values in an image 516---------------------------- 517 518Reduce the brightness of the R, G, and B channels by 10%, 519but leave the A channel at its original value:: 520 521 oiiotool original.exr --mulc 0.9,0.9,0.9,1.0 -o out.exr 522 523 524Remove gamma-correction from an image 525------------------------------------- 526 527Convert a gamma-corrected image (with gamma = 2.2) to linear values:: 528 529 oiiotool corrected.exr --powc 2.2,2.2,2.2,1.0 -o linear.exr 530 531Resize an image 532--------------- 533 534Resize to a specific resolution:: 535 536 oiiotool original.tif --resize 1024x768 -o specific.tif 537 538Resize both dimensions by a known scale factor:: 539 540 oiiotool original.tif --resize 200% -o big.tif 541 oiiotool original.tif --resize 25% -o small.tif 542 543Resize each dimension, independently, by known scale factors:: 544 545 oiiotool original.tif --resize 300%x200% -o big.tif 546 oiiotool original.tif --resize 100%x25% -o small.tif 547 548Resize to a known resolution in one dimension, with the other dimension 549automatically computed to preserve aspect ratio (just specify 0 as the 550resolution in the dimension to be automatically computed):: 551 552 oiiotool original.tif --resize 200x0 -o out.tif 553 oiiotool original.tif --resize 0x1024 -o out.tif 554 555Resize to fit into a given resolution, keeping the original aspect ratio and 556padding with black where necessary to fit into the specified resolution:: 557 558 oiiotool original.tif --fit 640x480 -o fit.tif 559 560 561 562Color convert an image 563---------------------- 564 565This command linearizes a JPEG assumed to be in sRGB, saving as an HDRI 566OpenEXR file:: 567 568 oiiotool photo.jpg --colorconvert sRGB linear -o output.exr 569 570And the other direction:: 571 572 oiiotool render.exr --colorconvert linear sRGB -o fortheweb.png 573 574This converts between two named color spaces (presumably defined by your 575facility's OpenColorIO configuration):: 576 577 oiiotool in.dpx --colorconvert lg10 lnf -o out.exr 578 579 580 581Grayscale and RGB 582----------------- 583 584Turn a single channel image into a 3-channel gray RGB:: 585 586 oiiotool gray.tif --ch 0,0,0 -o rgb.tif 587 588Convert a color image to luminance grayscale:: 589 590 oiiotool RGB.tif --chsum:weight=.2126,.7152,.0722 -o luma.tif 591 592 593Channel reordering and padding 594------------------------------ 595 596Copy just the color from an RGBA file, truncating the A, yielding RGB only:: 597 598 oiiotool rgba.tif --ch R,G,B -o rgb.tif 599 600Zero out the red and green channels:: 601 602 oiiotool rgb.tif --ch R=0,G=0,B -o justblue.tif 603 604Swap the red and blue channels from an RGBA image:: 605 606 oiiotool rgba.tif --ch R=B,G,B=R,A -o bgra.tif 607 608Extract just the named channels from a many-channel image, as efficiently as 609possible (avoiding memory and I/O for the unused channels):: 610 611 oiiotool -i:ch=R,G,B manychannels.exr -o rgb.exr 612 613Add an alpha channel to an RGB image, setting it to 1.0 everywhere, and 614naming it "A" so it will be recognized as an alpha channel:: 615 616 oiiotool rgb.tif --ch R,G,B,A=1.0 -o rgba.tif 617 618 619Add an alpha channel to an RGB image, setting it to be the same as the R 620channel and naming it "A" so it will be recognized as an alpha channel:: 621 622 oiiotool rgb.tif --ch R,G,B,A=R -o rgba.tif 623 624Add a *z* channel to an RGBA image, setting it to 3.0 everywhere, and naming 625it "Z" so it will be recognized as a depth channel:: 626 627 oiiotool rgba.exr --ch R,G,B,A,Z=3.0 -o rgbaz.exr 628 629 630 631Copy metadata from one image to another 632--------------------------------------- 633 634Suppose you have a (non-OIIO) application that consumes input Exr files and 635produces output Exr files, but along the way loses crucial metadata from 636the input files that you want carried along. This command will add all the 637metadata from the first image to the pixels of the second image: 638 639 oiiotool metaonly.exr pixelsonly.exr --pastemeta -o combined.exr 640 641 642Fade between two images 643----------------------- 644 645Fade 30% of the way from A to B:: 646 647 oiiotool A.exr --mulc 0.7 B.exr --mulc 0.3 --add -o fade.exr 648 649 650 651Simple compositing 652------------------ 653 654Simple "over" composite of aligned foreground and background:: 655 656 oiiotool fg.exr bg.exr --over -o composite.exr 657 658Composite of small foreground over background, with offset:: 659 660 oiiotool fg.exr --origin +512+89 bg.exr --over -o composite.exr 661 662 663 664Creating an animated GIF from still images 665------------------------------------------ 666 667Combine several separate JPEG images into an animated GIF with a frame rate 668of 8 frames per second:: 669 670 oiiotool foo??.jpg --siappendall --attrib FramesPerSecond 10.0 -o anim.gif 671 672 673 674Frame sequences: composite a sequence of images 675----------------------------------------------- 676 677Composite foreground images over background images for a series of files 678with frame numbers in their names:: 679 680 oiiotool fg.1-50%04d.exr bg.1-50%04d.exr --over -o comp.1-50%04d.exr 681 682 683Or:: 684 685 oiiotool --frames 1-50 fg.%04d.exr bg.%04d.exr --over -o comp.%04d.exr 686 687 688 689Expression example: annotate the image with its caption 690------------------------------------------------------- 691 692This command reads a file, and draws any text in the "ImageDescription" 693metadata, 30 pixels from the bottom of the image:: 694 695 oiiotool input.exr --text:x=30:y={TOP.height-30} {TOP.ImageDescription} -o out.exr 696 697Note that this works without needing to know the caption ahead of time, and 698will always put the text 30 pixels from the bottom of the image without 699requiring you to know the resolution. 700 701 702Contrast enhancement: stretch pixel value range to exactly fit [0-1] 703-------------------------------------------------------------------- 704 705This command reads a file, subtracts the minimum pixel value and then 706divides by the (new) maximum value, per channel, thus expanding its pixel 707values to the full [0-1] range:: 708 709 oiiotool input.tif -subc {TOP.MINCOLOR} -divc {TOP.MAXCOLOR} -o out.tif 710 711Note that this is a naive way to improve contrast and because each channel 712is handled independently, it may result in color hue shifts. 713 714 715Split a multi-image file into separate files 716-------------------------------------------- 717 718Take a multi-image TIFF file, split into its constituent subimages and 719output each one to a different file, with names `sub0001.tif`, 720`sub0002.tif`, etc.:: 721 722 oiiotool multi.tif -sisplit -o:all=1 sub%04d.tif 723 724 725 726| 727 728:program:`oiiotool` commands: general and image information 729=========================================================== 730 731.. option:: --help 732 733 Prints full usage information to the terminal, as well as information 734 about image formats supported, known color spaces, filters, OIIO build 735 options and library dependencies. 736 737.. option:: -v 738 739 Verbose status messages --- print out more information about what 740 :program:`oiiotool` is doing at every step. 741 742.. option:: -q 743 744 Quet mode --- print out less information about what :program:`oiiotool` 745 is doing (only errors). 746 747.. option:: -n 748 749 No saved output --- do not save any image files. This is helpful for 750 certain kinds of tests, or in combination with `--runstats` or 751 `--debug`, for getting detailed information about what a command 752 sequence will do and what it costs, but without producing any saved 753 output files. 754 755.. option:: --debug 756 757 Debug mode --- print lots of information about what operations are being 758 performed. 759 760.. option:: --runstats 761 762 Print timing and memory statistics about the work done by 763 :program:`oiiotool`. 764 765.. option:: -a 766 767 Performs all operations on all subimages and/or MIPmap levels of each 768 input image. Without `-a`, generally each input image will really 769 only read the top-level MIPmap of the first subimage of the file. 770 771.. option:: --info 772 773 Prints information about each input image as it is read. If verbose 774 mode is turned on (`-v`), all the metadata for the image is printed. If 775 verbose mode is not turned on, only the resolution and data format are 776 printed. 777 778 Optional appended modifiers include: 779 780 - `format=name` : The format name may be one of: `text` (default) for 781 readable text, or `xml` for an XML description of the image metadata. 782 - `verbose=1` : If nonzero, the information will contain all metadata, 783 not just the minimal amount. 784 785.. option:: --echo <message> 786 787 Prints the message to the console, at that point in the left-to-right 788 execution of command line arguments. The message may contain expressions 789 for substitution. 790 791 Optional appended modifiers include: 792 793 - `newline=n` : The number of newlines to print after the message 794 (default is 1, but 0 will suppress the newline, and a larger number 795 will make more vertical space. 796 797 Examples:: 798 799 oiiotool test.tif --resize 256x0 --echo "result is {TOP.width}x{TOP.height}" 800 801 This will resize the input to be 256 pixels wide and automatically size 802 it vertically to preserve the original aspect ratio, and then print a 803 message to the console revealing the resolution of the resulting image. 804 805.. option:: --metamatch <regex>, --no-metamatch <regex> 806 807 Regular expressions to restrict which metadata are output when using 808 `oiiotool --info -v`. The `--metamatch` expression causes only metadata 809 whose name matches to print; non-matches are not output. The 810 `--no-metamatch` expression causes metadata whose name matches to be 811 suppressed; others (non-matches) are printed. It is not advised to use 812 both of these options at the same time (probably nothing bad will 813 happen, but it's hard to reason about the behavior in that case). 814 815.. option:: --stats 816 817 Prints detailed statistical information about each input image as it is 818 read. 819 820.. option:: --hash 821 822 Print the SHA-1 hash of the pixels of each input image. 823 824.. option:: --dumpdata 825 826 Print to the console detailed information about the values in every pixel. 827 828 Optional appended modifiers include: 829 830 - `empty=` *verbose* : If 0, will cause deep images to skip printing of 831 information about pixels with no samples. 832 833.. option:: --diff 834 --fail <A> --failpercent <B> --hardfail <C> 835 --warn <A> --warnpercent <B> --hardwarn <C> 836 837 This command computes the difference of the current image and the next 838 image on the stack, and prints a report of those differences (how 839 many pixels differed, the maximum amount, etc.). This command does not 840 alter the image stack. 841 842 The `--fail`, `--failpercent`, and `--hardfail` options set thresholds 843 for `FAILURE`: if more than *B* % of pixels (on a 0-100 floating point 844 scale) are greater than *A* different, or if *any* pixels are more than 845 *C* different. The defaults are to fail if more than 0% (any) pixels 846 differ by more than 0.00001 (1e-6), and *C* is infinite. 847 848 The `--warn`, `--warnpercent`, and `hardwarn` options set thresholds for 849 `WARNING`: if more than *B* % of pixels (on a 0-100 floating point scale) 850 are greater than *A* different, or if *any* pixels are more than *C* 851 different. The defaults are to warn if more than 0% (any) pixels differ 852 by more than 0.00001 (1e-6), and *C* is infinite. 853 854.. option:: --pdiff 855 856 This command computes the difference of the current image and the next 857 image on the stack using a perceptual metric, and prints whether or not 858 they match according to that metric. This command does not alter the 859 image stack. 860 861.. option:: --colorcount r1,g1,b1,...:r2,g2,b2,...:... 862 863 Given a list of colors separated by colons or semicolons, where each 864 color is a list of comma-separated values (for each channel), examine 865 all pixels of the current image and print a short report of how many 866 pixels matched each of the colors. 867 868 Optional appended modifiers include: 869 870 - `eps=r,g,b,...` : Tolerance for matching colors (default: 871 0.001 for all channels). 872 873 Examples:: 874 875 oiiotool test.tif --colorcount "0.792,0,0,1;0.722,0,0,1" 876 877 might produce the following output:: 878 879 10290 0.792,0,0,1 880 11281 0.722,0,0,1 881 882 Notice that use of double quotes `" "` around the list of color 883 arguments, in order to make sure that the command shell does not 884 interpret the semicolon (`;`) as a statement separator. An alternate 885 way to specify multiple colors is to separate them with a colon (`:`), 886 for example:: 887 888 oiiotool test.tif --colorcount 0.792,0,0,1:0.722,0,0,1 889 890 Another example:: 891 892 oiiotool test.tif --colorcount:eps=.01,.01,.01,1000 "0.792,0,0,1" 893 894 This example sets a larger epsilon for the R, G, and B channels (so 895 that, for example, a pixel with value [0.795,0,0] would also match), and 896 by setting the epsilon to 1000 for the alpha channel, it effectively 897 ensures that alpha will not be considered in the matching of pixels to 898 the color value. 899 900 901.. option:: --rangecheck Rlow,Glow,Blow,... Rhi,Bhi,Ghi,... 902 903 Given a two colors (each a comma-separated list of values for each 904 channel), print a count of the number of pixels in the image that has 905 channel values outside the [low,hi] range. Any channels not 906 specified will assume a low of 0.0 and high of 1.0. 907 908 Example:: 909 910 oiiotool test.exr --rangecheck 0,0,0 1,1,1 911 912 might produce the following output:: 913 914 0 < 0,0,0 915 221 > 1,1,1 916 65315 within range 917 918 919.. option:: --no-clobber 920 921 Sets "no clobber" mode, in which existing images on disk will never be 922 overridden, even if the `-o` command specifies that file. 923 924.. option:: --threads <n> 925 926 Use *n* execution threads if it helps to speed up image operations. The 927 default (also if n=0) is to use as many threads as there are cores 928 present in the hardware. 929 930 931.. option:: --frames <seq> 932 --framepadding <n> 933 934 Describes the frame range to substitute for the `#` or `%0Nd` numeric 935 wildcards. The sequence is a comma-separated list of subsequences; each 936 subsequence is a single frame (e.g., `100`), a range of frames 937 (`100-150`), or a frame range with step (`100-150x4` means 938 `100,104,108,...`). 939 940 The frame padding is the number of digits (with leading zeroes applied) 941 that the frame numbers should have. It defaults to 4. 942 943 For example, 944 945 oiiotool --framepadding 3 --frames 3,4,10-20x2 blah.#.tif 946 947 would match `blah.003.tif`, `blah.004.tif`, `blah.010.tif`, 948 `blah.012.tif`, `blah.014.tif`, `blah.016.tif`, `blah.018.tif`, 949 `blah.020.tif`. 950 951.. option:: --views <name1,name2,...> 952 953 Supplies a comma-separated list of view names (substituted for `%V` 954 and `%v`). If not supplied, the view list will be `left,right`. 955 956 957.. option:: --wildcardoff, --wildcardon 958 959 Turns off (or on) numeric wildcard expansion for subsequent command line 960 arguments. This can be useful in selectively disabling numeric wildcard 961 expansion for a subset of the command line. 962 963.. option:: --evaloff, --evalon 964 965 Turns off (or on) expression evaluation (things with `{ }`) for 966 subsequent command line arguments. This can be useful in selectively 967 disabling expression evaluation expansion for a subset of the command 968 line, for example if you actually have filenames containing curly 969 braces. 970 971 972 973:program:`oiiotool` commands: reading and writing images 974======================================================== 975 976The commands described in this section read images, write images, or control 977the way that subsequent images will be written upon output. 978 979.. _sec-oiiotool-i: 980 981Reading images 982-------------- 983 984.. option:: <filename> 985 -i <filename> 986 987If a command-line option is the name of an image file, that file will be 988read and will become the new *current image*, with the previous current 989image pushed onto the image stack. 990 991The `-i` command may be used, which allows additional options that control 992the reading of just that one file. 993 994Optional appended modifiers include: 995 996 `:now=` *int* 997 If 1, read the image now, before proceding to the next command. 998 `:autocc=` *int* 999 Enable or disable `--autocc` for this input image. 1000 `:info=` *int* 1001 Print info about this file (even if the global `--info` was not used) if 1002 nonzero. If the value is 2, print full verbose info (like `--info -v`). 1003 `:infoformat=` *name* 1004 When printing info, the format may be one of: `text` (default) for 1005 readable text, or `xml` for an XML description of the image metadata. 1006 `:type=` *name* 1007 Upon reading, convert the pixel data to the named type. This can 1008 override the default behavior of internally storing whatever type is the 1009 most precise one found in the file. 1010 `:ch=` *name...* 1011 Causes the input to read only the specified channels. This is equivalent 1012 to following the input with a `--ch` command, except that by integrating 1013 into the `-i`, it potentially can avoid the I/O of the unneeded 1014 channels. 1015 1016 1017 1018.. option:: -no-autopremult, --autopremult 1019 1020 By default, OpenImageIO's format readers convert any "unassociated 1021 alpha" (color values that are not "premultiplied" by alpha) to the usual 1022 associated/premultiplied convention. If the `--no-autopremult` flag is 1023 found, subsequent inputs will not do this premultiplication. It can be 1024 turned on again via `--autopremult`. 1025 1026.. option:: --autoorient 1027 1028 Automatically do the equivalent of `--reorient` on every image as it is 1029 read in, if it has a nonstandard orientation. This is generally a good idea 1030 to use if you are using oiiotool to combine images that may have different 1031 orientations. 1032 1033.. option:: --autocc 1034 1035 Turns on automatic color space conversion: Every input image file will 1036 be immediately converted to a scene-referred linear color space, and 1037 every file written will be first transformed to an appropriate output 1038 color space based on the filename or type. Additionally, if the name 1039 of an output file contains a color space and that color space is 1040 associated with a particular data format, it will output that data 1041 format (akin to `-d`). 1042 1043 The rules for deducing color spaces are as follows, in order of 1044 priority: 1045 1046 1. If the filename (input or output) contains as a substring the name of 1047 a color space from the current OpenColorIO configuration, that will 1048 be assumed to be the color space of input data (or be the requested 1049 color space for output). 1050 1051 2. For input files, if the ImageInput set the ``"oiio:ColorSpace"`` 1052 metadata, it will be honored if the filename did not override it. 1053 1054 3. When outputting to JPEG files, assume that sRGB is the desired output 1055 color space (since JPEG requires sRGB), but still this only occurs if 1056 the filename does not specify something different. 1057 1058 If the implied color transformation is unknown (for example, involving a 1059 color space that is not recognized), a warning will be printed, but it 1060 the rest of `oiiotool` processing will proceed (but without having 1061 transformed the colors of the image). 1062 1063 Example: 1064 1065 If the input file `in_lg10.dpx` is in the `lg10` color space, 1066 and you want to read it in, brighten the RGB uniformly by 10% (in a linear 1067 space, of course), and then save it as a 16 bit integer TIFF file encoded 1068 in the `vd16` color space, you could specifiy the conversions 1069 explicitly:: 1070 1071 oiiotool in_lg10.dpx --colorconvert lg10 linear \ 1072 --mulc 1.1,1.1,1.1,1.0 -colorconvert linear vd16 \ 1073 -d uint16 -o out_vd16.tif 1074 1075 or rely on the naming convention matching the OCIO color space 1076 names and use automatic conversion:: 1077 1078 oiiotool --autocc in_lg10.dpx --mulc 1.1 -o out_vd16.tif 1079 1080 1081.. option:: --native 1082 1083 Normally, all images read by :program:`oiiotool` are read into an 1084 ImageBuf backed by an underlying ImageCache, and are automatically 1085 converted to `float` pixels for internal storage (because any subsequent 1086 image processing is usually much faster and more accurate when done on 1087 floating-point values). 1088 1089 This option causes (1) input images to be stored internally in their 1090 native pixel data type rather than converted to float, and (2) to bypass 1091 the ImageCache (reading directly into an ImageBuf) if the pixel data 1092 type is not one of the types that is supported internally to ImageCache 1093 (`UINT8`, `uint16`, `half`, and `float`). 1094 1095 images whose pixels are comprised of data types that are not natively 1096 representable exactly in the ImageCache to bypass the ImageCache and be 1097 read directly into an ImageBuf. 1098 1099 The typical use case for this is when you know you are dealing with 1100 unusual pixel data types that might lose precision if converted to 1101 `float` (for example, if you have images with `uint32` or `double` 1102 pixels). Another use case is if you are using :program:`oiiotool` merely 1103 for file format or data format conversion, with no actual image 1104 processing math performed on the pixel values -- in that case, you might 1105 save time and memory by bypassing the conversion to `float`. 1106 1107.. option:: --cache <size> 1108 1109 Set the underlying ImageCache size (in MB). See Section 1110 :ref:`sec-imagecache-api`. 1111 1112.. option:: --autotile <tilesize> 1113 1114 For the underlying ImageCache, turn on auto-tiling with the given tile 1115 size. Setting *tilesize* to 0 turns off auto-tiling (the default is 1116 off). If auto-tile is turned on, The ImageCache "autoscanline" feature 1117 will also be enabled. See Section :ref:`sec-imagecache-api` for details. 1118 1119.. option:: --iconfig <name> <value> 1120 1121 Sets configuration metadata that will apply to the next input file read. 1122 1123 Optional appended modifiers include: 1124 1125 - `type=` *typename* : Specify the metadata type. 1126 1127 If the optional `type=` specifier is used, that provides an explicit 1128 type for the metadata. If not provided, it will try to infer the type of 1129 the metadata from the value: if the value contains only numerals (with 1130 optional leading minus sign), it will be saved as `int` metadata; if it 1131 also contains a decimal point, it will be saved as `float` metadata; 1132 otherwise, it will be saved as a `string` metadata. 1133 1134 Examples:: 1135 1136 oiiotool --iconfig "oiio:UnassociatedAlpha" 1 in.png -o out.tif 1137 1138 1139.. _sec-oiiotool-o: 1140 1141Writing images 1142-------------- 1143 1144.. option:: -o <filename> 1145 1146 Outputs the current image to the named file. This does not remove the 1147 current image from the image stack, it merely saves a copy of it. 1148 1149 Optional appended modifiers include: 1150 1151 `:type=` *name* 1152 Set the pixel data type (like `-d`) for this output image (e.g., 1153 `:uint8`, `uint16`, `half`, `float`, etc.). 1154 `:bits=` *int* 1155 Set the bits per pixel (if nonstandard for the datatype) for this 1156 output image. 1157 `:dither=` *int* 1158 Turn dither on or off for this output. (default: 0) 1159 `:autocc=` *int* 1160 Enable or disable `--autocc` for this output image. 1161 `:autocrop=` *int* 1162 Enable or disable autocrop for this output image. 1163 `:autotrim=` *int* 1164 Enable or disable `--autotrim` for this output image. 1165 `:separate=` *int*, `contig=` *int* 1166 Set separate or contiguous planar configuration for this output. 1167 `:fileformatname=` *string* 1168 Specify the desired output file format, overriding any guess based 1169 on file name extension. 1170 `:scanline=` *int* 1171 If nonzero, force scanline output. 1172 `:tile=` *int* `x` *int* 1173 Force tiling with given size. 1174 `:all=` *n* 1175 Output all images currently on the stack using a pattern. 1176 See further explanation below. 1177 1178 The `all=n` option causes *all* images on the image stack to be output, 1179 with the filename argument used as a pattern assumed to contain a `%d`, 1180 which will be substituted with the index of the image (beginning with 1181 *n*). For example, to take a multi-image TIFF and extract all the 1182 subimages and save them as separate files:: 1183 1184 oiiotool multi.tif -sisplit -o:all=1 sub%04d.tif 1185 1186 This will output the subimges as separate files `sub0001.tif`, 1187 `sub0002.tif`, and so on. 1188 1189 1190.. option:: -otex <filename> 1191 -oenv <filename> 1192 -obump <filename> 1193 1194 Outputs the current image to the named file, as a MIP-mapped texture or 1195 environment map, identical to that which would be output by `maketx` 1196 (Chapter :ref:`chap-maketx`). The advantage of using :program:`oiiotool` 1197 rather than `maketx` is simply that you can have a complex 1198 :program:`oiiotool` command line sequence of image operations, culminating 1199 in a direct saving of the results as a texture map, rather than saving to a 1200 temporary file and then separately invoking `maketx`. 1201 1202 In addition to all the optional arguments of `-o`, optional appended 1203 arguments for `-otex`, `-oenv`, and `-obump` also include: 1204 1205 `:wrap=` *string* 1206 Set the default $s$ and $t$ wrap modes of the texture, to one of: 1207 `:black`, `clamp`, `periodic`, `mirror`. 1208 `:swrap=` *string* 1209 Set the default $s$ wrap mode of the texture. 1210 `:twrap=` *string* 1211 Set the default $t$ wrap mode of the texture. 1212 `:resize=` *int* 1213 If nonzero, resize to a power of 2 before starting to create the 1214 MIPpmap levels. (default: 0) 1215 `:nomipmap=` *int* 1216 If nonzero, do not create MIP-map levels at all. (default: 0) 1217 `:updatemode=` *int* 1218 If nonzero, do not create and overwrite the existing texture if it 1219 appears to already match the source pixels. (default: 0) 1220 `:constant_color_detect=` *int* 1221 Detect images that are entirely one color, and change them to be low 1222 resolution. (default: 0) 1223 `:monochrome_detect=` *int* 1224 Detect monochrome (R=G=B) images and turn them into 1-channel 1225 textures. (default: 0) 1226 `:opaque_detect=` *int* 1227 Detect opaque (A=1) images and drop the alpha channel from the 1228 texture. (default: 0) 1229 `:compute_average=` *int* 1230 Compute and store the average color of the texture. (default: 1) 1231 `:unpremult=` *int* 1232 Unpremultiply colors before any per-MIP-level color conversions, and 1233 re-premultiply after. (default: 0) 1234 `:incolorspace=` *string* 1235 Specify color space conversion. 1236 `:outcolorspace=` *string* 1237 ... 1238 `:highlightcomp=` *int* 1239 Use highlight compensation for HDR images when resizing for MIP-map 1240 levels. (default: 0) 1241 `:sharpen=` *float* 1242 Additional sharpening factor when resizing for MIP-map levels. 1243 (default: 0.0) 1244 `:filter=` *string* 1245 Specify the filter for MIP-map level resizing. (default: box) 1246 `:prman_metadata=` *int* 1247 Turn all all options required to make the resulting texture file 1248 compatible with PRMan (particular tile sizes, formats, options, and 1249 metadata). (default: 0) 1250 `:prman_options=` *int* 1251 Include the metadata that PRMan's texture system wants. (default: 0) 1252 `:bumpformat=` *string* 1253 For `-obump` only, specifies the interpretation of 3-channel source 1254 images as one of: `height`, `normal`, `auto` (default). 1255 1256 1257 Examples:: 1258 1259 oiiotool in.tif -otex out.tx 1260 1261 oiiotool in.jpg --colorconvert sRGB linear -d uint16 -otex out.tx 1262 1263 oiiotool --pattern:checker 512x512 3 -d uint8 -otex:wrap=periodic checker.tx 1264 1265 oiiotool in.exr -otex:hilightcomp=1:sharpen=0.5 out.exr 1266 1267 1268.. option:: -d <datatype> 1269 -d <channelname>=<datatype> 1270 -d <subimagename>.*=<datatype> 1271 -d <subimagename>.<channelname>=<datatype> 1272 1273 Attempts to set the pixel data type of all subsequent outputs. If no 1274 channel or subimage name is given, sets *all* channels to be the 1275 specified data type. If a specific channel is named, then the data type 1276 will be overridden for just that channel (multiple `-d` commands may be 1277 used). If both a subimage name and channel name are specified, the hint 1278 is only for the named channel when encountered in a named subimage. And 1279 if the specification is of the form `subimagename.*=type`, then all 1280 channels of that subimage will be output with the given type. 1281 1282 Valid types are: `uint8`, `sint8`, `uint16`, `sint16`, `half`, `float`, 1283 `double`. The types `uint10` and `uint12` may be used to request 10- or 1284 12-bit unsigned integers. If the output file format does not support 1285 them, `uint16` will be substituted. 1286 1287 If the `-d` option is not supplied, the output data type will be 1288 deduced from the data format of the input files, if possible. 1289 1290 In any case, if the output file type does not support the requested data 1291 type, it will instead use whichever supported data type results in the 1292 least amount of precision lost. 1293 1294.. option:: --scanline 1295 1296 Requests that subsequent output files be scanline-oriented, if scanline 1297 orientation is supported by the output file format. By default, the 1298 output file will be scanline if the input is scanline, or tiled if the 1299 input is tiled. 1300 1301.. option:: --tile <x> <y> 1302 1303 Requests that subsequent output files be tiled, with the given 1304 :math:`x \times y` tile size, if tiled images are supported by the 1305 output format. By default, the output file will take on the tiledness 1306 and tile size of the input file. 1307 1308.. option:: --compression <method> 1309 --compression <method:quality> 1310 1311 Sets the compression method, and optionally a quality setting, for the 1312 output image. Each ImageOutput plugin will have its own set of methods 1313 that it supports. 1314 1315 Sets the compression method, and optionally a quality setting, for the 1316 output image. Each ImageOutput plugin will have its own set of methods 1317 that it supports. 1318 1319.. option:: --quality <q> 1320 1321 Sets the compression quality, on a 1-100 floating-point scale. 1322 This only has an effect if the particular compression method supports 1323 a quality metric (as JPEG does). 1324 1325 .. DEPRECATED(2.1) 1326 1327 This is considered deprecated, and in general we now recommend just 1328 appending the quality metric to the `--compression name:qual`. 1329 1330.. option:: --dither 1331 1332 Turns on *dither* when outputting to 8-bit image files (does not affect 1333 other data types). This adds just a bit of noise that reduces visible 1334 banding artifacts. 1335 1336.. option:: --planarconfig <config> 1337 1338 Sets the planar configuration of subsequent outputs (if supported by 1339 their formats). Valid choices are: `config` for contiguous (or 1340 interleaved) packing of channels in the file (e.g., RGBRGBRGB...), 1341 `separate` for separate channel planes (e.g., RRRR...GGGG...BBBB...), or 1342 `default` for the default choice for the given format. This command 1343 will be ignored for output files whose file format does not support the 1344 given choice. 1345 1346.. option:: --adjust-time 1347 1348 When this flag is present, after writing each output, the resulting 1349 file's modification time will be adjusted to match any `"DateTime"` 1350 metadata in the image. After doing this, a directory listing will show 1351 file times that match when the original image was created or captured, 1352 rather than simply when :program:`oiiotool` was run. This has no effect 1353 on image files that don't contain any `"DateTime"` metadata. 1354 1355.. option:: --noautocrop 1356 1357 For subsequent outputs, do *not* automatically crop images whose formats 1358 don't support separate pixel data and full/display windows. Without 1359 this, the default is that outputs will be cropped or padded with black 1360 as necessary when written to formats that don't support the concepts of 1361 pixel data windows and full/display windows. This is a non-issue for 1362 file formats that support these concepts, such as OpenEXR. 1363 1364.. option:: --autotrim 1365 1366 For subsequent outputs, if the output format supports separate pixel 1367 data and full/display windows, automatically trim the output so that 1368 it writes the minimal data window that contains all the non-zero valued 1369 pixels. In other words, trim off any all-black border rows and columns 1370 before writing the file. 1371 1372.. option:: --metamerge 1373 1374 When this flag is used, most image operations will try to merge the 1375 metadata found in all of their source input images into the output. 1376 The default (if this is not used) is that image oprations with multiple 1377 input images will just take metadata from the first source image. 1378 1379 (This was added for OpenImageIO 2.1.) 1380 1381 1382 1383:program:`oiiotool` commands that change the current image metadata 1384=================================================================== 1385 1386This section describes :program:`oiiotool` commands that alter the metadata 1387of the current image, but do not alter its pixel values. Only the current 1388(i.e., top of stack) image is affected, not any images further down the 1389stack. 1390 1391If the `-a` flag has previously been set, these commands apply to all 1392subimages or MIPmap levels of the current top image. Otherwise, they only 1393apply to the highest-resolution MIPmap level of the first subimage of the 1394current top image. 1395 1396.. option:: --attrib <name> <value> 1397 --sattrib <name> <value> 1398 1399 Adds or replaces metadata with the given *name* to have the specified 1400 *value*. 1401 1402 Optional appended modifiers include: 1403 1404 - `type=` *typename* : Specify the metadata type. 1405 1406 If the optional `type=` specifier is used, that provides an explicit 1407 type for the metadata. If not provided, it will try to infer the type of 1408 the metadata from the value: if the value contains only numerals (with 1409 optional leading minus sign), it will be saved as `int` metadata; if it 1410 also contains a decimal point, it will be saved as `float` metadata; 1411 otherwise, it will be saved as a `string` metadata. 1412 1413 The `--sattrib` command is equivalent to `--attrib:type=string`. 1414 1415 Examples:: 1416 1417 oiiotool in.jpg --attrib "IPTC:City" "Berkeley" -o out.jpg 1418 1419 oiiotool in.jpg --attrib:type=string "Name" "0" -o out.jpg 1420 1421 oiiotool in.exr --attrib:type=matrix worldtocam \ 1422 "1,0,0,0,0,1,0,0,0,0,1,0,2.3,2.1,0,1" -o out.exr 1423 1424 oiiotool in.exr --attrib:type=timecode smpte:TimeCode "11:34:04:00" \ 1425 -o out.exr 1426 1427 1428.. option:: --caption <text> 1429 1430 Sets the image metadata `"ImageDescription"`. This has no effect if the 1431 output image format does not support some kind of title, caption, or 1432 description metadata field. Be careful to enclose *text in quotes if you 1433 want your caption to include spaces or certain punctuation! 1434 1435.. option:: --keyword <text> 1436 1437 Adds a keyword to the image metadata `"Keywords"`. Any existing 1438 keywords will be preserved, not replaced, and the new keyword will not 1439 be added if it is an exact duplicate of existing keywords. This has no 1440 effect if the output image format does not support some kind of keyword 1441 field. 1442 1443 Be careful to enclose *text in quotes if you want your keyword to 1444 include spaces or certain punctuation. For image formats that have only 1445 a single field for keywords, OpenImageIO will concatenate the keywords, 1446 separated by semicolon (`;`), so don't use semicolons within your 1447 keywords. 1448 1449.. option:: --clear-keywords 1450 1451 Clears all existing keywords in the current image. 1452 1453.. option:: --nosoftwareattrib 1454 1455 When set, this prevents the normal adjustment of "Software" and 1456 "ImageHistory" metadata to reflect what :program:`oiiotool` is doing. 1457 1458.. option:: --sansattrib 1459 1460 When set, this edits the command line inserted in the "Software" and 1461 "ImageHistory" metadata to omit any verbose `--attrib` and `--sattrib` 1462 commands. 1463 1464.. option:: --eraseattrib <pattern> 1465 1466 Removes any metadata whose name matches the regular expression *pattern*. 1467 The pattern will be case insensitive. 1468 1469 Examples:: 1470 1471 # Remove one item only 1472 oiiotool in.jpg --eraseattrib "smpte:TimeCode" -o no_timecode.jpg 1473 1474 # Remove all GPS tags 1475 oiiotool in.jpg --eraseattrib "GPS:.*" -o no_gps_metadata.jpg 1476 1477 # Remove all metadata 1478 oiiotool in.exr --eraseattrib ".*" -o no_metadata.exr 1479 1480 1481.. option:: --orientation <orient> 1482 1483 Explicitly sets the image's `"Orientation"` metadata to a numeric value 1484 (see Section :ref:`sec-metadata-displayhints` for the numeric codes). This 1485 only changes the metadata field that specifies how the image should be 1486 displayed, it does NOT alter the pixels themselves, and so has no effect 1487 for image formats that don't support some kind of orientation metadata. 1488 1489.. option:: --orientcw 1490 --orientccw 1491 --orient180 1492 1493 Adjusts the image's `"Orientation"` metadata by rotating the suggested 1494 viewing orientation :math:`90^\circ` clockwise, :math:`90^\circ` degrees 1495 counter-clockwise, or :math:`180^\circ`, respectively, compared to its 1496 current setting. This only changes the metadata field that specifies 1497 how the image should be displayed, it does NOT alter the pixels 1498 themselves, and so has no effect for image formats that don't support 1499 some kind of orientation metadata. 1500 1501 See the `--rotate90`, `--rotate180`, `--rotate270`, and `--reorient` 1502 commands for true rotation of the pixels (not just the metadata). 1503 1504.. option:: --origin <neworigin> 1505 1506 Set the pixel data window origin, essentially translating the existing 1507 pixel data window to a different position on the image plane. 1508 The new data origin is in the form:: 1509 1510 [+-]x[+-]y 1511 1512 Examples:: 1513 1514 --origin +20+10 x=20, y=10 1515 --origin +0-40 x=0, y=-40 1516 1517 1518.. option:: --originoffset <offset> 1519 1520 Alter the data window origin, translating the existing pixel data window 1521 by this relative amount. 1522 The offset is in the form:: 1523 1524 [+-]x[+-]y 1525 1526 Examples:: 1527 1528 # Assuming the old origin was +100+20... 1529 --originoffset +20+10 # new x=120, y=30 1530 --originoffset +0-40 # new x=100, y=-20 1531 1532 1533.. option:: --fullsize <size> 1534 1535 Set the display/full window size and/or offset. The size is in the 1536 form 1537 1538 *width* x *height* [+-] *xoffset* [+-] *yoffset* 1539 1540 If either the offset or resolution is omitted, it will remain 1541 unchanged. 1542 1543 Examples: 1544 1545 ============================ ============================================ 1546 `--fullsize 1920x1080` resolution w=1920, h=1080, offset unchanged 1547 `--fullsize -20-30` resolution unchanged, x=-20, y=-30 1548 `--fullsize 1024x768+100+0` resolution w=1024, h=768, offset x=100, y=0 1549 ============================ ============================================ 1550 1551 1552.. option:: --fullpixels 1553 1554 Set the full/display window range to exactly cover the pixel data 1555 window. 1556 1557.. option:: --chnames <name-list> 1558 1559 Rename some or all of the channels of the top image to the given 1560 comma-separated list. Any completely empty channel names in the 1561 list will not be changed. For example:: 1562 1563 oiiotool in.exr --chnames ",,,A,Z" -o out.exr 1564 1565 will rename channel 3 to be "A" and channel 4 to be 1566 "Z", but will leave channels 0--3 with their old names. 1567 1568 Optional appended modifiers include: 1569 1570 `:subimages=` *indices-or-names* 1571 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 1572 Only included subimages will have their channels renamed. 1573 1574 1575.. _sec-oiiotool-shuffle-channels-or-subimages: 1576 1577:program:`oiiotool` commands that shuffle channels or subimages 1578=============================================================== 1579 1580.. option:: --selectmip <level> 1581 1582 If the current image is MIP-mapped, replace the current image with a new 1583 image consisting of only the given *level* of the MIPmap. Level 0 is the 1584 highest resolution version, level 1 is the next-lower resolution 1585 version, etc. 1586 1587.. option:: --unmip 1588 1589 If the current image is MIP-mapped, discard all but the top level (i.e., 1590 replacing the current image with a new image consisting of only the 1591 highest-resolution level). Note that this is equivalent to `--selectmip 1592 0`. 1593 1594.. option:: --subimage <n> 1595 1596 If the current image has multiple subimages, replace it with just the 1597 specified subimage. The subimage specifier *n* is either an integer 1598 giving the index of the subimage to extract (starting with 0), or the 1599 *name* of the subimage to extract (comparing to the 1600 `"oiio:subimagename"` metadata). 1601 1602 Additionally, this command can be used to remove one subimage (leaving 1603 the others) by using the optional modifier `--subimage:delete=1`. 1604 1605.. option:: --sisplit 1606 1607 Remove the top image from the stack, split it into its constituent 1608 subimages, and push them all onto the stack (first to last). 1609 1610.. option:: --siappend 1611 1612 Replaces the top two (or more) images on the stack with a single new 1613 multi-subimage comprised of the original images appended together as 1614 subimages within the same single image. 1615 1616 Optional appended modifiers include: 1617 1618 `:n=` *number-of-subimages* 1619 Specify the number (if more than 2) of images to combine into a 1620 single multi-subimage image. This will be clamped between 2 and the 1621 total number of images on the stack. 1622 1623.. option:: --siappendall 1624 1625 Replace *all* of the individual images on the stack with a single new 1626 image comprised of the subimages of all original images appended 1627 together. 1628 1629.. option:: --ch <channellist> 1630 1631 Replaces the top image with a new image whose channels have been 1632 reordered as given by the *channellist*. The `channellist` is a 1633 comma-separated list of channel designations, each of which may be 1634 1635 * an integer channel index of the channel to copy, 1636 * the name of a channel to copy, 1637 * *newname* `=` *oldname*, which copies a named channel and also renames 1638 it, 1639 * `=` *float*, which will set the channel to a constant value, or 1640 * *newname* `=` *float*, which sets the channel to a constant value as 1641 well as names the new channel. Examples include: `R,G,B`, 1642 `R=0.0,G,B,A=1.0`, `R=B,G,B=R`, `4,5,6,A`. 1643 1644 Channel numbers outside the valid range of input channels, or unknown 1645 names, will be replaced by black channels. If the *channellist* is 1646 shorter than the number of channels in the source image, unspecified 1647 channels will be omitted. 1648 1649.. option:: --chappend 1650 1651 Replaces the top two (or more) images on the stack with a single new 1652 image comprised of the channels of the input images appended together. 1653 1654 Optional appended modifiers include: 1655 1656 `:n=` *number-of-subimages* 1657 Specify the number (if more than 2) of images whose channels should 1658 be combined into a single image. This will be clamped between 2 and 1659 the total number of images on the stack. 1660 1661 `:subimages=` *indices-or-names* 1662 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 1663 1664 1665 1666:program:`oiiotool` commands that adjust the image stack 1667======================================================== 1668 1669.. option:: --pop 1670 1671 Pop the image stack, discarding the current image and thereby making the 1672 next image on the stack into the new current image. 1673 1674.. option:: --dup 1675 1676 Duplicate the current image and push the duplicate on the stack. Note 1677 that this results in both the current and the next image on the stack 1678 being identical copies. 1679 1680.. option:: --swap 1681 1682 Swap the current image and the next one on the stack. 1683 1684.. option:: --label <name> 1685 1686 Gives a name to (and saves) the current image at the top of the stack. 1687 Thereafter, the label name may be used to refer to that saved image, in 1688 the usual manner that an ordinary input image would be specified by 1689 filename. 1690 1691 1692:program:`oiiotool` commands that make entirely new images 1693========================================================== 1694 1695.. option:: --create <size> <channels> 1696 1697 Create new black image with the given size and number of channels, 1698 pushing it onto the image stack and making it the new current image. 1699 1700 The *size* is in the form 1701 1702 *width* x *height* [+-] *xoffset* [+-] *yoffset* 1703 1704 If the offset is omitted, it will be x=0, y=0. Optional appended 1705 arguments include: 1706 1707 - `type=` *name* : Create the image in memory with the named data type 1708 (default: float). 1709 1710 Examples:: 1711 1712 --create 1920x1080 3 # RGB with w=1920, h=1080, x=0, y=0 1713 --create 1024x768+100+0 4 # RGBA with w=1024, h=768, x=100, y=0 1714 --create:type=uint8 1920x1080 3 # RGB, store internally as uint8 1715 1716 1717.. option:: --pattern <patternname> <size> <channels> 1718 1719 Create new image with the given size and number of channels, 1720 initialize its pixels to the named pattern, and push it onto 1721 the image stack to make it the new current image. 1722 1723 The *size* is in the form 1724 1725 *width* x *height* [+-] *xoffset* [+-] *yoffset* 1726 1727 If the offset is omitted, it will be x=0, y=0. Optional appended 1728 arguments include: 1729 1730 - `type=` *name* : Create the image in memory with the named data type 1731 (default: float). 1732 1733 The patterns recognized include the following: 1734 1735 * `black` : A black image (all pixels 0.0) 1736 * `constant` : A constant color image, defaulting to white, but the 1737 color can be set with the optional `:color=r,g,b,...` arguments giving 1738 a numerical value for each channel. 1739 * `checker` : A black and white checkerboard pattern. The optional 1740 argument `:width=` sets with width of the checkers (defaulting to 8 1741 pixels). 1742 * `fill` : A constant color or gradient, depending on the optional 1743 colors. Argument `:color=r,g,b,...` results in a constant color. 1744 Argument `:top=r,g,b,...:bottom=...` results in a top-to-bottom 1745 gradient. Argument `:left=r,g,b,...:right=...` results in a 1746 left-to-right gradient. Argument 1747 `:topleft=r,g,b,...:topright=...:bottomleft=...:bottomright=...` 1748 results in a 4-corner bilinear gradient. 1749 * `noise` : Create a noise image, with the option `:type=` specifying 1750 the kind of noise: (1) `gaussian` (default) for normal distribution 1751 noise with mean and standard deviation given by `:mean=` and 1752 `:stddev=`, respectively (defaulting to 0 and 0.1); (2) `uniform` for 1753 uniformly-distributed noise over the range of values given by options 1754 `:min=` and `:max=` (defaults: 0 and 0.1); (3) `salt` for ``salt and 1755 pepper'' noise where a portion of pixels given by option `portion=` 1756 (default: 0.1) is replaced with value given by option `value=` 1757 (default: 0). For any of these noise types, the option `seed=` can be 1758 used to change the random number seed and `mono=1` can be used to make 1759 monochromatic noise (same value in all channels). 1760 1761 Examples: 1762 1763 A constant 4-channel, 640x480 image with all pixels (0.5, 0.5, 0.1, 1):: 1764 1765 --pattern constant:color=0.3,0.5,0.1,1.0 640x480 4 1766 1767 A 256x256 RGB image with a 16-pixel-wide checker pattern:: 1768 1769 --pattern checker:width=16:height=16 256x256 3 1770 1771 .. image:: figures/checker.jpg 1772 :align: center 1773 :width: 1.5in 1774 | 1775 1776 Horizontal, vertical, or 4-corner gradients:: 1777 1778 --pattern fill:top=0.1,0.1,0.1:bottom=0,0,0.5 640x480 3 1779 --pattern fill:left=0.1,0.1,0.1:right=0,0.75,0 640x480 3 1780 --pattern fill:topleft=.1,.1,.1:topright=1,0,0:bottomleft=0,1,0:botromright=0,0,1 640x480 3 1781 1782 .. image:: figures/gradient.jpg 1783 :width: 2.0in 1784 .. image:: figures/gradienth.jpg 1785 :width: 2.0in 1786 .. image:: figures/gradient4.jpg 1787 :width: 2.0in 1788 1789 | 1790 1791 The first example puts uniform noise independently in 3 channels, while the 1792 second generates a single greyscale noise and replicates it in all channels. 1793 1794 .. code-block:: 1795 1796 oiiotool --pattern noise:type=uniform:min=1:max=1 256x256 3 -o colornoise.jpg 1797 oiiotool --pattern noise:type=uniform:min=0:max=1:mono=1 256x256 3 -o greynoise.jpg} 1798 .. 1799 1800 .. image:: figures/unifnoise3.jpg 1801 :height: 1.5 in 1802 .. image:: figures/unifnoise1.jpg 1803 :height: 1.5 in 1804 1805 Generate Gaussian noise with mean 0.5 and standard deviation 0.2 for 1806 each channel:: 1807 1808 oiiotool --pattern noise:type=gaussian:mean=0.5:stddev=0.2 256x256 3 -o gaussnoise.jpg 1809 .. 1810 1811 .. image:: figures/gaussnoise.jpg 1812 :height: 2.0 in 1813 1814 1815.. option:: --kernel <name> <size> 1816 1817 Create new 1-channel `float` image big enough to hold the named kernel 1818 and size (size is expressed as *width* x *height*, e.g. `5x5`). The 1819 *width* and *height* are allowed to be floating-point numbers. The 1820 kernel image will have its origin offset so that the kernel center is at 1821 (0,0), and and will be normalized (the sum of all pixel values will be 1822 1.0). 1823 1824 Kernel names can be: `gaussian`, `sharp-gaussian`, `box`, `triangle`, 1825 `blackman-harris`, `mitchell`, `b-spline`, `cubic`, `keys`, `simon`, 1826 `rifman`, `disk`. There are also `catmull-rom` and `lanczos3` (and its 1827 synonym, `nuke-lanczos6`), but they are fixed-size kernels that don't 1828 scale with the width, and are therefore probably less useful in most 1829 cases. 1830 1831 Examples:: 1832 1833 oiiotool --kernel gaussian 11x11 -o gaussian.exr 1834 1835 1836 1837.. option:: --capture 1838 1839 Capture a frame from a camera device, pushing it onto the image stack 1840 and making it the new current image. Optional appended arguments 1841 include: 1842 1843 - `camera=` *num* : Select which camera number to capture (default: 0). 1844 1845 Examples:: 1846 1847 --capture # Capture from the default camera 1848 --capture:camera=1 # Capture from camera #1 1849 1850 1851:program:`oiiotool` commands that do image processing 1852===================================================== 1853 1854.. option:: --add 1855 --addc <value> 1856 --addc <value0,value1,value2...> 1857 1858 Replace the *two* top images with a new image that is the pixel-by-pixel 1859 sum of those images (`--add`), or add a constant color value to all 1860 pixels in the top image (`--addc`). 1861 1862 For `--addc`, if a single constant value is given, it will be added to 1863 all color channels. Alternatively, a series of comma-separated constant 1864 values (with no spaces!) may be used to specifiy a different value to 1865 add to each channel in the image. 1866 1867 Optional appended modifiers include: 1868 1869 `:subimages=` *indices-or-names* 1870 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 1871 1872 Examples:: 1873 1874 oiiotool imageA.tif imageB.tif --add -o sum.jpg 1875 1876 .. code-block:: 1877 1878 oiiotool tahoe.jpg --addc 0.5 -o addc.jpg 1879 .. 1880 1881 .. image:: figures/tahoe-small.jpg 1882 :width: 2.0 in 1883 .. image:: figures/addc.jpg 1884 :width: 2.0 in 1885 | 1886 1887 1888.. option:: --sub 1889 -- subc <value> 1890 -- subc <value0,value1,value2...> 1891 1892 Replace the *two* top images with a new image that is the pixel-by-pixel 1893 difference between the first and second images (`--sub`), or subtract a 1894 constant color value from all pixels in the top image (`--subc`). 1895 1896 For `--subc`, if a single constant value is given, it will be subtracted 1897 from all color channels. Alternatively, a series of comma-separated 1898 constant values (with no spaces!) may be used to specifiy a different 1899 value to subtract from each channel in the image. 1900 1901 Optional appended modifiers include: 1902 1903 `:subimages=` *indices-or-names* 1904 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 1905 1906 1907.. option:: --mul 1908 -- mulc <value> 1909 -- mulc <value0,value1,value2...> 1910 1911 Replace the *two* top images with a new image that is the pixel-by-pixel 1912 multiplicative product of those images (`--mul`), or multiply all pixels 1913 in the top image by a constant value (`--mulc`). 1914 1915 For `--mulc`, if a single constant value is given, it will be multiplied 1916 to all color channels. Alternatively, a series of comma-separated 1917 constant values (with no spaces!) may be used to specifiy a different 1918 value to multiply with each channel in the image. 1919 1920 Optional appended modifiers include: 1921 1922 `:subimages=` *indices-or-names* 1923 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 1924 1925 Example:: 1926 1927 # Scale image brightness to 20% of its original 1928 oiiotool tahoe.jpg --mulc 0.2 -o mulc.jpg 1929 .. 1930 1931 .. image:: figures/tahoe-small.jpg 1932 :width: 2.0 in 1933 .. image:: figures/mulc.jpg 1934 :width: 2.0 in 1935 | 1936 1937 1938.. option:: --div 1939 -- divc <value> 1940 -- divc <value0,value1,value2...> 1941 1942 Replace the *two* top images with a new image that is the 1943 pixel-by-pixel, channel-by-channel result of the first image divided by 1944 the second image (`--div`), or divide all pixels in the top image by a 1945 constant value (`--divc`). Division by zero is defined as resulting in 1946 0. 1947 1948 For `--divc`, if a single constant value is given, all color channels 1949 will have their values divided by the same value. Alternatively, a 1950 series of comma-separated constant values (with no spaces!) may be used 1951 to specifiy a different multiplier for each channel in the image, 1952 respectively. 1953 1954 Optional appended modifiers include: 1955 1956 `:subimages=` *indices-or-names* 1957 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 1958 1959 1960.. option:: --mad 1961 1962 Replace the *three* top images A, B, and C (C being the top of stack, B 1963 below it, and A below B), and compute `A*B+C`, placing the result on the 1964 stack. Note that `A B C --mad` is equivalent to `A B --mul C --add`, 1965 though using `--mad` may be somewhat faster and preserve more precision. 1966 1967 Optional appended modifiers include: 1968 1969 `:subimages=` *indices-or-names* 1970 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 1971 1972 1973.. option:: --invert 1974 1975 Replace the top images with its color inverse. It only inverts the first 1976 three channels, in order to preserve alpha. 1977 1978 Optional appended modifiers include: 1979 1980 `:subimages=` *indices-or-names* 1981 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 1982 1983 Example:: 1984 1985 oiiotool tahoe.jpg --inverse -o inverse.jpg 1986 .. 1987 1988 .. image:: figures/tahoe-small.jpg 1989 :width: 2.0 in 1990 .. image:: figures/invert.jpg 1991 :width: 2.0 in 1992 1993 1994 1995.. option:: --absdiff 1996 --absdiffc <value> 1997 --absdiffc <value0,value1,value2...> 1998 1999 Replace the *two* top images with a new image that is the absolute value 2000 of the difference between the first and second images (`--absdiff`), or 2001 replace the top image by the absolute value of the difference between 2002 each pixel and a constant color (`--absdiffc`). 2003 2004 Optional appended modifiers include: 2005 2006 `:subimages=` *indices-or-names* 2007 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 2008 2009 2010.. option:: --abs 2011 2012 Replace the current image with a new image that has each pixel 2013 consisting of the *absolute value* of the old pixel value. 2014 2015 Optional appended modifiers include: 2016 2017 `:subimages=` *indices-or-names* 2018 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 2019 2020.. option:: --powc <value> 2021 --powc <value0,value1,value2...> 2022 2023 Raise all the pixel values in the top image to a constant power value. 2024 If a single constant value is given, all color channels will have their 2025 values raised to this power. Alternatively, a series of comma-separated 2026 constant values (with no spaces!) may be used to specifiy a different 2027 exponent for each channel in the image, respectively. 2028 2029 Optional appended modifiers include: 2030 2031 `:subimages=` *indices-or-names* 2032 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 2033 2034 2035.. option:: --noise 2036 2037 Alter the top image to introduce noise, with the option `:type=` 2038 specifying the kind of noise: (1) `gaussian` (default) for normal 2039 distribution noise with mean and standard deviation given by `:mean=` 2040 and `:stddev=`, respectively (defaulting to 0 and 0.1); (2) `uniform` 2041 for uniformly-distributed noise over the range of values given by 2042 options `:min=` and `:max=` (defaults: 0 and 0.1); (3) `salt` for "salt 2043 and pepper" noise where a portion of pixels given by option `portion=` 2044 (default: 0.1) is replaced with value given by option `value=` (default: 2045 0). 2046 2047 Optional appended modifiers include: 2048 2049 `:seed=` *int* 2050 Can be used to change the random number seed. 2051 2052 `:mono=1` 2053 Make monochromatic noise (same value in all channels). 2054 2055 `:nchannels=` *int* 2056 Limit which channels are affected by the noise. 2057 2058 `:subimages=` *indices-or-names* 2059 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 2060 2061 Example:: 2062 2063 # Add color gaussian noise to an image 2064 oiiotool tahoe.jpg --noise:type=gaussian:stddev=0.1 -o noisy.jpg 2065 2066 # Simulate bad pixels by turning 1% of pixels black, but only in RGB 2067 # channels (leave A alone) 2068 oiiotool tahoe-rgba.tif --noise:type=salt:value=0:portion=0.01:mono=1:nchannels=3 \ 2069 -o dropouts.tif 2070 2071 .. 2072 2073 .. |noiseimg1| image:: figures/unifnoise1.jpg 2074 :height: 1.5 in 2075 .. |noiseimg2| image:: figures/tahoe-gauss.jpg 2076 :width: 2.0 in 2077 .. |noiseimg3| image:: figures/tahoe-pepper.jpg 2078 :width: 2.0 in 2079 2080 2081 +------------------------+------------------------+------------------------+ 2082 | |noiseimg1| | |noiseimg2| | |noiseimg3| | 2083 +------------------------+------------------------+------------------------+ 2084 | uniform noise | gaussian noise added | salt & pepper dropouts | 2085 +------------------------+------------------------+------------------------+ 2086 2087| 2088 2089.. option:: --chsum 2090 2091 Replaces the top image by a copy that contains only 1 color channel, 2092 whose value at each pixel is the sum of all channels of the original 2093 image. Using the optional weight allows you to customize the 2094 weight of each channel in the sum. 2095 2096 Optional appended modifiers include: 2097 2098 `weight=` *r,g,...* 2099 Specify the weight of each channel (default: 1). 2100 2101 `:subimages=` *indices-or-names* 2102 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 2103 2104 Example:: 2105 2106 oiiotool RGB.tif --chsum:weight=.2126,.7152,.0722 -o luma.tif 2107 2108 .. 2109 2110 .. image:: figures/tahoe-small.jpg 2111 :width: 2.0 in 2112 .. image:: figures/luma.jpg 2113 :width: 2.0 in 2114 2115| 2116 2117.. option:: --contrast 2118 2119 Remap pixel values from [black, white] to [min, max], with an optional 2120 smooth sigmoidal contrast stretch as well. 2121 2122 Optional appended modifiers include: 2123 2124 `black=` *vals* 2125 Specify black value(s), default 0.0. 2126 `white=` *vals* 2127 Specify white value(s), default 1.0. 2128 `min=` *vals* 2129 Specify the minimum range value(s), default 0.0. 2130 `max=` *vals* 2131 Specify the maximum range value(s), default 1.0. 2132 `scontrast=` *vals* 2133 Specify sigmoidal contrast slope value(s), 2134 default 1.0. 2135 `sthresh=` *vals* 2136 Specify sigmoidal threshold value(s) giving the position of maximum 2137 slope, default 0.5. 2138 `clamp=` *on* 2139 If *on* is nonzero, will optionally clamp all result channels to 2140 [min,max]. 2141 `:subimages=` *indices-or-names* 2142 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 2143 2144 Each *vals* may be either a single floating point value for all 2145 channels, or a comma-separated list of per-channel values. 2146 2147 Examples:: 2148 2149 oiiotool tahoe.tif --contrast:black=0.1:white=0.75 -o linstretch.tif 2150 oiiotool tahoe.tif --contrast:black=1.0:white=0.0:clamp=0 -o inverse.tif 2151 oiiotool tahoe.tif --contrast:scontrast=5 -o sigmoid.tif 2152 2153 .. |crimage1| image:: figures/tahoe-small.jpg 2154 :width: 1.5 in 2155 .. |crimage2| image:: figures/tahoe-lincontrast.jpg 2156 :width: 1.5 in 2157 .. |crimage3| image:: figures/tahoe-inverse.jpg 2158 :width: 1.5 in 2159 .. |crimage4| image:: figures/tahoe-sigmoid.jpg 2160 :width: 1.5 in 2161 .. 2162 2163 +-------------+-------------+-------------+-------------+ 2164 | |crimage1| | |crimage2| | |crimage3| | |crimage4| | 2165 +-------------+-------------+-------------+-------------+ 2166 | original | linstretch | inverse | sigmoid | 2167 +-------------+-------------+-------------+-------------+ 2168 2169 2170 2171.. option:: --colormap <mapname> 2172 2173 Creates an RGB color map based on the luminance of the input image. The 2174 `mapname` may be one of: "magma", "inferno", "plasma", "viridis", "turbo", 2175 "blue-red", "spectrum", and "heat". Or, `mapname` may also be a 2176 comma-separated list of RGB triples, to form a custom color map curve. 2177 2178 Note that "magma", "inferno", "plasma", "viridis" are perceptually 2179 uniform, strictly increasing in luminance, look good when converted to 2180 grayscale, and work for people with all types of colorblindness. The 2181 "turbo" color map also shares all of these qualities except for being 2182 strictly increasing in luminance. These 2183 are all desirable qualities that are lacking in the other, older, 2184 crappier maps (blue-red, spectrum, and heat). Don't be fooled by the 2185 flashy "spectrum" colors --- it is an empirically bad color map compared 2186 to the preferred ones. 2187 2188 Optional appended modifiers include: 2189 2190 `:subimages=` *indices-or-names* 2191 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 2192 2193 Example:: 2194 2195 oiiotool tahoe.jpg --colormap inferno -o inferno.jpg 2196 oiiotool tahoe.jpg --colormap viridis -o viridis.jpg 2197 oiiotool tahoe.jpg --colormap turbo -o turbo.jpg 2198 oiiotool tahoe.jpg --colormap .25,.25,.25,0,.5,0,1,0,0 -o custom.jpg 2199 2200 .. |cmimage1| image:: figures/tahoe-small.jpg 2201 :width: 1.25 in 2202 .. |cmimage2| image:: figures/colormap-inferno.jpg 2203 :width: 1.25 in 2204 .. |cmimage3| image:: figures/colormap-viridis.jpg 2205 :width: 1.25 in 2206 .. |cmimage4| image:: figures/colormap-turbo.jpg 2207 :width: 1.25 in 2208 .. |cmimage5| image:: figures/colormap-custom.jpg 2209 :width: 1.25 in 2210 .. 2211 2212 +-----------------+-----------------+-----------------+-----------------+---------------+ 2213 | |cmimage1| | |cmimage2| | |cmimage3| | |cmimage4| | |cmimage5| | 2214 +-----------------+-----------------+-----------------+-----------------+---------------+ 2215 | original | inferno | viridis | turbo | custom values | 2216 +-----------------+-----------------+-----------------+-----------------+---------------+ 2217 2218 2219.. option:: --paste <location> 2220 2221 Takes two images -- the first is the "foreground" and the second is the 2222 "background" -- and uses the pixels of the foreground to replace those 2223 of the backgroud, with foreground pixel (0,0) being pasted to the 2224 background at the *location* specified (expressed as `+xpos+ypos`, e.g., 2225 `+100+50`, or of course using `-` for negative offsets). Only pixels 2226 within the actual data region of the foreground image are pasted in this 2227 manner. 2228 2229 Note that if location is +0+0, the foreground image's data region will 2230 be copied to its same position in the background image (this is useful 2231 if you are pasting an image that already knows its correct data window 2232 offset). 2233 2234 Optional appended modifiers include: 2235 2236 - `mergeroi=1` : If the value is nonzero, the result image will be sized 2237 to be the *union* of the input images (versus being the same data 2238 window as the background image). (The `mergeroi` modifier was added in 2239 OIIO 2.1.) 2240 2241 - `all=1` : If the value is nonzero, will paste *all* images on the 2242 image stack, not just the top two images. This can be useful to 2243 paste-merge many images at once, for example, if you have rendered a 2244 large image in abutting tiles and wish to re-assemble them into a 2245 single image. (The `all` modifier was added in OIIO 2.1.) 2246 2247 Examples:: 2248 2249 # Result will be the size of bg, but with fg on top and with an 2250 # offset of (100,100). 2251 oiiotool fg.exr bg.exr -paste +100+100 -o out.exr 2252 2253 # Use "merge" mode, so result will be sized to contain both fg 2254 # and bg. Also, paste fg into its natural position given by its 2255 # data window. 2256 oiiotool fg.exr bg.exr -paste:mergeroi=1 +0+0 -o out.exr 2257 2258 # Merge many non-overlapping "tiles" into one combined image 2259 oiiotool img*.exr -paste:mergeroi=1:all=1 +0+0 -o combined.exr 2260 2261 2262.. option:: --pastemeta <location> 2263 2264 Takes two images -- the first will be a source of metadata only, and the 2265 second the source of pixels -- and produces a new copy of the second 2266 image with the metadata from the first image added. 2267 2268 The output image's pixels will come only from the second input. Metadata 2269 from the second input will be preserved if no identically-named metadata 2270 was present in the first input image. 2271 2272 Examples:: 2273 2274 # Add all the metadata from meta.exr to pixels.exr and write the 2275 # combined image to out.exr. 2276 oiiotool meta.exr pixels.exr --pastemeta -o out.exr 2277 2278 2279.. option:: --mosaic <size> 2280 2281 Removes :math:`w \times h` images, dictated by the *size*, and turns 2282 them into a single image mosaic. Optional appended modifiers include: 2283 2284 - `pad=` *num* : Select the number of pixels of black padding to add 2285 between images (default: 0). 2286 2287 Examples:: 2288 2289 oiiotool left.tif right.tif --mosaic:pad=16 2x1 -o out.tif 2290 2291 oiiotool 0.tif 1.tif 2.tif 3.tif 4.tif --mosaic:pad=16 2x2 -o out.tif 2292 2293 2294.. option:: --over 2295 2296 Replace the *two* top images with a new image that is the Porter/Duff 2297 "over" composite with the first image as the foreground and the second 2298 image as the background. Both input images must have the same number and 2299 order of channels and must contain an alpha channel. 2300 2301 Optional appended modifiers include: 2302 2303 `:subimages=` *indices-or-names* 2304 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 2305 2306.. option:: --zover 2307 2308 Replace the *two* top images with a new image that is a *depth 2309 composite* of the two images -- the operation is the Porter/Duff "over" 2310 composite, but each pixel individually will choose which of the two 2311 images is the foreground and which background, depending on the "Z" 2312 channel values for that pixel (larger Z means farther away). Both input 2313 images must have the same number and order of channels and must contain 2314 both depth/Z and alpha channels. Optional appended modifiers include: 2315 2316 `zeroisinf=` *num* 2317 If nonzero, indicates that z=0 pixels should be treated as if they 2318 were infinitely far away. (The default is 0, meaning that "zero 2319 means zero.""). 2320 `:subimages=` *indices-or-names* 2321 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 2322 2323 2324.. option:: --rotate90 2325 2326 Replace the current image with a new image that is rotated 90 degrees 2327 clockwise. 2328 2329 Optional appended modifiers include: 2330 2331 `:subimages=` *indices-or-names* 2332 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 2333 2334 Example:: 2335 2336 oiiotool grid.jpg --rotate90 -o rotate90.jpg 2337 2338 .. 2339 2340 .. image:: figures/grid-small.jpg 2341 :width: 1.5 in 2342 .. image:: figures/rotate90.jpg 2343 :width: 1.5 in 2344 2345 2346.. option:: --rotate180 2347 2348 Replace the current image with a new image that is rotated by 2349 180 degrees. 2350 2351 Optional appended modifiers include: 2352 2353 `:subimages=` *indices-or-names* 2354 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 2355 2356 Example:: 2357 2358 oiiotool grid.jpg --rotate180 -o rotate180.jpg 2359 2360 .. 2361 2362 .. image:: figures/grid-small.jpg 2363 :width: 1.5 in 2364 .. image:: figures/rotate180.jpg 2365 :width: 1.5 in 2366 2367.. option:: --rotate270 2368 2369 Replace the current image with a new image that is rotated 270 degrees 2370 clockwise (or 90 degrees counter-clockwise). 2371 2372 Optional appended modifiers include: 2373 2374 `:subimages=` *indices-or-names* 2375 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 2376 2377 Example:: 2378 2379 oiiotool grid.jpg --rotate270 -o rotate270.jpg 2380 2381 .. 2382 2383 .. image:: figures/grid-small.jpg 2384 :width: 1.5 in 2385 .. image:: figures/rotate270.jpg 2386 :width: 1.5 in 2387 2388 2389.. option:: --flip 2390 2391 Replace the current image with a new image that is flipped vertically, 2392 with the top scanline becoming the bottom, and vice versa. 2393 2394 Optional appended modifiers include: 2395 2396 `:subimages=` *indices-or-names* 2397 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 2398 2399 Example:: 2400 2401 oiiotool grid.jpg --flip -o flip.jpg 2402 2403 .. 2404 2405 .. image:: figures/grid-small.jpg 2406 :width: 1.5 in 2407 .. image:: figures/flip.jpg 2408 :width: 1.5 in 2409 2410.. option:: --flop 2411 2412 Replace the current image with a new image that is flopped horizontally, 2413 with the leftmost column becoming the rightmost, and vice versa. 2414 2415 Optional appended modifiers include: 2416 2417 `:subimages=` *indices-or-names* 2418 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 2419 2420 Example:: 2421 2422 oiiotool grid.jpg --flop -o flop.jpg 2423 2424 .. 2425 2426 .. image:: figures/grid-small.jpg 2427 :width: 1.5 in 2428 .. image:: figures/flop.jpg 2429 :width: 1.5 in 2430 2431 2432.. option:: --reorient 2433 2434 Replace the current image with a new image that is rotated and/or flipped 2435 as necessary to move the pixels to match the Orientation metadata 2436 that describes the desired display orientation. 2437 2438 Example:: 2439 2440 oiiotool tahoe.jpg --reorient -o oriented.jpg 2441 2442 2443.. option:: --transpose 2444 2445 Replace the current image with a new image that is reflected about 2446 the x-y axis (x and y coordinates and sizes are swapped). 2447 2448 Optional appended modifiers include: 2449 2450 `:subimages=` *indices-or-names* 2451 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 2452 2453 Example:: 2454 2455 oiiotool grid.jpg --transpose -o transpose.jpg 2456 2457 .. 2458 2459 .. image:: figures/grid-small.jpg 2460 :width: 1.5 in 2461 .. image:: figures/transpose.jpg 2462 :width: 1.5 in 2463 2464.. option:: --cshift <offset> 2465 2466 Circularly shift the pixels of the image by the given offset (expressed 2467 as `+10+100` to move by 10 pixels horizontally and 100 pixels 2468 vertically, or `+50-30` to move by 50 pixels horizontally and -30 2469 pixels vertically. *Circular* shifting means that the pixels wrap to 2470 the other side as they shift. 2471 2472 Optional appended modifiers include: 2473 2474 `:subimages=` *indices-or-names* 2475 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 2476 2477 Example:: 2478 2479 oiiotool grid.jpg --cshift +70+30 -o cshift.jpg 2480 2481 .. image:: figures/grid-small.jpg 2482 :width: 1.5 in 2483 .. image:: figures/cshift.jpg 2484 :width: 1.5 in 2485 2486.. option:: --crop <size> 2487 2488 Replace the current image with a new copy with the given *size*, 2489 cropping old pixels no longer needed, padding black pixels where they 2490 previously did not exist in the old image, and adjusting the offsets 2491 if requested. 2492 2493 The size is in the form 2494 2495 *width* x *height* [+-] *xoffset* [+-] *yoffset* 2496 2497 or 2498 2499 *xmin,ymin,xmax,ymax* 2500 2501 Note that `crop` does not *reposition* pixels, it only trims or pads to 2502 reset the image's pixel data window to the specified region. 2503 2504 If :program:`oiiotool`'s global `-a` flag is used (**all** subimages), 2505 or if the optional `--crop:allsubimages=1` is employed, the crop will be 2506 applied identically to all subimages. 2507 2508 Examples:: 2509 2510 # Both of these crop to a 100x120 region that begins at x=35,y=40 2511 oiiotool tahoe.exr --crop 100x120+35+40 -o crop.exr 2512 oiiotool tahoe.exr --crop 35,40,134,159 -o crop.exr 2513 2514 .. image:: figures/tahoe-small.jpg 2515 :width: 1.5 in 2516 .. image:: figures/crop.jpg 2517 :width: 1.5 in 2518 2519.. option:: --croptofull 2520 2521 Replace the current image with a new image that is cropped or padded 2522 as necessary to make the pixel data window exactly cover 2523 the full/display window. 2524 2525.. option:: --trim 2526 2527 Replace the current image with a new image that is cropped to contain the 2528 minimal rectangular ROI that contains all of the nonzero-valued pixels of 2529 the original image. 2530 2531 Examples:: 2532 2533 oiiotool greenrect.exr -trim -o trimmed.jpg 2534 2535 .. image:: figures/pretrim.jpg 2536 :width: 1.5 in 2537 .. image:: figures/trim.jpg 2538 :width: 1.5 in 2539 2540.. option:: --cut <size> 2541 2542 Replace the current image with a new copy with the given *size*, 2543 cropping old pixels no longer needed, padding black pixels where they 2544 previously did not exist in the old image, repositioning the cut region 2545 at the image origin (0,0) and resetting the full/display window to be 2546 identical to the new pixel data window. (In other words, `--cut` is 2547 equavalent to `--crop` followed by `--origin +0+0 --fullpixels`.) 2548 2549 The size is in the form 2550 2551 *width* x *height* [+-] *xoffset* [+-] *yoffset* 2552 2553 or 2554 2555 *xmin,ymin,xmax,ymax* 2556 2557 Examples:: 2558 2559 # Both of these crop to a 100x120 region that begins at x=35,y=40 2560 oiiotool tahoe.exr --cut 100x120+35+40 -o cut.exr 2561 oiiotool tahoe.exr --cut 35,40,134,159 -o cut.exr 2562 2563 .. image:: figures/tahoe-small.jpg 2564 :width: 1.5 in 2565 .. image:: figures/cut.jpg 2566 :width: 0.5 in 2567 2568| 2569 2570.. option:: --resample <size> 2571 2572 Replace the current image with a new image that is resampled to the 2573 given pixel data resolution rapidly, but at a low quality, either by 2574 simple bilinear interpolation or by just copying the "closest" pixel. 2575 The size is in the form of any of these: 2576 2577 *width* x *height* 2578 2579 *width* x *height* [+-] *xoffset* [+-] *yoffset* 2580 2581 *xmin,ymin,xmax,ymax* 2582 2583 *wscale% x hscale%* 2584 2585 if `width` or `height` is 0, that dimension will be automatically 2586 computed so as to preserve the original aspect ratio. 2587 2588 Optional appended modifiers include: 2589 2590 `interp=` *bool* 2591 If set to zero, it will just copy the "closest" pixel; if nonzero, 2592 bilinear interpolation of the surrounding 4 pixels will be used. 2593 2594 `:subimages=` *indices-or-names* 2595 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 2596 2597 Examples (suppose that the original image is 640x480):: 2598 2599 --resample 1024x768 # new resolution w=1024, h=768 2600 --resample 50% # reduce resolution to 320x240 2601 --resample 300% # increase resolution to 1920x1440 2602 --resample 400x0 # new resolution will be 400x300 2603 2604 2605.. option:: --resize <size> 2606 2607 Replace the current image with a new image whose display (full) size is 2608 the given pixel data resolution and offset. The *size* is in the form 2609 2610 *width* x *height* 2611 2612 *width* x *height* [+-] *xoffset* [+-] *yoffset* 2613 2614 *xmin,ymin,xmax,ymax* 2615 2616 *wscale% x hscale%* 2617 2618 if `width` or `height` is 0, that dimension will be 2619 automatically computed so as to preserve the original aspect ratio. 2620 2621 Optional appended modifiers include: 2622 2623 `filter=` *name* 2624 Filter name. The default is `blackman-harris` when increasing 2625 resolution, `lanczos3` when decreasing resolution. 2626 2627 `:subimages=` *indices-or-names* 2628 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 2629 2630 Examples (suppose that the original image is 640x480):: 2631 2632 --resize 1024x768 # new resolution w=1024, h=768 2633 --resize 50% # reduce resolution to 320x240 2634 --resize 300% # increase resolution to 1920x1440 2635 --resize 400x0 # new resolution will be 400x300 2636 2637 2638.. option:: --fit <size> 2639 2640 Replace the current image with a new image that is resized to fit 2641 into the given pixel data resolution, keeping the original aspect ratio 2642 and padding with black pixels if the requested image size does not 2643 have the same aspect ratio. The *size* is in the form 2644 2645 *width* x *height* 2646 2647 *width* x *height* [+-] *xoffset* [+-] *yoffset* 2648 2649 Optional appended modifiers include: 2650 2651 - `filter=` *name* : Filter name. The default is `blackman-harris` when 2652 increasing resolution, `lanczos3` when decreasing resolution. 2653 - `pad=` *p* : If the argument is nonzero, will pad with black pixels to 2654 make the resulting image exactly the size specified, if the source and 2655 desired size are not the same aspect ratio. 2656 - `exact=` *e* : If the argument is nonzero, will result in an exact 2657 match on aspect ratio and centering (partial pixel shift if 2658 necessary), whereas the default (0) will only preserve aspect ratio 2659 and centering to the precision of a whole pixel. 2660 - `wrap=` *w* : For "exact" aspect ratio fitting, this determines the 2661 wrap mode used for the resizing kernel (default: `black`, other 2662 choices include `clamp`, `periodic`, `mirror`). 2663 2664 Examples:: 2665 2666 oiiotool in.exr --fit:pad=1:exact=1 640x480 -o out.exr 2667 2668 oiiotool in.exr --fit 1024x1024 -o out.exr 2669 2670 2671.. option:: --pixelaspect <aspect> 2672 2673 Replace the current image with a new image that scales up the width or 2674 height in order to match the requested pixel aspect ratio. If displayed 2675 in a manner that honors the PixelAspectRatio, it should look the same, 2676 but it will have different pixel dimensions than the original. It will 2677 always be the same or higher resolution, so it does not lose any detail 2678 present in the original. 2679 2680 As an example, if you have a 512x512 image with pixel aspect ratio 1.0, 2681 `--pixelaspect 2.0` will result in a 512x1024 image that has 2682 "PixelAspectRatio" metadata set to 2.0. 2683 2684 Optional appended modifiers include: 2685 2686 - `filter=` *name* : Filter name. The default is `lanczos3`. 2687 2688 Examples:: 2689 2690 oiiotool mandrill.tif --pixelaspect 2.0 -o widepixels.tif 2691 2692 2693.. option:: --rotate <angle> 2694 2695 Replace the current image with a new image that is rotated by the given 2696 angle (in degrees). Positive angles mean to rotate counter-clockwise, 2697 negative angles mean clockwise. By default, the center of rotation is at 2698 the exact center of the display window (a.k.a. "full" image), but can be 2699 explicitly set with the optional `center=x,y` option. 2700 2701 Optional appended modifiers include: 2702 2703 `center=` *x,y* 2704 Alternate center of rotation. 2705 2706 `filter=` *name* 2707 Filter name. The default is `lanczos3`. 2708 2709 `recompute_roi=` *val* 2710 If nonzero, recompute the pixel data window to exactly hold the 2711 transformed image (default=0). 2712 2713 `:subimages=` *indices-or-names* 2714 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 2715 2716 Examples:: 2717 2718 oiiotool mandrill.tif --rotate 45 -o rotated.tif 2719 2720 oiiotool mandrill.tif --rotate:center=80,91.5:filter=lanczos3 45 -o rotated.tif 2721 2722 .. image:: figures/grid-small.jpg 2723 :width: 2.0 in 2724 .. image:: figures/rotate45.jpg 2725 :width: 2.0 in 2726 2727 2728.. option:: --warp <M33> 2729 2730 Replace the current image with a new image that is warped by the given 2731 3x3 matrix (presented as a comma-separated list of values, without 2732 any spaces). 2733 2734 Optional appended modifiers include: 2735 2736 `filter=` *name* 2737 Filter name. The default is `lanczos3`. 2738 2739 `recompute_roi=` *val* 2740 If nonzero, recompute the pixel data window to exactly hold the 2741 transformed image (default=0). 2742 2743 `:subimages=` *indices-or-names* 2744 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 2745 2746 Examples:: 2747 2748 oiiotool mandrill.tif --warp "0.707,0.707,0,-0.707,0.707,0,128,-53.02,1" -o warped.tif 2749 2750 2751.. option:: --convolve 2752 2753 Use the top image as a kernel to convolve the next image farther down 2754 the stack, replacing both with the result. 2755 2756 Optional appended modifiers include: 2757 2758 `:subimages=` *indices-or-names* 2759 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 2760 2761 Examples:: 2762 2763 # Use a kernel image already prepared 2764 oiiotool image.exr kernel.exr --convolve -o output.exr 2765 2766 # Construct a kernel image on the fly with --kernel 2767 oiiotool image.exr --kernel gaussian 5x5 --convolve -o blurred.exr 2768 2769 2770.. option:: --blur <size> 2771 2772 Blur the top image with a blur kernel of the given size expressed as *width* 2773 x *height*. (The sizes may be floating point numbers.) 2774 2775 Optional appended modifiers include: 2776 2777 `kernel=` *name* 2778 Kernel name. The default is `gaussian`. 2779 2780 `:subimages=` *indices-or-names* 2781 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 2782 2783 Examples:: 2784 2785 oiiotool image.jpg --blur 5x5 -o blurred.jpg 2786 2787 oiiotool image.jpg --blur:kernel=bspline 7x7 -o blurred.jpg 2788 2789 .. |convimage1| image:: figures/tahoe-small.jpg 2790 :width: 2.0 in 2791 .. |convimage2| image:: figures/tahoe-blur.jpg 2792 :width: 2.0 in 2793 .. 2794 2795 +-----------------+-----------------+ 2796 | |convimage1| | |convimage2| | 2797 +-----------------+-----------------+ 2798 | original | blurred | 2799 +-----------------+-----------------+ 2800 2801 2802.. option:: --median <size> 2803 2804 Perform a median filter on the top image with a window of the given size 2805 expressed as *width* x *height*. (The sizes are integers.) This helps 2806 to eliminate noise and other unwanted high-frequency detail, but without 2807 blurring long edges the way a `--blur` command would. 2808 2809 Optional appended modifiers include: 2810 2811 `:subimages=` *indices-or-names* 2812 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 2813 2814 Examples:: 2815 2816 oiiotool noisy.jpg --median 3x3 -o smoothed.jpg 2817 2818 .. |medimage1| image:: figures/tahoe-small.jpg 2819 :width: 2.0 in 2820 .. |medimage2| image:: figures/tahoe-pepper.jpg 2821 :width: 2.0 in 2822 .. |medimage3| image:: figures/tahoe-pepper-median.jpg 2823 :width: 2.0 in 2824 .. 2825 2826 +-----------------+-----------------+-----------------+ 2827 | |medimage1| | |medimage2| | |medimage3| | 2828 +-----------------+-----------------+-----------------+ 2829 | original | with dropouts | median filtered | 2830 +-----------------+-----------------+-----------------+ 2831 2832 2833 2834.. option:: --dilate <size> 2835 --erode <size> 2836 2837 Perform dilation or erosion on the top image with a window of the given 2838 size expressed as *width* x *height*. (The sizes are integers.) Dilation 2839 takes the maximum of pixel values inside the window, and makes bright 2840 features wider and more prominent, dark features thinner, and removes 2841 small isolated dark spots. Erosion takes the minimum of pixel values 2842 inside the window, and makes dark features wider, bright features 2843 thinner, and removes small isolated bright spots. 2844 2845 Optional appended modifiers include: 2846 2847 `:subimages=` *indices-or-names* 2848 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 2849 2850 Examples:: 2851 2852 oiiotool orig.tif --dilate 3x3 -o dilate.tif 2853 oiiotool orig.tif --erode 3x3 -o erode.tif 2854 oiiotool orig.tif --erode 3x3 --dilate 3x3 -o open.tif 2855 oiiotool orig.tif --dilate 3x3 --erode 3x3 -o close.tif 2856 oiiotool orig.tif --dilate 3x3 --erode 3x3 -sub -o gradient.tif 2857 oiiotool orig.tif open.tif -o tophat.tif 2858 oiiotool close.tif orig.tif -o bottomhat.tif 2859 2860 .. |morph1| image:: figures/morphsource.jpg 2861 :width: 1.0 in 2862 .. |morph2| image:: figures/dilate.jpg 2863 :width: 1.0 in 2864 .. |morph3| image:: figures/erode.jpg 2865 :width: 1.0 in 2866 .. |morph4| image:: figures/morphopen.jpg 2867 :width: 1.0 in 2868 .. |morph5| image:: figures/morphclose.jpg 2869 :width: 1.0 in 2870 .. |morph6| image:: figures/morphgradient.jpg 2871 :width: 1.0 in 2872 .. |morph7| image:: figures/tophat.jpg 2873 :width: 1.0 in 2874 .. |morph8| image:: figures/bottomhat.jpg 2875 :width: 1.0 in 2876 .. 2877 2878 +-----------------+-----------------+-----------------+-----------------+ 2879 | |morph1| | |morph2| | |morph3| | |morph4| | 2880 +-----------------+-----------------+-----------------+-----------------+ 2881 | original | dilate | erode | open | 2882 +-----------------+-----------------+-----------------+-----------------+ 2883 | | | | | 2884 | |morph5| | |morph6| | |morph7| | |morph8| | 2885 +-----------------+-----------------+-----------------+-----------------+ 2886 | close | gradient | tophat | bottomhat | 2887 +-----------------+-----------------+-----------------+-----------------+ 2888 2889 2890.. option:: --laplacian 2891 2892 Calculates the Laplacian of the top image. 2893 2894 Optional appended modifiers include: 2895 2896 `:subimages=` *indices-or-names* 2897 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 2898 2899 Examples:: 2900 2901 oiiotool tahoe.jpg --laplacian tahoe-laplacian.exr 2902 2903 .. |lapimage1| image:: figures/tahoe-small.jpg 2904 :width: 2.0 in 2905 .. |lapimage2| image:: figures/tahoe-laplacian.jpg 2906 :width: 2.0 in 2907 .. 2908 2909 +-----------------+-----------------+ 2910 | |lapimage1| | |lapimage2| | 2911 +-----------------+-----------------+ 2912 | original | Laplacian image | 2913 +-----------------+-----------------+ 2914 2915 2916 2917.. option:: --unsharp 2918 2919 Unblur the top image using an "unsharp mask."" 2920 2921 Optional appended modifiers include: 2922 2923 `kernel=` *name* 2924 Name of the blur kernel (default: `gaussian`). If the kernel name is 2925 `median`, the unsarp mask algorithm will use a median filter rather 2926 than a blurring filter in order to compute the low-frequency image. 2927 `width=` *w* 2928 Width of the blur kernel (default: 3). 2929 `contrast=` *c* 2930 Contrast scale (default: 1.0) 2931 `threshold=` *t* 2932 Threshold for applying the difference (default: 0) 2933 `:subimages=` *indices-or-names* 2934 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 2935 2936 Examples:: 2937 2938 oiiotool image.jpg --unsharp -o sharper.jpg 2939 2940 oiiotool image.jpg --unsharp:width=5:contrast=1.5 -o sharper.jpg 2941 2942 oiiotool image.jpg --unsharp:kernel=median -o sharper.jpg 2943 # Note: median filter helps emphasize compact high-frequency details 2944 # without over-sharpening long edges as the default unsharp filter 2945 # sometimes does. 2946 2947 2948 2949.. option:: --fft 2950 --ifft 2951 2952 Performs forward and inverse unitized discrete Fourier transform. The 2953 forward FFT always transforms only the first channel of the top image on 2954 the stack, and results in a 2-channel image (with real and imaginary 2955 channels). The inverse FFT transforms the first two channels of the top 2956 image on the stack (assuming they are real and imaginary, respectively) 2957 and results in a single channel result (with the real component only of 2958 the spatial domain result). 2959 2960 Optional appended modifiers include: 2961 2962 `:subimages=` *indices-or-names* 2963 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 2964 2965 Examples:: 2966 2967 # Select the blue channel and take its DCT 2968 oiiotool image.jpg --ch 2 --fft -o fft.exr 2969 2970 # Reconstruct from the FFT 2971 oiiotool fft.exr --ifft -o reconstructed.exr 2972 2973 # Output the power spectrum: real^2 + imag^2 2974 oiiotool fft.exr --dup --mul --chsum -o powerspectrum.exr 2975 2976 2977 2978.. option:: --polar 2979 --unpolar 2980 2981 The `--polar` transforms a 2-channel image whose channels are interpreted 2982 as complex values (real and imaginary components) into the equivalent 2983 values expressed in polar form of amplitude and phase (with phase 2984 between 0 and :math:`2\pi`). 2985 2986 The `unpolar` performs the reverse transformation, converting from polar 2987 values (amplitude and phase) to complex (real and imaginary). 2988 2989 Optional appended modifiers include: 2990 2991 `:subimages=` *indices-or-names* 2992 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 2993 2994 Examples:: 2995 2996 oiiotool complex.exr --polar -o polar.exr 2997 oiiotool polar.exr --unpolar -o complex.exr 2998 2999 3000 3001.. option:: --fixnan <streategy> 3002 3003 Replace the top image with a copy in which any pixels that contained 3004 `NaN` or `Inf` values (hereafter referred to collectively as 3005 "nonfinite") are repaired. If *strategy* is `black`, nonfinite values 3006 will be replaced with 0. If *strategy* is `box3`, nonfinite values will 3007 be replaced by the average of all the finite values within a 3x3 region 3008 surrounding the pixel. If *strategy* is `error`, nonfinite values will 3009 be left alone, but it will result in an error that will terminate 3010 :program:`oiiotool`. 3011 3012 3013.. option:: --max 3014 --maxc <value> 3015 --maxc <value0,value1,value2...> 3016 --min 3017 --minc <value> 3018 --minc <value0,value1,value2...> 3019 3020 Replace the *two* top images with a new image that is the pixel-by-pixel 3021 maximum of those images (`--max`) or minimum (`--min`) of the 3022 corresponding pixels of each image, or the min/max of each pixel of one 3023 image with a constant color (`--maxc`, `--minc`). 3024 3025 For `--maxc` and `--minc`, if a single constant value is given, it will 3026 be used for all color channels. Alternatively, a series of 3027 comma-separated constant values (with no spaces) may be used to specifiy 3028 a different value to add to each channel in the image. 3029 3030 Optional appended modifiers include: 3031 3032 `:subimages=` *indices-or-names* 3033 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 3034 3035 Examples: 3036 3037 oiiotool imageA.tif imageB.tif --min -o minimum.tif 3038 3039 # Clamp all channels to a mimimum of 0 (all negative values are 3040 # changed to 0). 3041 oiiotool input.exr --minc 0.0 -o nonegatives.exr 3042 3043 3044.. option:: --clamp 3045 3046 Replace the top image with a copy in which pixel values have been 3047 clamped. Optional arguments include: 3048 3049 Optional appended modifiers include: 3050 3051 - `min=` *val* : Specify a minimum value for all channels. 3052 - `min=` *val0,val1,...* : Specify minimum value for each channel 3053 individually. 3054 - `max=` *val* : Specify a maximum value for all channels. 3055 - `max=` *val0,val1,...* : Specify maximum value for each channel 3056 individually. 3057 - `clampalpha=` *val* : If *val* is nonzero, will additionally clamp the 3058 alpha channel to [0,1]. (Default: 0, no additional alpha clamp.) 3059 3060 If no value is given for either the minimum or maximum, it will NOT 3061 clamp in that direction. For the variety of minimum and maximum that 3062 specify per-channel values, a missing value indicates that the 3063 corresponding channel should not be clamped. 3064 3065 Examples: 3066 3067 - `--clamp:min=0` : Clamp all channels to a mimimum of 0 (all negative 3068 values are changed to 0). 3069 - `--clamp:min=0:max=1` : Clamp all channels to [0,1]. 3070 - `--clamp:clampalpha=1` : Clamp the designated alpha channel to [0,1]. 3071 - `--clamp:min=,,0:max=,,3.0` : Clamp the third channel to [0,3], do not 3072 clamp & other channels. 3073 3074 3075.. option:: --rangecompress 3076 --rangeexpand 3077 3078 Range compression re-maps input values to a logarithmic scale. 3079 Range expansion is the inverse mapping back to a linear scale. 3080 Range compression and expansion only applies to color 3081 channels; alpha or z channels will not be modified. 3082 3083 By default, this transformation will happen to each color channel 3084 independently. But if the optional `luma` argument is nonzero and the 3085 image has at least 3 channels and the first three channels are not alpha 3086 or depth, they will be assumed to be RGB and the pixel scaling will be 3087 done using the luminance and applied equally to all color channels. This 3088 can help to preserve color even when remapping intensity. 3089 3090 Optional appended modifiers include: 3091 3092 `luma=` *val* 3093 *val* is 0, turns off the luma behavior. 3094 3095 `:subimages=` *indices-or-names* 3096 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 3097 3098 Range compression and expansion can be useful in cases where high 3099 contrast super-white (> 1) pixels (such as very bright highlights in HDR 3100 captured or rendered images) can produce undesirable artifacts, such as 3101 if you resize an HDR image using a filter with negative lobes -- which 3102 could result in objectionable ringing or even negative result pixel 3103 values. For example:: 3104 3105 oiiotool hdr.exr --rangecompress --resize 512x512 --rangeexpand -o resized.exr 3106 3107.. option:: --fillholes 3108 3109 Replace the top image with a copy in which any pixels that had 3110 :math:`\alpha < 1` are "filled" in a smooth way using data from 3111 surrounding :math:`\alpha > 0` pixels, resulting in an image that is 3112 :math:`\alpha = 1` and plausible color everywhere. This can be used both 3113 to fill internal "holes" as well as to extend an image out. 3114 3115 3116.. option:: --line <x1,y1,x2,y2,...> 3117 3118 Draw (rasterize) an open polyline connecting the list of pixel 3119 positions, as a comma-separated list of alternating *x* and *y* values. 3120 Additional optional arguments include: 3121 3122 `color=` *r,g,b,...* 3123 specify the color of the line 3124 `:subimages=` *indices-or-names* 3125 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 3126 3127 The default color, if not supplied, is opaque white. 3128 3129 Examples:: 3130 3131 oiiotool checker.exr --line:color=1,0,0 10,60,250,20,100,190 -o out.exr 3132 3133 .. image:: figures/lines.png 3134 :align: center 3135 :width: 2.0 in 3136 3137 3138.. option:: --box <x1,y1,x2,y2> 3139 3140 Draw (rasterize) a filled or unfilled a box with opposite corners 3141 `(x1,y1)` and `(x2,y2)`. Additional optional arguments include: 3142 3143 `color=` *r,g,b,...* 3144 specify the color of the lines 3145 `fill=` *bool* 3146 if nonzero, fill in the box 3147 `:subimages=` *indices-or-names* 3148 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 3149 3150 The default color, if not supplied, is opaque white. 3151 3152 Examples:: 3153 3154 oiiotool checker.exr --box:color=0,1,1,1 150,100,240,180 \ 3155 --box:color=0.5,0.5,0,0.5:fill=1 100,50,180,140 -o out.exr 3156 3157 .. image:: figures/box.png 3158 :align: center 3159 :width: 2.0 in 3160 3161 3162.. option:: --fill <size> 3163 3164 Alter the top image by filling the ROI specified by *size*. The fill can 3165 be a constant color, vertical gradient, horizontal gradient, or 3166 four-corner gradient. 3167 3168 Optional modifiers for constant color: 3169 3170 `color=` *r,g,b,...* 3171 the color of the constant 3172 3173 Optional modifiers for vertical gradient: 3174 3175 `top=` *r,g,b,...* 3176 the color for the top edge of the region 3177 `bottom=` *r,g,b,...* 3178 the color for the bottom edge of the region 3179 3180 Optional modifiers for horizontal gradient: 3181 3182 `left=` *r,g,b,...* 3183 the color for the left edge of the region 3184 `right=` *r,g,b,...* 3185 the color for the right edge of the region 3186 3187 Optional modifiers for 4-corner gradient: 3188 3189 `topleft=` *r,g,b,...* 3190 the color for the top left corner of the region 3191 `topright=` *r,g,b,...* 3192 the color for the top right corner of the region 3193 `bottomleft=` *r,g,b,...* 3194 the color for the bottom left corner of the region 3195 `bottomright=` *r,g,b,...* 3196 the color for the bottom right corner of the region 3197 3198 Examples:: 3199 3200 # make a grey-to-blue vertical gradient 3201 oiiotool --create 640x480 3 \ 3202 --fill:top=0.1,0.1,0.1:bottom=0,0,0.5 640x480 -o gradient.tif 3203 3204 # make a grey-to-green horizontal gradient 3205 oiiotool --create 640x480 3 \ 3206 --fill:left=0.1,0.1,0.1:right=0,0.75,0 640x480 -o gradient.tif 3207 3208 # four-corner interpolated gradient 3209 oiiotool --create 640x480 3 \ 3210 -fill:topleft=.1,.1,.1:topright=1,0,0:bottomleft=0,1,0:botromright=0,0,1 \ 3211 640x480 -o gradient.tif 3212 3213 .. |textimg1| image:: figures/gradient.jpg 3214 :width: 2.0 in 3215 .. |textimg2| image:: figures/gradienth.jpg 3216 :width: 2.0 in 3217 .. |textimg2| image:: figures/gradient4.jpg 3218 :width: 2.0 in 3219 .. 3220 3221 3222 3223.. option:: --text <words> 3224 3225 Draw (rasterize) text overtop of the current image. 3226 3227 Optional appended modifiers include: 3228 3229 `x=` *xpos* 3230 *x* position (in pixel coordinates) of the text 3231 `y=` *ypos* 3232 *y* position (in pixel coordinates) of the text 3233 `size=` *size* 3234 font size (height, in pixels) 3235 `font=` *name* 3236 font name, full path to the font file on disk (use double quotes 3237 `"name"` if the path name includes spaces) 3238 `color=` *r,g,b,...* 3239 specify the color of the text 3240 `xalign=` *val* 3241 controls horizontal text alignment: `left` (default), `right`, 3242 `center`. 3243 `yalign=` *val* 3244 controls vertical text alignment: `base` (default), `top`, `bottom`, 3245 `center`. 3246 `shadow=` *size* 3247 if nonzero, will make a dark shadow halo to make the text more clear 3248 on bright backgrounds. 3249 `:subimages=` *indices-or-names* 3250 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 3251 3252 The default positions the text starting at the center of the image, 3253 drawn 16 pixels high in opaque white in all channels (1,1,1,...), and 3254 using a default font (which may be system dependent). 3255 3256 Examples:: 3257 3258 oiiotool --create 320x240 3 --text:x=10:y=400:size=40 "Hello world" \ 3259 --text:x=100:y=200:font="Arial Bold":color=1,0,0:size=60 "Go Big Red!" \ 3260 --tocolorspace sRGB -o text.jpg 3261 3262 oiiotool --create 320x240 3 --text:x=160:y=120:xalign=center "Centered" \ 3263 --tocolorspace sRGB -o textcentered.jpg 3264 3265 oiiotool tahoe-small.jpg \ 3266 --text:x=160:y=40:xalign=center:size=40:shadow=0 "shadow = 0" \ 3267 --text:x=160:y=80:xalign=center:size=40:shadow=1 "shadow = 1" \ 3268 --text:x=160:y=120:xalign=center:size=40:shadow=2 "shadow = 2" \ 3269 --tocolorspace sRGB -o textshadowed.jpg 3270 3271 .. |textimg1| image:: figures/text.jpg 3272 :width: 2.0 in 3273 .. |textimg2| image:: figures/textcentered.jpg 3274 :width: 2.0 in 3275 .. |textimg2| image:: figures/textshadowed.jpg 3276 :width: 2.0 in 3277 .. 3278 3279 Note that because of slightly differing fonts and versions of Freetype 3280 available, we do not expect drawn text to be pixel-for-pixel identical 3281 on different platforms supported by OpenImageIO. 3282 3283 3284 3285:program:`oiiotool` commands for color management 3286================================================= 3287 3288Many of the color management commands depend on an installation of 3289OpenColorIO (http://opencolorio.org). 3290 3291If OIIO has been compiled with OpenColorIO support and the environment 3292variable `$OCIO` is set to point to a valid OpenColorIO configuration file, 3293you will have access to all the color spaces that are known by that OCIO 3294configuration. Alternately, you can use the `--colorconfig` option to 3295explicitly point to a configuration file. If no valid configuration file is 3296found (either in `$OCIO` or specified by `--colorconfig}` or OIIO was not 3297compiled with OCIO support, then the only color space transformats available 3298are `linear` to `Rec709` (and vice versa) and `linear` to `sRGB` (and vice 3299versa). 3300 3301If you ask for :program:`oiiotool` help (`oiiotool --help`), at the very 3302bottom you will see the list of all color spaces, looks, and displays that 3303:program:`oiiotool` knows about. 3304 3305.. option:: --iscolorspace <colorspace> 3306 3307 Alter the metadata of the current image so that it thinks its pixels are 3308 in the named color space. This does not alter the pixels of the image, 3309 it only changes :program:`oiiotool`'s understanding of what color space 3310 those those pixels are in. 3311 3312.. option:: --colorconfig <filename> 3313 3314 Instruct :program:`oiiotool` to read an OCIO configuration from a custom 3315 location. Without this, the default is to use the `$OCIO` environment 3316 variable as a guide for the location of the configuration file. 3317 3318.. option:: --colorconvert <fromspace tospace> 3319 3320 Replace the current image with a new image whose pixels are transformed 3321 from the named *fromspace* color space into the named *tospace* 3322 (disregarding any notion it may have previously had about the color 3323 space of the current image). Optional appended modifiers include: 3324 3325 - `key=` *name*, `value=` *str* : 3326 3327 Adds a key/value pair to the "context" that OpenColorIO will used 3328 when applying the look. Multiple key/value pairs may be specified by 3329 making each one a comma-separated list. 3330 3331 - `unpremult=` *val* : 3332 3333 If the numeric *val* is nonzero, the pixel values will be 3334 "un-premultipled" (divided by alpha) prior to the actual color 3335 conversion, and then re-multipled by alpha afterwards. The default is 3336 0, meaning the color transformation not will be automatically 3337 bracketed by divide-by-alpha / mult-by-alpha operations. 3338 3339 - `strict=` *val* : 3340 3341 When nonzero (the default), an inability to perform the color 3342 transform will be a hard error. If strict is 0, inability to find the 3343 transformation will just print a warning and simply copy the image 3344 without changing colors. 3345 3346 `:subimages=` *indices-or-names* 3347 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 3348 3349.. option:: --tocolorspace <tospace> 3350 3351 Replace the current image with a new image whose pixels are transformed 3352 from their existing color space (as best understood or guessed by OIIO) 3353 into the named *tospace*. This is equivalent to a use of 3354 `oiiotool --colorconvert` where the *fromspace* is automatically deduced. 3355 3356 Optional appended modifiers include: 3357 3358 `:subimages=` *indices-or-names* 3359 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 3360 3361.. option:: --ccmatrix <m00,m01,...> 3362 3363 **NEW 2.1** 3364 3365 Replace the current image with a new image whose colors are transformed 3366 according to the 3x3 or 4x4 matrix formed from the 9 or 16 3367 comma-separated floating-point values in the subsequent argument (spaces 3368 are allowed only if the whole collection of values is enclosed in quotes 3369 so that they are a single command-line argument). 3370 3371 The values fill in the matrix left to right, first row, then second row, 3372 etc. This means that colors are treated as "row vectors" that are 3373 post-multiplied by the matrix (`C*M`). 3374 3375 Optional appended modifiers include: 3376 3377 - `unpremult=` *val* : 3378 3379 If the numeric *val* is nonzero, the pixel values will be 3380 "un-premultipled" (divided by alpha) prior to the actual color 3381 conversion, and then re-multipled by alpha afterwards. The default is 3382 0, meaning the color transformation not will be automatically 3383 bracketed by divide-by-alpha / mult-by-alpha operations. 3384 3385 - `invert=` *val* : 3386 3387 If nonzero, this will cause the matrix to be inverted before being 3388 applied. 3389 3390 - `transpose=` *val* : 3391 3392 If nonzero, this will cause the matrix to be transposed (this allowing 3393 you to more easily specify it as if the color values were column 3394 vectors and the transformation as `M*C`). 3395 3396 `:subimages=` *indices-or-names* 3397 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 3398 3399 Example:: 3400 3401 # Convert ACES to ACEScg using a matrix 3402 oiiotool aces.exr --ccmatrix:transpose=1 \ 3403 "1.454,-0.237,-0.215,-0.077,1.176,-0.010,0.008,-0.006, 0.998" \ 3404 -o acescg.exr 3405 3406.. option:: --ociolook <lookname> 3407 3408 Replace the current image with a new image whose pixels are transformed 3409 using the named OpenColorIO look description. Optional appended 3410 arguments include: 3411 3412 - `from=` *val* 3413 3414 Assume the image is in the named color space. If no `from=` is 3415 supplied, it will try to deduce it from the image's metadata or 3416 previous `--iscolorspace` directives. If no such hints are available, 3417 it will assume the pixel data are in the default linear scene-referred 3418 color space. 3419 3420 - `to=` *val* 3421 3422 Convert to the named space after applying the look. 3423 3424 - `inverse=` *val* 3425 3426 If *val* is nonzero, inverts the color transformation and look 3427 application. 3428 3429 - `key=` *name*, `value=` *str* 3430 3431 Adds a key/value pair to the "context" that OpenColorIO will used 3432 when applying the look. Multiple key/value pairs may be specified by 3433 making each one a comma-separated list. 3434 3435 - `unpremult=` *val* : 3436 3437 If the numeric *val* is nonzero, the pixel values will be 3438 "un-premultipled" (divided by alpha) prior to the actual color 3439 conversion, and then re-multipled by alpha afterwards. The default is 3440 0, meaning the color transformation not will be automatically 3441 bracketed by divide-by-alpha / mult-by-alpha operations. 3442 3443 `:subimages=` *indices-or-names* 3444 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 3445 3446 This command is only meaningful if OIIO was compiled with OCIO support 3447 and the environment variable `$OCIO` is set to point to a valid 3448 OpenColorIO configuration file. If you ask for :program:`oiiotool` help 3449 (`oiiotool --help`), at the very bottom you will see the list of all 3450 looks that :program:`oiiotool` knows about. 3451 3452 Examples:: 3453 3454 oiiotool in.jpg --ociolook:from=vd8:to=vd8:key=SHOT:value=pe0012 match -o cc.jpg 3455 3456 3457 3458.. option:: --ociodisplay <displayname> <viewname> 3459 3460 Replace the current image with a new image whose pixels are transformed 3461 using the named OpenColorIO "display" transformation given by the 3462 *displayname* and *viewname*. An empty string for *displayname* 3463 means to use the default display, and an empty string for *viewname* 3464 means to use the default view on that display. 3465 3466 Optional appended modifiers include: 3467 3468 `from=` *val* 3469 Assume the image is in the named color space. If no `from=` is 3470 supplied, it will try to deduce it from the image's metadata or 3471 previous `--iscolorspace` directives. If no such hints are 3472 available, it will assume the pixel data are in the default linear 3473 scene-referred color space. 3474 3475 `key=` *name*, `value=` *str* 3476 Adds a key/value pair to the "context" that OpenColorIO will used 3477 when applying the look. Multiple key/value pairs may be specified by 3478 making each one a comma-separated list. 3479 3480 `unpremult=` *val* : 3481 If the numeric *val* is nonzero, the pixel values will be 3482 "un-premultipled" (divided by alpha) prior to the actual color 3483 conversion, and then re-multipled by alpha afterwards. The default 3484 is 0, meaning the color transformation not will be automatically 3485 bracketed by divide-by-alpha / mult-by-alpha operations. 3486 3487 `:subimages=` *indices-or-names* 3488 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 3489 3490 This command is only meaningful if OIIO was compiled with OCIO support 3491 and the environment variable `$OCIO` is set to point to a valid 3492 OpenColorIO configuration file. If you ask for :program:`oiiotool` help 3493 (`oiiotool --help`), at the very bottom you will see the list of all 3494 looks that :program:`oiiotool` knows about. 3495 3496 Examples:: 3497 3498 oiiotool in.exr --ociodisplay:from=lnf:key=SHOT:value=pe0012 sRGB Film -o cc.jpg 3499 3500 3501.. option:: --ociofiletransform <name> 3502 3503 Replace the current image with a new image whose pixels are transformed 3504 using the named OpenColorIO file transform. Optional appended arguments 3505 include: 3506 3507 - `inverse=` *val* : 3508 3509 If *val* is nonzero, inverts the color transformation. 3510 3511 - `unpremult=` *val* : 3512 3513 If the numeric *val* is nonzero, the pixel values will be 3514 "un-premultipled" (divided by alpha) prior to the actual color 3515 conversion, and then re-multipled by alpha afterwards. The default is 3516 0, meaning the color transformation not will be automatically 3517 bracketed by divide-by-alpha / mult-by-alpha operations. 3518 3519 `:subimages=` *indices-or-names* 3520 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 3521 3522 This command is only meaningful if OIIO was compiled with OCIO support 3523 and the environment variable `$OCIO` is set to point to a valid 3524 OpenColorIO configuration file. If you ask for :program:`oiiotool` help 3525 (`oiiotool --help`), at the very bottom you will see the list of all 3526 looks that :program:`oiiotool` knows about. 3527 3528 Examples:: 3529 3530 oiiotool in.jpg --ociofiletransform footransform.csp -o out.jpg 3531 3532.. option:: --unpremult 3533 3534 Divide all color channels (those not alpha or z) of the current image by 3535 the alpha value, to "un-premultiply" them. This presumes that the image 3536 starts of as "associated alpha," a.k.a. "premultipled." Pixels in which 3537 the alpha channel is 0 will not be modified (since the operation is 3538 undefined in that case). This is a no-op if there is no identified 3539 alpha channel. 3540 3541 Optional appended modifiers include: 3542 3543 `:subimages=` *indices-or-names* 3544 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 3545 3546.. option:: --premult 3547 3548 Multiply all color channels (those not alpha or z) of the current image 3549 by the alpha value, to "premultiply'' them. This presumes that the 3550 image starts of as "unassociated alpha,'' a.k.a. "non-premultipled." 3551 3552 Optional appended modifiers include: 3553 3554 `:subimages=` *indices-or-names* 3555 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 3556 3557 3558| 3559 3560:program:`oiiotool` commands for deep images 3561============================================ 3562 3563A number of :program:`oiiotool` operations are designed to work with "deep" 3564images. These are detailed below. In general, operations not listed in this 3565section should not be expected to work with deep images. 3566 3567Commands specific to deep images 3568-------------------------------- 3569 3570.. option:: --deepen 3571 3572 If the top image is not deep, then turn it into the equivalent "deep" 3573 image. Pixels with non-infinite $z$ or with any non-zero color channels 3574 will get a single depth sample in the resulting deep image. Pixels in 3575 the source that have 0 in all channels, and either no "Z" channel or a 3576 $z$ value indicating an infinite distance, will result in a pixel with 3577 no depth samples. 3578 3579 Optional appended modifiers include: 3580 3581 `z=` *val* 3582 The depth to use for deep samples if the source image did not have a 3583 "Z" channel. (The default is 1.0.) 3584 3585 `:subimages=` *indices-or-names* 3586 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 3587 3588.. option:: --flatten 3589 3590 If the top image is "deep," then "flatten" it by compositing the depth 3591 samples in each pixel. 3592 3593 Optional appended modifiers include: 3594 3595 `:subimages=` *indices-or-names* 3596 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 3597 3598.. option:: --deepmerge 3599 3600 Replace the *two* top images with a new deep image that is the "deep 3601 merge" of the inputs. Both input images must be deep images, have the 3602 same number and order of channels and must contain an alpha channel and 3603 depth channel. 3604 3605 Optional appended modifiers include: 3606 3607 `:subimages=` *indices-or-names* 3608 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 3609 3610.. option:: --deepholdout 3611 3612 Replace the *two* top images with a new deep image that is the ``deep 3613 holdout'' of the first image by the second --- that is, the samples from 3614 the first image that are closer than the opaque frontier of the second 3615 image. Both input inputs must be deep images. 3616 3617 Optional appended modifiers include: 3618 3619 `:subimages=` *indices-or-names* 3620 Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). 3621 3622| 3623 3624General commands that also work for deep images 3625----------------------------------------------- 3626 3627 3628.. option:: --addc, --subc, --mulc, --divc 3629 3630 Adding, subtracting, multiplying, or dividing a per-channel constant 3631 will work for deep images, performing the operation for every sample in 3632 the image. 3633 3634.. option:: --autotrim 3635 3636 For subsequent outputs, automatically `--trim` before writing the file. 3637 3638.. option:: --ch <channellist> 3639 3640 Reorder, rename, remove, or add channels to a deep image. 3641 See Section :ref:`sec-oiiotool-shuffle-channels-or-subimages` 3642 3643 3644.. option:: --crop <size> 3645 3646 Crop (adjust the pixel data window), removing pixels or adding empty 3647 pixels as needed. 3648 3649.. option:: --paste <position> 3650 3651 Replace one image's pixels with another's (at an arbitary offset). 3652 3653 (This functionality was extended to deep images in OIIO 2.1.) 3654 3655.. option:: --resample <size> 3656 3657 Resampling (resize without filtering or interpolation, just choosing the 3658 closest deep pixel to copy for each output pixel). 3659 3660.. option:: --diff 3661 3662 Report on the difference of the top two images. 3663 3664.. option:: --dumpdata 3665 3666 Print to the console detailed information about the values in every pixel. 3667 3668 Optional appended modifiers include: 3669 3670 - `empty=` *val* : If 0, will cause deep images to skip printing of 3671 information about pixels with no samples, and cause non-deep images to 3672 skip printing information about pixels that are entirely 0.0 value in 3673 all channels. 3674 3675.. option:: --info 3676 3677 Prints information about each input image as it is read. 3678 3679.. option:: --trim 3680 3681 Replace the current image with a new image that is cropped to contain 3682 the minimal rectangular ROI that contains all of the non-empty pixels of 3683 the original image. 3684 3685.. option:: --scanline 3686 --tile <x> <y> 3687 3688 Convert to scanline or to tiled representations upon output. 3689 3690.. option:: --stats 3691 3692 Prints detailed statistical information about each input image as it is 3693 read. 3694 3695.. option:: --fixnan <streategy> 3696 3697 Replace the top image with a copy in which any pixels that contained 3698 `NaN` or `Inf` values (hereafter referred to collectively as 3699 "nonfinite") are repaired. The *strategy* may be either `black` or 3700 `error`. 3701 3702 3703 3704 3705