Skip to content

Commit eabfc26

Browse files
committed
Fix issue with large PNG images in PDF.
PNGs separate large images into chunks, but PDFs do not.
1 parent eb74d35 commit eabfc26

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/matplotlib/backends/backend_pdf.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,7 +1529,8 @@ def _writePng(self, img):
15291529
buffer = BytesIO()
15301530
img.save(buffer, format="png")
15311531
buffer.seek(8)
1532-
png_data = bit_depth = palette = None
1532+
png_data = b''
1533+
bit_depth = palette = None
15331534
while True:
15341535
length, type = struct.unpack(b'!L4s', buffer.read(8))
15351536
if type in [b'IHDR', b'PLTE', b'IDAT']:
@@ -1541,7 +1542,7 @@ def _writePng(self, img):
15411542
elif type == b'PLTE':
15421543
palette = data
15431544
elif type == b'IDAT':
1544-
png_data = data
1545+
png_data += data
15451546
elif type == b'IEND':
15461547
break
15471548
else:

0 commit comments

Comments
 (0)