Skip to content

Commit

Permalink
Merge pull request #1871 from wiredfool/pr_1865
Browse files Browse the repository at this point in the history
Rebased #1865 + 1 test
  • Loading branch information
wiredfool committed May 1, 2016
2 parents bf12965 + 6f92a5a commit 9f9436c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions PIL/Image.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ def isImageType(t):
# official modes
"1": ('|b1', None), # broken
"L": ('|u1', None),
"LA": ('|u1', 2),
"I": (_ENDIAN + 'i4', None),
"F": (_ENDIAN + 'f4', None),
"P": ('|u1', None),
Expand Down Expand Up @@ -2215,6 +2216,7 @@ def fromqpixmap(im):
((1, 1), ">f4"): ("F", "F;32BF"),
((1, 1), "<f8"): ("F", "F;64F"),
((1, 1), ">f8"): ("F", "F;64BF"),
((1, 1, 2), "|u1"): ("LA", "LA"),
((1, 1, 3), "|u1"): ("RGB", "RGB"),
((1, 1, 4), "|u1"): ("RGBA", "RGBA"),
}
Expand Down
2 changes: 2 additions & 0 deletions Tests/test_image_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def test(mode):
# FIXME: wrong?
self.assertEqual(test("F"), (3, (100, 128), Image._ENDIAN + 'f4', 51200))

self.assertEqual(test("LA"), (3, (100, 128, 2), '|u1', 25600))
self.assertEqual(test("RGB"), (3, (100, 128, 3), '|u1', 38400))
self.assertEqual(test("RGBA"), (3, (100, 128, 4), '|u1', 51200))
self.assertEqual(test("RGBX"), (3, (100, 128, 4), '|u1', 51200))
Expand All @@ -35,6 +36,7 @@ def test(mode):
self.assertEqual(test("L"), ("L", (128, 100), True))
self.assertEqual(test("I"), ("I", (128, 100), True))
self.assertEqual(test("F"), ("F", (128, 100), True))
self.assertEqual(test("LA"), ("LA", (128, 100), True))
self.assertEqual(test("RGB"), ("RGB", (128, 100), True))
self.assertEqual(test("RGBA"), ("RGBA", (128, 100), True))
self.assertEqual(test("RGBX"), ("RGBA", (128, 100), True))
Expand Down
2 changes: 2 additions & 0 deletions Tests/test_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def to_image(dtype, bands=1, boolean=0):
self.assert_image(to_image(numpy.float32), "F", (10, 10))
self.assert_image(to_image(numpy.float64), "F", (10, 10))

self.assert_image(to_image(numpy.uint8, 2), "LA", (10, 10))
self.assert_image(to_image(numpy.uint8, 3), "RGB", (10, 10))
self.assert_image(to_image(numpy.uint8, 4), "RGBA", (10, 10))

Expand Down Expand Up @@ -105,6 +106,7 @@ def _to_array(mode, dtype):
modes = [("L", 'uint8'),
("I", 'int32'),
("F", 'float32'),
("LA", 'uint8'),
("RGB", 'uint8'),
("RGBA", 'uint8'),
("RGBX", 'uint8'),
Expand Down

0 comments on commit 9f9436c

Please sign in to comment.