From ad5cf0a0e24dbfa942e685ba89416b307562463f Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 5 Sep 2018 17:36:27 +0300 Subject: [PATCH] Add RGBAX and RGBAXX tiff modes --- Tests/test_lib_pack.py | 4 ++++ src/PIL/TiffImagePlugin.py | 4 ++++ src/libImaging/Unpack.c | 2 ++ 3 files changed, 10 insertions(+) diff --git a/Tests/test_lib_pack.py b/Tests/test_lib_pack.py index 002db2e19..921af3bea 100644 --- a/Tests/test_lib_pack.py +++ b/Tests/test_lib_pack.py @@ -273,6 +273,10 @@ class TestLibUnpack(PillowTestCase): (1, 1, 1, 3), (5, 5, 5, 7), (9, 9, 9, 11)) self.assert_unpack("RGBA", "RGBA", 4, (1, 2, 3, 4), (5, 6, 7, 8), (9, 10, 11, 12)) + self.assert_unpack("RGBA", "RGBAX", 5, + (1, 2, 3, 4), (6, 7, 8, 9), (11, 12, 13, 14)) + self.assert_unpack("RGBA", "RGBAXX", 6, + (1, 2, 3, 4), (7, 8, 9, 10), (13, 14, 15, 16)) self.assert_unpack("RGBA", "RGBa", 4, (63, 127, 191, 4), (159, 191, 223, 8), (191, 212, 233, 12)) self.assert_unpack("RGBA", "RGBa", diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py index 6f032f49d..17b133c82 100644 --- a/src/PIL/TiffImagePlugin.py +++ b/src/PIL/TiffImagePlugin.py @@ -210,6 +210,10 @@ OPEN_INFO = { (MM, 2, (1,), 1, (8, 8, 8, 8), (1,)): ("RGBA", "RGBa"), (II, 2, (1,), 1, (8, 8, 8, 8), (2,)): ("RGBA", "RGBA"), (MM, 2, (1,), 1, (8, 8, 8, 8), (2,)): ("RGBA", "RGBA"), + (II, 2, (1,), 1, (8, 8, 8, 8, 8), (2, 0)): ("RGBA", "RGBAX"), + (MM, 2, (1,), 1, (8, 8, 8, 8, 8), (2, 0)): ("RGBA", "RGBAX"), + (II, 2, (1,), 1, (8, 8, 8, 8, 8, 8), (2, 0, 0)): ("RGBA", "RGBAXX"), + (MM, 2, (1,), 1, (8, 8, 8, 8, 8, 8), (2, 0, 0)): ("RGBA", "RGBAXX"), (II, 2, (1,), 1, (8, 8, 8, 8), (999,)): ("RGBA", "RGBA"), # Corel Draw 10 (MM, 2, (1,), 1, (8, 8, 8, 8), (999,)): ("RGBA", "RGBA"), # Corel Draw 10 diff --git a/src/libImaging/Unpack.c b/src/libImaging/Unpack.c index 05b4299b0..04e05dcb3 100644 --- a/src/libImaging/Unpack.c +++ b/src/libImaging/Unpack.c @@ -1301,6 +1301,8 @@ static struct { {"RGBA", "LA", 16, unpackRGBALA}, {"RGBA", "LA;16B", 32, unpackRGBALA16B}, {"RGBA", "RGBA", 32, copy4}, + {"RGBA", "RGBAX", 40, copy4skip1}, + {"RGBA", "RGBAXX", 48, copy4skip2}, {"RGBA", "RGBa", 32, unpackRGBa}, {"RGBA", "RGBa;16L", 64, unpackRGBa16L}, {"RGBA", "RGBa;16B", 64, unpackRGBa16B},