diff --git a/Tests/test_lib_pack.py b/Tests/test_lib_pack.py index 771c5d5c8..0155c4bb4 100644 --- a/Tests/test_lib_pack.py +++ b/Tests/test_lib_pack.py @@ -339,6 +339,10 @@ class TestLibUnpack(PillowTestCase): self.assert_unpack("RGBX", "RGB;4B", 2, (17,0,34,X), (51,0,68,X)) self.assert_unpack("RGBX", "RGBX", 4, (1,2,3,4), (5,6,7,8), (9,10,11,12)) + self.assert_unpack("RGBX", "RGBXX", 5, + (1,2,3,4), (6,7,8,9), (11,12,13,14)) + self.assert_unpack("RGBX", "RGBXXX", 6, + (1,2,3,4), (7,8,9,10), (13,14,15,16)) self.assert_unpack("RGBX", "RGBX;L", 4, (1,4,7,10), (2,5,8,11), (3,6,9,12)) self.assert_unpack("RGBX", "RGBX;16L", 8, (2,4,6,8), (10,12,14,16)) @@ -355,7 +359,12 @@ class TestLibUnpack(PillowTestCase): self.assert_unpack("RGBX", "X", 1, (0,0,0,1), (0,0,0,2), (0,0,0,3)) def test_CMYK(self): - self.assert_unpack("CMYK", "CMYK", 4, (1,2,3,4), (5,6,7,8), (9,10,11,12)) + self.assert_unpack("CMYK", "CMYK", 4, + (1,2,3,4), (5,6,7,8), (9,10,11,12)) + self.assert_unpack("CMYK", "CMYKX", 5, + (1,2,3,4), (6,7,8,9), (11,12,13,14)) + self.assert_unpack("CMYK", "CMYKXX", 6, + (1,2,3,4), (7,8,9,10), (13,14,15,16)) self.assert_unpack("CMYK", "CMYK;I", 4, (254,253,252,251), (250,249,248,247), (246,245,244,243)) self.assert_unpack("CMYK", "CMYK;L", 4, @@ -376,8 +385,10 @@ class TestLibUnpack(PillowTestCase): def test_YCbCr(self): self.assert_unpack("YCbCr", "YCbCr", 3, (1,2,3), (4,5,6), (7,8,9)) self.assert_unpack("YCbCr", "YCbCr;L", 3, (1,4,7), (2,5,8), (3,6,9)) - self.assert_unpack("YCbCr", "YCbCrX", 4, (1,2,3), (5,6,7), (9,10,11)) self.assert_unpack("YCbCr", "YCbCrK", 4, (1,2,3), (5,6,7), (9,10,11)) + self.assert_unpack("YCbCr", "YCbCrX", 4, (1,2,3), (5,6,7), (9,10,11)) + self.assert_unpack("YCbCr", "YCbCrXX", 5, (1,2,3), (6,7,8), (11,12,13)) + self.assert_unpack("YCbCr", "YCbCrXXX", 6, (1,2,3), (7,8,9), (13,14,15)) def test_LAB(self): self.assert_unpack("LAB", "LAB", 3, diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py index db3eaa50e..17f456930 100644 --- a/src/PIL/TiffImagePlugin.py +++ b/src/PIL/TiffImagePlugin.py @@ -194,6 +194,10 @@ OPEN_INFO = { (MM, 2, (1,), 1, (8, 8, 8, 8), ()): ("RGBA", "RGBA"), # missing ExtraSamples (II, 2, (1,), 1, (8, 8, 8, 8), (0,)): ("RGBX", "RGBX"), (MM, 2, (1,), 1, (8, 8, 8, 8), (0,)): ("RGBX", "RGBX"), + (II, 2, (1,), 1, (8, 8, 8, 8, 8), (0, 0)): ("RGBX", "RGBXX"), + (MM, 2, (1,), 1, (8, 8, 8, 8, 8), (0, 0)): ("RGBX", "RGBXX"), + (II, 2, (1,), 1, (8, 8, 8, 8, 8, 8), (0, 0, 0)): ("RGBX", "RGBXXX"), + (MM, 2, (1,), 1, (8, 8, 8, 8, 8, 8), (0, 0, 0)): ("RGBX", "RGBXXX"), (II, 2, (1,), 1, (8, 8, 8, 8), (1,)): ("RGBA", "RGBa"), (MM, 2, (1,), 1, (8, 8, 8, 8), (1,)): ("RGBA", "RGBa"), (II, 2, (1,), 1, (8, 8, 8, 8), (2,)): ("RGBA", "RGBA"), @@ -233,9 +237,19 @@ OPEN_INFO = { (II, 5, (1,), 1, (8, 8, 8, 8), ()): ("CMYK", "CMYK"), (MM, 5, (1,), 1, (8, 8, 8, 8), ()): ("CMYK", "CMYK"), + (II, 5, (1,), 1, (8, 8, 8, 8, 8), (0,)): ("CMYK", "CMYKX"), + (MM, 5, (1,), 1, (8, 8, 8, 8, 8), (0,)): ("CMYK", "CMYKX"), + (II, 5, (1,), 1, (8, 8, 8, 8, 8, 8), (0, 0)): ("CMYK", "CMYKXX"), + (MM, 5, (1,), 1, (8, 8, 8, 8, 8, 8), (0, 0)): ("CMYK", "CMYKXX"), (II, 6, (1,), 1, (8, 8, 8), ()): ("YCbCr", "YCbCr"), (MM, 6, (1,), 1, (8, 8, 8), ()): ("YCbCr", "YCbCr"), + (II, 6, (1,), 1, (8, 8, 8, 8), (0,)): ("YCbCr", "YCbCrX"), + (MM, 6, (1,), 1, (8, 8, 8, 8), (0,)): ("YCbCr", "YCbCrX"), + (II, 6, (1,), 1, (8, 8, 8, 8, 8), (0, 0)): ("YCbCr", "YCbCrXXX"), + (MM, 6, (1,), 1, (8, 8, 8, 8, 8), (0, 0)): ("YCbCr", "YCbCrXXX"), + (II, 6, (1,), 1, (8, 8, 8, 8, 8, 8), (0, 0, 0)): ("YCbCr", "YCbCrXXX"), + (MM, 6, (1,), 1, (8, 8, 8, 8, 8, 8), (0, 0, 0)): ("YCbCr", "YCbCrXXX"), (II, 8, (1,), 1, (8, 8, 8), ()): ("LAB", "LAB"), (MM, 8, (1,), 1, (8, 8, 8), ()): ("LAB", "LAB"), diff --git a/src/libImaging/Unpack.c b/src/libImaging/Unpack.c index 691eec7c1..036cec5e4 100644 --- a/src/libImaging/Unpack.c +++ b/src/libImaging/Unpack.c @@ -1041,6 +1041,28 @@ copy4(UINT8* out, const UINT8* in, int pixels) memcpy(out, in, 4 * pixels); } +static void +copy4skip1(UINT8* _out, const UINT8* in, int pixels) +{ + int i; + UINT32* out = (UINT32*) _out; + for (i = 0; i < pixels; i++) { + out[i] = *(UINT32*)&in[0]; + in += 5; + } +} + +static void +copy4skip2(UINT8* _out, const UINT8* in, int pixels) +{ + int i; + UINT32* out = (UINT32*) _out; + for (i = 0; i < pixels; i++) { + out[i] = *(UINT32*)&in[0]; + in += 6; + } +} + /* Unpack to "I" and "F" images */ @@ -1330,6 +1352,8 @@ static struct { {"RGBX", "RGB;4B", 16, ImagingUnpackRGB4B}, {"RGBX", "BGR;5", 16, ImagingUnpackBGR15}, /* compat */ {"RGBX", "RGBX", 32, copy4}, + {"RGBX", "RGBXX", 40, copy4skip1}, + {"RGBX", "RGBXXX", 48, copy4skip2}, {"RGBX", "RGBX;L", 32, unpackRGBAL}, {"RGBX", "RGBX;16L", 64, unpackRGBA16L}, {"RGBX", "RGBX;16B", 64, unpackRGBA16B}, @@ -1344,6 +1368,8 @@ static struct { /* colour separation */ {"CMYK", "CMYK", 32, copy4}, + {"CMYK", "CMYKX", 40, copy4skip1}, + {"CMYK", "CMYKXX", 48, copy4skip2}, {"CMYK", "CMYK;I", 32, unpackCMYKI}, {"CMYK", "CMYK;L", 32, unpackRGBAL}, {"CMYK", "C", 8, band0}, @@ -1359,6 +1385,8 @@ static struct { {"YCbCr", "YCbCr", 24, ImagingUnpackRGB}, {"YCbCr", "YCbCr;L", 24, unpackRGBL}, {"YCbCr", "YCbCrX", 32, copy4}, + {"YCbCr", "YCbCrXX", 40, copy4skip1}, + {"YCbCr", "YCbCrXXX", 48, copy4skip2}, {"YCbCr", "YCbCrK", 32, copy4}, /* LAB Color */