23
23
write_image_Imageio ,
24
24
write_image_OpenImageIO ,
25
25
)
26
- from colour .utilities import attest , full , is_openimageio_installed
26
+ from colour .utilities import attest , full
27
27
28
28
__author__ = "Colour Developers"
29
29
__copyright__ = "Copyright 2013 Colour Developers"
@@ -60,9 +60,6 @@ def test_image_specification_OpenImageIO(self) -> None: # pragma: no cover
60
60
definition.
61
61
"""
62
62
63
- if not is_openimageio_installed ():
64
- return
65
-
66
63
from OpenImageIO import HALF # pyright: ignore
67
64
68
65
compression = Image_Specification_Attribute ("Compression" , "none" )
@@ -275,9 +272,6 @@ class TestReadImageOpenImageIO:
275
272
def test_read_image_OpenImageIO (self ) -> None : # pragma: no cover
276
273
"""Test :func:`colour.io.image.read_image_OpenImageIO` definition."""
277
274
278
- if not is_openimageio_installed ():
279
- return
280
-
281
275
image = read_image_OpenImageIO (
282
276
os .path .join (ROOT_RESOURCES , "CMS_Test_Pattern.exr" ),
283
277
additional_data = False ,
@@ -362,9 +356,6 @@ def teardown_method(self) -> None:
362
356
def test_write_image_OpenImageIO (self ) -> None : # pragma: no cover
363
357
"""Test :func:`colour.io.image.write_image_OpenImageIO` definition."""
364
358
365
- if not is_openimageio_installed ():
366
- return
367
-
368
359
from OpenImageIO import TypeDesc # pyright: ignore
369
360
370
361
path = os .path .join (self ._temporary_directory , "8-bit.png" )
@@ -380,27 +371,30 @@ def test_write_image_OpenImageIO(self) -> None: # pragma: no cover
380
371
np .testing .assert_equal (np .squeeze (RGB ), image )
381
372
382
373
source_path = os .path .join (ROOT_RESOURCES , "Overflowing_Gradient.png" )
374
+ source_image = read_image_OpenImageIO (source_path , bit_depth = "uint8" )
383
375
target_path = os .path .join (
384
376
self ._temporary_directory , "Overflowing_Gradient.png"
385
377
)
386
378
RGB = np .arange (0 , 256 , 1 , dtype = np .uint8 )[None ] * 2
387
379
write_image_OpenImageIO (RGB , target_path , bit_depth = "uint8" )
388
- image = read_image_OpenImageIO (source_path , bit_depth = "uint8" )
389
- np .testing .assert_equal (np .squeeze (RGB ), image )
380
+ target_image = read_image_OpenImageIO (source_path , bit_depth = "uint8" )
381
+ np .testing .assert_equal (source_image , target_image )
382
+ np .testing .assert_equal (np .squeeze (RGB ), target_image )
390
383
391
384
source_path = os .path .join (ROOT_RESOURCES , "CMS_Test_Pattern.exr" )
392
- target_path = os .path .join (self ._temporary_directory , "CMS_Test_Pattern.exr" )
393
- image = read_image_OpenImageIO (
385
+ source_image = read_image_OpenImageIO (
394
386
source_path ,
395
387
additional_data = False ,
396
388
)
397
- write_image_OpenImageIO (image , target_path )
398
- image = read_image_OpenImageIO (
389
+ target_path = os .path .join (self ._temporary_directory , "CMS_Test_Pattern.exr" )
390
+ write_image_OpenImageIO (source_image , target_path )
391
+ target_image = read_image_OpenImageIO (
399
392
target_path ,
400
393
additional_data = False ,
401
394
)
402
- assert image .shape == (1267 , 1274 , 3 )
403
- assert image .dtype is np .dtype ("float32" )
395
+ np .testing .assert_equal (source_image , target_image )
396
+ assert target_image .shape == (1267 , 1274 , 3 )
397
+ assert target_image .dtype is np .dtype ("float32" )
404
398
405
399
chromaticities = (
406
400
0.73470 ,
@@ -419,8 +413,8 @@ def test_write_image_OpenImageIO(self) -> None: # pragma: no cover
419
413
),
420
414
Image_Specification_Attribute ("compression" , "none" ),
421
415
]
422
- write_image_OpenImageIO (image , target_path , attributes = write_attributes )
423
- image , read_attributes = read_image_OpenImageIO (
416
+ write_image_OpenImageIO (target_image , target_path , attributes = write_attributes )
417
+ target_image , read_attributes = read_image_OpenImageIO (
424
418
target_path , additional_data = True
425
419
)
426
420
for write_attribute in write_attributes :
@@ -517,35 +511,41 @@ def test_write_image_Imageio(self) -> None:
517
511
"""Test :func:`colour.io.image.write_image_Imageio` definition."""
518
512
519
513
source_path = os .path .join (ROOT_RESOURCES , "Overflowing_Gradient.png" )
514
+ source_image = read_image_Imageio (source_path , bit_depth = "uint8" )
520
515
target_path = os .path .join (
521
516
self ._temporary_directory , "Overflowing_Gradient.png"
522
517
)
523
518
RGB = np .arange (0 , 256 , 1 , dtype = np .uint8 )[None ] * 2
524
519
write_image_Imageio (RGB , target_path , bit_depth = "uint8" )
525
- image = read_image_Imageio (source_path , bit_depth = "uint8" )
526
- np .testing .assert_equal (np .squeeze (RGB ), image )
520
+ target_image = read_image_Imageio (target_path , bit_depth = "uint8" )
521
+ np .testing .assert_equal (np .squeeze (RGB ), target_image )
522
+ np .testing .assert_equal (source_image , target_image )
527
523
528
- source_path = os .path .join (ROOT_RESOURCES , "CMS_Test_Pattern.exr" )
529
- target_path = os .path .join (self ._temporary_directory , "CMS_Test_Pattern.exr" )
530
- image = read_image_Imageio (source_path )
531
- write_image_Imageio (image , target_path )
532
- image = read_image_Imageio (target_path )
533
- assert image .shape == (1267 , 1274 , 3 )
534
- assert image .dtype is np .dtype ("float32" )
535
-
536
- # NOTE: Those unit tests are breaking unpredictably on Linux, skipping
537
- # for now.
524
+ # NOTE: Those unit tests are breaking on Linux, skipping for now.
538
525
if platform .system () != "Linux" : # pragma: no cover
526
+ source_path = os .path .join (ROOT_RESOURCES , "CMS_Test_Pattern.exr" )
527
+ source_image = read_image_Imageio (source_path )
528
+ target_path = os .path .join (
529
+ self ._temporary_directory , "CMS_Test_Pattern.exr"
530
+ )
531
+ write_image_Imageio (source_image , target_path )
532
+ target_image = read_image_Imageio (target_path )
533
+ np .testing .assert_allclose (
534
+ source_image , target_image , atol = TOLERANCE_ABSOLUTE_TESTS
535
+ )
536
+ assert target_image .shape == (1267 , 1274 , 3 )
537
+ assert target_image .dtype is np .dtype ("float32" )
538
+
539
539
target_path = os .path .join (self ._temporary_directory , "Full_White.exr" )
540
- image = full ((32 , 16 , 3 ), 1e6 , dtype = np .float16 )
541
- write_image_Imageio (image , target_path )
542
- image = read_image_Imageio (target_path )
543
- assert np .max (image ) == np .inf
540
+ target_image = full ((32 , 16 , 3 ), 1e6 , dtype = np .float16 )
541
+ write_image_Imageio (target_image , target_path )
542
+ target_image = read_image_Imageio (target_path )
543
+ assert np .max (target_image ) == np .inf
544
544
545
- image = full ((32 , 16 , 3 ), 1e6 )
546
- write_image_Imageio (image , target_path )
547
- image = read_image_Imageio (target_path )
548
- assert np .max (image ) == 1e6
545
+ target_image = full ((32 , 16 , 3 ), 1e6 )
546
+ write_image_Imageio (target_image , target_path )
547
+ target_image = read_image_Imageio (target_path )
548
+ assert np .max (target_image ) == 1e6
549
549
550
550
551
551
class TestReadImage :
@@ -582,12 +582,15 @@ def test_write_image(self) -> None:
582
582
"""Test :func:`colour.io.image.write_image` definition."""
583
583
584
584
source_path = os .path .join (ROOT_RESOURCES , "CMS_Test_Pattern.exr" )
585
+ source_image = read_image (source_path )
585
586
target_path = os .path .join (self ._temporary_directory , "CMS_Test_Pattern.exr" )
586
- image = read_image (source_path )
587
- write_image (image , target_path )
588
- image = read_image (target_path )
589
- assert image .shape == (1267 , 1274 , 3 )
590
- assert image .dtype is np .dtype ("float32" )
587
+ write_image (source_image , target_path )
588
+ target_image = read_image (target_path )
589
+ np .testing .assert_allclose (
590
+ source_image , target_image , atol = TOLERANCE_ABSOLUTE_TESTS
591
+ )
592
+ assert target_image .shape == (1267 , 1274 , 3 )
593
+ assert target_image .dtype is np .dtype ("float32" )
591
594
592
595
593
596
class TestAs3ChannelsImage :
0 commit comments