diff --git a/Tests/images/lab.tif b/Tests/images/lab.tif new file mode 100644 index 000000000..7dab9b2ba Binary files /dev/null and b/Tests/images/lab.tif differ diff --git a/Tests/test_image_lab.py b/Tests/test_image_lab.py new file mode 100644 index 000000000..bbc59a2c7 --- /dev/null +++ b/Tests/test_image_lab.py @@ -0,0 +1,25 @@ +from tester import * + +from PIL import Image + +def test_sanity(): + i = Image.open('Tests/images/lab.tif') + + bits = i.load() + + assert_equal(i.mode, 'LAB') + + assert_equal(i.getbands(), ('L','A', 'B')) + + k = i.getpixel((0,0)) + assert_equal(k, (255,0,0)) + + L = i.getdata(0) + a = i.getdata(1) + b = i.getdata(2) + + assert_equal(list(L), [255]*100) + assert_equal(list(a), [0]*100) + assert_equal(list(b), [0]*100) + + diff --git a/libImaging/Pack.c b/libImaging/Pack.c index f8470fd73..d38d9e5e3 100644 --- a/libImaging/Pack.c +++ b/libImaging/Pack.c @@ -527,7 +527,7 @@ static struct { {"YCbCr", "Cr", 8, band2}, /* LAB Color */ - {"LAB", "LAB", 24, copy3}, + {"LAB", "LAB", 24, ImagingPackRGB}, {"LAB", "L", 8, band0}, {"LAB", "A", 8, band1}, {"LAB", "B", 8, band2}, diff --git a/libImaging/Storage.c b/libImaging/Storage.c index f8248a079..50259be47 100644 --- a/libImaging/Storage.c +++ b/libImaging/Storage.c @@ -182,9 +182,8 @@ ImagingNewPrologueSubtype(const char *mode, unsigned xsize, unsigned ysize, /* 24-bit color, luminance, + 2 color channels */ /* L is uint8, a,b are int8 */ im->bands = 3; - im->pixelsize = 3; - im->linesize = (xsize*4 + 3) & -4; - im->type = IMAGING_TYPE_SPECIAL; + im->pixelsize = 4; + im->linesize = xsize * 4; } else { free(im); diff --git a/libImaging/Unpack.c b/libImaging/Unpack.c index 1330f1434..e05728f49 100644 --- a/libImaging/Unpack.c +++ b/libImaging/Unpack.c @@ -965,7 +965,7 @@ static struct { {"YCbCr", "YCbCrK", 32, copy4}, /* LAB Color */ - {"LAB", "LAB", 24, copy3}, + {"LAB", "LAB", 24, ImagingUnpackRGB}, {"LAB", "L", 8, band0}, {"LAB", "A", 8, band1}, {"LAB", "B", 8, band2},