import os
import img2pdf
with open('1.pdf', 'wb') as f:
f.write(img2pdf.convert(['img/'+ img_name for img_name in os.listdir('img') ]))
print('转化完成')
Traceback (most recent call last):
File "D:\pythonstudypac\douin.py", line 13, in <module>
f.write(img2pdf.convert(['img/'+ img_name for img_name in os.listdir('img') ]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\pythonstudypac\venv\Lib\site-packages\img2pdf.py", line 2360, in convert
) in read_images(
^^^^^^^^^^^^
File "D:\pythonstudypac\venv\Lib\site-packages\img2pdf.py", line 1682, in read_images
pngidat, palette = parse_png(rawdata)
^^^^^^^^^^^^^^^^^^
File "D:\pythonstudypac\venv\Lib\site-packages\img2pdf.py", line 1526, in parse_png
raise Exception("invalid png: %d %d %d" % (i, n, len(rawdata)))
Exception: invalid png: 143320 640034384 143358
我运行上述代码,出现报错,不明原因,请求帮助,谢谢!