我有一个程序,我需要使用Image Magick将PDF转换为图像.我这样做是使用subprocess包:
cmd = 'magick convert -density 300 '+pdfFile+'['+str(rangeTuple[0])+'-'+str(rangeTuple[1])+'] -depth 8 '+'temp.tiff' #WINDOWS
if(os.path.isfile('temp.tiff')):
os.remove('temp.tiff')
subprocess.call(cmd,shell=True)
im = Image.open('temp.tiff')
Run Code Online (Sandbox Code Playgroud)
我得到的错误是:
convert-im6.q16: not authorized `temp2.pdf' @ error/constitute.c/ReadImage/412.
convert-im6.q16: no images defined `temp.tiff' @ error/convert.c/ConvertImageCommand/3258.
Traceback (most recent call last):
File "UKExtraction2.py", line 855, in <module>
doItAllUpper("A0","UK5.csv","temp",59,70,"box",2,1000,firstPageCoordsUK,boxCoordUK,voterBoxCoordUK,internalBoxNumberCoordUK,externalBoxNumberCoordUK,addListInfoUK)
File "UKExtraction2.py", line 776, in doItAllUpper
doItAll(tempPDFName,outputCSV,2,pdfs,formatType,n_blocks,writeBlockSize,firstPageCoords,boxCoord,voterBoxCoord,internalBoxNumberCoord,externalBoxNumberCoord,addListInfo,pdfName)
File "UKExtraction2.py", line 617, in doItAll
mainProcess(pdfName,(0,noOfPages-1),formatType,n_blocks,outputCSV,writeBlockSize,firstPageCoords,boxCoord,voterBoxCoord,internalBoxNumberCoord,externalBoxNumberCoord,addListInfo,bigPDFName,basePages)
File "UKExtraction2.py", line 542, in mainProcess
im = Image.open('temp.tiff')
File "/home/rohit/.local/lib/python3.6/site-packages/PIL/Image.py", line 2609, in open
fp = builtins.open(filename, "rb") …Run Code Online (Sandbox Code Playgroud) 我在使用Wand将pdf转换为图像时遇到了这个问题:
E wand.exceptions.PolicyError: not authorized `/opt/sample.pdf' @ error/constitute.c/ReadImage/412
Run Code Online (Sandbox Code Playgroud)
我已经访问过此前的堆栈溢出问题: 转换:未授权`aaaa` @ error/construct.c/ReadImage/453
这是我的代码
def build_image(self, pdf_path, img_path):
with wand.image.Image(filename=pdf_path) as img:
img.save(filename=img_path)
Run Code Online (Sandbox Code Playgroud)
我的代码在过去6个月内处于工作状态.现在为什么我得到错误.
请帮忙.
通过pip安装安装了pypdfocr和ghostscript.但是,当在命令提示符下运行pypdfocr时:
[env27] C:\Users\888537>pypdfocr Hotel.pdf
ERROR: Could not find Ghostscript in the usual place; please specify it using your config file
Run Code Online (Sandbox Code Playgroud)
请求帮助链接这些库需要做些什么?
anaconda ×1
imagemagick ×1
linker ×1
linux ×1
ocr ×1
python ×1
python-2.7 ×1
python-3.x ×1
subprocess ×1
wand ×1
windows ×1