I am trying to convert all the pages of a PDF to images and save them to a specific working directory. The code is:
from wand.image import Image
from wand.image import Image as wi
pdf = wi(filename="work.pdf", resolution=300)
pdfimage = pdf.convert("jpeg")
i=1
for img in pdfimage.sequence:
page = wi(image=img)
page.save(filename=r"C:\Users\...\work" + str(i) + ".jpg")
i +=1
As you can see, I am converting each page to jpg format and then am trying to save them in the folder. But due to some reason, it is not working. If instead of the second last line, I try:
from wand.image import Image as wi
pdf = wi(filename="work.pdf", resolution=300)
pdfimage = pdf.convert("jpeg")
i=1
for img in pdfimage.sequence:
page = wi(image=img)
#page.save(filename=r"C:\Users\...\work" + str(i) + ".jpg")
page.save(filename=str(i)+".jpg")
i +=1
then it saves successfully but in the folder C:\Users\Me. How can I save them in the working directory?