@@ -434,26 +434,36 @@ def test_trns_null(self):
434434
435435 self .assertEqual (im .info ["transparency" ], 0 )
436436
437- def test_save_icc_profile_none (self ):
438- # check saving files with an ICC profile set to None (omit profile)
439- in_file = "Tests/images/icc_profile_none.png"
440- im = Image .open (in_file )
437+ def test_save_icc_profile (self ):
438+ im = Image .open ("Tests/images/icc_profile_none.png" )
441439 self .assertEqual (im .info ['icc_profile' ], None )
442440
443- im = roundtrip (im )
441+ with_icc = Image .open ("Tests/images/icc_profile.png" )
442+ expected_icc = with_icc .info ['icc_profile' ]
443+
444+ im = roundtrip (im , icc_profile = expected_icc )
445+ self .assertEqual (im .info ['icc_profile' ], expected_icc )
446+
447+ def test_discard_icc_profile (self ):
448+ im = Image .open ('Tests/images/icc_profile.png' )
449+
450+ im = roundtrip (im , icc_profile = None )
444451 self .assertNotIn ('icc_profile' , im .info )
445452
446453 def test_roundtrip_icc_profile (self ):
447- # check that we can roundtrip the icc profile
448- im = hopper ( 'RGB' )
454+ im = Image . open ( 'Tests/images/icc_profile.png' )
455+ expected_icc = im . info [ 'icc_profile' ]
449456
450- jpeg_image = Image .open ('Tests/images/flower2.jpg' )
451- expected_icc = jpeg_image .info ['icc_profile' ]
452-
453- im .info ['icc_profile' ] = expected_icc
454457 im = roundtrip (im )
455458 self .assertEqual (im .info ['icc_profile' ], expected_icc )
456459
460+ def test_roundtrip_no_icc_profile (self ):
461+ im = Image .open ("Tests/images/icc_profile_none.png" )
462+ self .assertEqual (im .info ['icc_profile' ], None )
463+
464+ im = roundtrip (im )
465+ self .assertNotIn ('icc_profile' , im .info )
466+
457467 def test_repr_png (self ):
458468 im = hopper ()
459469
0 commit comments