我正在使用Python PDF2Image库运行一个简单的PDF到图像的转换。我当然可以理解这个库正在越过最大内存阈值,从而得出这个错误。但是,the PDF大约是6.6MB,那么为什么抛出一个内存错误要占用GBs的内存呢?在Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from pdf2image import convert_from_path
>>> pages = convert_from_path(r'C:\Users\aakashba598\Documents\pwc-annual-report-2017-2018.pdf', 200)
Exception in thread Thread-3:
Traceback (most recent call last):
File "C:\Users\aakashba598\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 917, in _bootstrap_inner
self.run()
File "C:\Users\aakashba598\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\aakashba598\AppData\Local\Programs\Python\Python37-32\lib\subprocess.py", line 1215, in _readerthread
buffer.append(fh.read())
MemoryError
还有,有什么可能的解决办法呢?在
更新:当我从convert_-from_-path函数中减少dpi参数时,它的工作原理很有魅力。但制作的图片质量很低(原因很明显)。有办法解决这个问题吗?像一批一批的创建图像和清除内存每次。如果有办法,怎么办?在