相关疑难解决方法(0)

ImageMagick无权将PDF转换为图像

我有一个程序,我需要使用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)

python linux subprocess imagemagick

31
推荐指数
3
解决办法
1万
查看次数

Wand Policy Error:error/construct.c/ReadImage/412

我在使用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个月内处于工作状态.现在为什么我得到错误.

请帮忙.

python-3.x wand

11
推荐指数
1
解决办法
6694
查看次数

在Windows平台中将Ghostscript链接到pypdfocr

通过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)

请求帮助链接这些库需要做些什么?

windows ocr linker python-2.7 anaconda

2
推荐指数
1
解决办法
983
查看次数