Skip to content

Commit

Permalink
Merge pull request #3817 from radarhere/cmyk_16l
Browse files Browse the repository at this point in the history
Added reading of CMYK;16L TIFF images
  • Loading branch information
hugovk committed May 4, 2019
2 parents d45a13d + ca0d28e commit fdcacb6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
Binary file added Tests/images/tiff_strip_cmyk_16l_jpeg.tif
Binary file not shown.
6 changes: 6 additions & 0 deletions Tests/test_file_libtiff.py
Expand Up @@ -687,6 +687,12 @@ def test_strip_cmyk_jpeg(self):

self.assert_image_similar_tofile(im, "Tests/images/pil_sample_cmyk.jpg", 0.5)

def test_strip_cmyk_16l_jpeg(self):
infile = "Tests/images/tiff_strip_cmyk_16l_jpeg.tif"
im = Image.open(infile)

self.assert_image_similar_tofile(im, "Tests/images/pil_sample_cmyk.jpg", 0.5)

def test_strip_ycbcr_jpeg_2x2_sampling(self):
infile = "Tests/images/tiff_strip_ycbcr_jpeg_2x2_sampling.tif"
im = Image.open(infile)
Expand Down
2 changes: 2 additions & 0 deletions src/PIL/TiffImagePlugin.py
Expand Up @@ -263,6 +263,8 @@
(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, 5, (1,), 1, (16, 16, 16, 16), ()): ("CMYK", "CMYK;16L"),

# JPEG compressed images handled by LibTiff and auto-converted to RGBX
# Minimal Baseline TIFF requires YCbCr images to have 3 SamplesPerPixel
(II, 6, (1,), 1, (8, 8, 8), ()): ("RGB", "RGBX"),
Expand Down
1 change: 1 addition & 0 deletions src/libImaging/Unpack.c
Expand Up @@ -1417,6 +1417,7 @@ static struct {
{"CMYK", "CMYKXX", 48, copy4skip2},
{"CMYK", "CMYK;I", 32, unpackCMYKI},
{"CMYK", "CMYK;L", 32, unpackRGBAL},
{"CMYK", "CMYK;16L", 64, unpackRGBA16L},
{"CMYK", "C", 8, band0},
{"CMYK", "M", 8, band1},
{"CMYK", "Y", 8, band2},
Expand Down

0 comments on commit fdcacb6

Please sign in to comment.