I'm trying to convert some pdf files to jpg through Wand in Python:
from wand.image import Image as Img
from wand.color import Color
def importPdf(self):
filename, _ = QtWidgets.QFileDialog.getOpenFileName(self, "Open File",
QtCore.QDir.currentPath())
print(filename)
if not filename:
print('error')
return
with Img(filename=filename,format='jpeg', resolution=300) as image:
image.compression_quality = 99
image.save(filename='file.jpeg')
self.open_picture()
My problem is that it results is a black screeen. The conversion works fine with png, but I cannot perform the OCR (via tesseract on the png). I think it comes from a kind of transparent layer, but I have not found the way to remove it, though I did several things such as
image.alpha_channel = False # made the same with True
image.background_color = Color('White')
before saving the file. I'm using Imagemagick V6.9, because V7 fails with Wand.