Skip to content

Commit 4363507

Browse files
authored
Merge pull request #4608 from radarhere/numpy
2 parents ba58ae7 + 59957fb commit 4363507

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

Tests/test_numpy.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ def test_3d_array():
8989
assert_image(Image.fromarray(a[:, :, 1]), "L", TEST_IMAGE_SIZE)
9090

9191

92+
def test_1d_array():
93+
a = numpy.ones(5, dtype=numpy.uint8)
94+
assert_image(Image.fromarray(a), "L", (1, 5))
95+
96+
9297
def _test_img_equals_nparray(img, np):
9398
assert len(np.shape) >= 2
9499
np_size = np.shape[1], np.shape[0]

src/PIL/Image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2751,7 +2751,7 @@ def fromarray(obj, mode=None):
27512751
if ndim > ndmax:
27522752
raise ValueError("Too many dimensions: %d > %d." % (ndim, ndmax))
27532753

2754-
size = shape[1], shape[0]
2754+
size = 1 if ndim == 1 else shape[1], shape[0]
27552755
if strides is not None:
27562756
if hasattr(obj, "tobytes"):
27572757
obj = obj.tobytes()

0 commit comments

Comments
 (0)