I have the following piece of python code to convert PDF to JPG.
with Img(filename=pdfName, resolution=300) as pic:
pic.compression_quality = self.compressionQuality
pic.background_color = Color("white")
pic.alpha_channel = 'remove'
pic.save(filename=output)
My problem is, with a large PDF file (10mb) I have the following error :
File "/home/nathan/PycharmProjects/oc_for_maarch/worker.py", line 44, in <module>
launch(args)
File "/home/nathan/PycharmProjects/oc_for_maarch/src/main.py", line 105, in launch
q = process(args, path + file, Log, Separator, Config, Image, Ocr, Locale, WebService, q)
File "/home/nathan/PycharmProjects/oc_for_maarch/src/process/OCForMaarch.py", line 48, in process
Image.pdf_to_jpg(file + '[0]')
File "/home/nathan/PycharmProjects/oc_for_maarch/src/classes/Images.py", line 36, in pdf_to_jpg
self.save_img_with_wand(pdfName, self.jpgName)
File "/home/nathan/PycharmProjects/oc_for_maarch/src/classes/Images.py", line 46, in save_img_with_wand
with Img(filename=pdfName, resolution=300) as pic:
File "/home/nathan/Documents/OpenCV/lib/python3.7/site-packages/wand/image.py", line 6406, in __init__
self.read(filename=filename, resolution=resolution)
File "/home/nathan/Documents/OpenCV/lib/python3.7/site-packages/wand/image.py", line 6799, in read
raise WandRuntimeError(msg)
wand.exceptions.WandRuntimeError: MagickReadImage returns false, but did raise ImageMagick exception. This can occurs when a delegate is missing, or returns EXIT_SUCCESS without generating a raster.
I checked a little on Internet, and for what I've seen the problems was related to ghostscript
but It's installed
I have the problem on Debian 10 and Ubuntu 19.04 using Python 3.7
EDIT : If I put the resolution to 100 instead of 300, I didn't have the issue