Skip to content

Commit da6335a

Browse files
authored
Merge pull request #423 from Aikhjarto/fix_422
don't multiply by 255 is data is already uint8
2 parents 32a3bb9 + 4972f62 commit da6335a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tikzplotlib/_image.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ def draw_image(data, obj):
3434
img_array = numpy.flipud(img_array)
3535

3636
# Convert mpl image to PIL
37-
image = PIL.Image.fromarray(numpy.uint8(img_array * 255))
37+
if img_array.dtype != numpy.uint8:
38+
img_array = numpy.uint8(img_array * 255)
39+
image = PIL.Image.fromarray(img_array)
3840

3941
# If the input image is PIL:
4042
# image = PIL.Image.fromarray(img_array)

0 commit comments

Comments
 (0)