Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python converting pdf to image?

Tags:

python

pdf

wand

So I'm using Wand to try to convert the pdf to an image

from wand.image import Image

with Image(filename="test.pdf") as img:
     img.save(filename="/temp.jpg")

with Image(filename="test.jpg") as img:
     img.resize(200, 150)
     img.save(filename="t.jpg")

but for some reason i get:

Traceback (most recent call last):
  File "C:\Users\Rafael\Desktop\k\pdf to image.py", line 3, in <module>
    with Image(filename="test.pdf") as img:
  File "C:\Python27\lib\site-packages\wand\image.py", line 2534, in __init__
    self.read(filename=filename, resolution=resolution)
  File "C:\Python27\lib\site-packages\wand\image.py", line 2601, in read
    self.raise_exception()
  File "C:\Python27\lib\site-packages\wand\resource.py", line 222, in raise_exception
    raise e
DelegateError: PDFDelegateFailed `The system cannot find the file specified.

' @ error/pdf.c/ReadPDFImage/798

Can i do something or is there another way to convert a pdf to an image?

like image 610
Rafas Avatar asked Oct 18 '22 09:10

Rafas


1 Answers

Installing Ghostscript and adding

C:\Program Files (x86)\gs\gs9.06\bin

to your systempath should help to resolve this issue as it helped me to overcome this error....

like image 191
Abhishek Jain Avatar answered Oct 20 '22 23:10

Abhishek Jain