English 中文(简体)
pdf2image transformation of multi page PDFs to pornographysam the final page on all pornography
原标题:pdf2image conversion of multi page PDFs to images returns the last page on all images

因此,我使用<代码>pdf2image。 输出阵列含有多种图像,但所有图像都出现在最后的PDF网页上(因为我预计每个图像是PDF网页之一)。

产出就是这样:

“pdf2image

为什么会发生这种情况? 我无法在网上找到任何解决办法。 我发现了一些模糊的建议,即<代码>使用_crop Box 可能使用这一论点,但加以修改没有任何效果。

def convert(opened_file)
    # Read PDF and convert pages to PPM image objects
    try:
        _ppm_pages = self.pdf2image.convert_from_bytes(
            opened_file.read(),
            grayscale = True
        )
    except Exception as e:
        print(f"[CreateJPEG] Could not convert PDF pages to JPEG image due to error: 
     {e} ")
        return

    # Do stuff with _ppm_pages
    for img in _ppm_pages:
        img.show() # ...all images in that list are of the last page

有时,产出是1x1图像的空洞,但我也发现这是原因。 因此,如果你们有任何想法,请让我知道!

Thanks in advance, Simon

EDIT:添加代码。

EDIT:因此,当我用随机笔记来尝试时,它实际上进行罚款。

我删除了我原法典中使用的几条tour子,现在它运作。 仍不能确定背后的原因何在......

同样,由于你的帮助,每个人!

问题回答

我现在使用这一权利。

from pdf2image import convert_from_path

imgSet = convert_from_path(pathToPDF, 500)

这使我看到了在成像中的形象清单。 集邮

我猜想,正如一揽子计划单位测试所描述的那样,你必须做这样的事情。

        with open("./tests/test.pdf", "rb") as pdf_file:
            images_from_bytes = convert_from_bytes(pdf_file.read(), fmt="jpg")
            self.assertTrue(images_from_bytes[0].format == "JPEG")

这个问题可能发生在pdf网页上隐藏着文字时。 我没有办法。 你们是否解决了这一问题?





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签