Skip to content

bug: oiiotool -otex incorrectly detects any image as constant color #5243

@SitiSchu

Description

@SitiSchu

Note: With some additional debugging I may have found the cause for this, I've added it as seperate comment below.

Describe the bug
Running oiiotool with -otex:constant_color_detect=1 seems to consider any image regardless of its content as constant color. maketx does it correctly.

$ oiiotool --create 4096x4096 3 --pattern noise 4096x4096 3 -o noise.exr

$ oiiotool -v noise.exr -otex:constant_color_detect=1 noise_oiiotool.tx
[...]
  Constant color image detected. Creating 64x64 texture instead.
[...]
  Top level is 64x64
    64x64           (228.9 MB)  write 0.02s
  Mipmapping...
    32x32           (228.9 MB)  downres 0.00s write 0.00s
    16x16           (228.9 MB)  downres 0.00s write 0.01s
    8x8             (228.9 MB)  downres 0.00s write 0.01s
    4x4             (228.9 MB)  downres 0.00s write 0.01s
    2x2             (228.9 MB)  downres 0.00s write 0.02s
    1x1             (228.9 MB)  downres 0.00s write 0.01s
[...]

The resulting image will only have 64x64 and lower tiles:

$ magick identify ./noise_oiiotool.tx
./noise_oiiotool.tx[0] TIFF 64x64 64x64+0+0 32-bit sRGB 3165B 0.001u 0:00.000
./noise_oiiotool.tx[1] TIFF 32x32 32x32+0+0 32-bit sRGB 0.001u 0:00.000
./noise_oiiotool.tx[2] TIFF 16x16 16x16+0+0 32-bit sRGB 0.001u 0:00.001
./noise_oiiotool.tx[3] TIFF 8x8 8x8+0+0 32-bit sRGB 0.002u 0:00.001
./noise_oiiotool.tx[4] TIFF 4x4 4x4+0+0 32-bit sRGB 0.002u 0:00.001
./noise_oiiotool.tx[5] TIFF 2x2 2x2+0+0 32-bit sRGB 0.002u 0:00.002
./noise_oiiotool.tx[6] TIFF 1x1 1x1+0+0 32-bit sRGB 0.002u 0:00.002

Compared to maketx:

$ maketx -v --constant-color-detect ./noise.exr -o ./noise_maketx.tx
[...]
Top level is 4096x4096
    4096x4096       (228.1 MB)  write 4.12s
  Mipmapping...
    2048x2048       (278.4 MB)  downres 0.02s write 1.17s
    1024x1024       (98.1 MB)  downres 0.02s write 0.30s
    512x512         (54.5 MB)  downres 0.01s write 0.08s
    256x256         (43.3 MB)  downres 0.00s write 0.03s
    128x128         (40.9 MB)  downres 0.00s write 0.02s
    64x64           (40.9 MB)  downres 0.00s write 0.01s
    32x32           (40.9 MB)  downres 0.00s write 0.01s
    16x16           (40.9 MB)  downres 0.00s write 0.01s
    8x8             (40.9 MB)  downres 0.00s write 0.01s
    4x4             (40.9 MB)  downres 0.00s write 0.01s
    2x2             (40.9 MB)  downres 0.00s write 0.01s
    1x1             (40.9 MB)  downres 0.00s write 0.01s
[...]

And to show that it's not just maketx not doing it correctly, the same with a constant color image:

Commands & Output
$ oiiotool --create 4096x4096 3 --pattern constant:color=1.0,0.5,0.3 4096x4096 3 -o constant_color.exr

$ oiiotool -v constant_color.exr -otex:constant_color_detect=1 constant_oiiotool.tx
[...]
  Constant color image detected. Creating 64x64 texture instead.
[...]
  Top level is 64x64
    64x64           (231.5 MB)  write 0.02s
  Mipmapping...
    32x32           (231.5 MB)  downres 0.00s write 0.01s
    16x16           (231.5 MB)  downres 0.00s write 0.01s
    8x8             (231.5 MB)  downres 0.00s write 0.01s
    4x4             (231.5 MB)  downres 0.00s write 0.01s
    2x2             (231.5 MB)  downres 0.00s write 0.01s
    1x1             (231.5 MB)  downres 0.00s write 0.01s
[...]

$ maketx -v --constant-color-detect ./constant_color.exr -o ./constant_maketx.tx
[...]
  Constant color image detected. Creating 64x64 texture instead.
[...]
  Top level is 64x64
    64x64           (36.3 MB)  write 0.02s
  Mipmapping...
    32x32           (36.3 MB)  downres 0.00s write 0.01s
    16x16           (36.3 MB)  downres 0.00s write 0.01s
    8x8             (36.3 MB)  downres 0.00s write 0.01s
    4x4             (36.3 MB)  downres 0.00s write 0.01s
    2x2             (36.3 MB)  downres 0.00s write 0.01s
    1x1             (36.3 MB)  downres 0.00s write 0.01s
[...]

OpenImageIO version and dependencies

OIIO 3.1.13.1 | Windows/x86_64
    Build compiler: MSVS 1937 | C++17/199711
    HW features enabled at build: sse2
    No CUDA support (disabled / unavailable at build time)
Dependencies: BZip2 NONE, expat 2.6.3, fmt 12.1.0, Freetype 2.14.1, Imath 3.1.10, JPEG 80, libdeflate 1.23, Libheif NONE, libjpeg-turbo 3.1.2, LibRaw NONE, libuhdr 1.4.0, minizip-ng 4.0.10, OpenColorIO 2.5.1, OpenEXR 3.3.5, OpenGL, OpenJPEG 2.5.4, openjph NONE,
    PNG 1.6.50, Ptex NONE, Ptex NONE, pystring NONE, Qt5 NONE, Qt6 NONE, Robinmap 1.4.0, TIFF 4.7.1, WebP 1.6.0, yaml-cpp 0.8.0, ZLIB 1.3.1, ZLIB 1.3.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions