pdf2image icon indicating copy to clipboard operation
pdf2image copied to clipboard

Due to reduced Image quality (after conversion), text is not readable

Open jaiswati opened this issue 3 years ago • 1 comments

Describe the bug Due to reduced Image quality (after conversion), text is not readable . This has been tried in colab notebook To Reproduce Steps to reproduce the behavior: from pdf2image import convert_from_path, convert_from_bytes from IPython.display import display, Image

images = convert_from_bytes(open('/content/sample_data/test.pdf', 'rb').read(), size=800,dpi=400) display(images[0])

Expected behavior text in the image should be clear

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information): colab notebook with Chrome browser

jaiswati avatar Aug 25 '22 14:08 jaiswati

The way the code is written, both parameters (dpi and size) are being sent to pdftoppm this means that the issue you are seeing is most likely not at the pdf2image level, but in the underlying library.

My best solution would be to resize the output of pdf2image manually instead of using the parameter. Something like:

from PIL import Image

images = convert_from_bytes(open('/content/sample_data/test.pdf', 'rb').read(), size=800,dpi=400)

images[0].thumbnail((800, 800)) # This is in place I think

display(images[0])

Belval avatar Sep 03 '22 19:09 Belval