0

我正在使用 pdf2image 将 pdf 转换为图像(.png)。但是,转换后图像的大小会增加。这是我正在使用的代码:

path = "2x.pdf"
pages = pdf2image.convert_from_path(
        path,
        dpi=300,
        poppler_path=poppler_path,
            )
for page in pages:
    page.save("output_2x.png","PNG")

查找pdf大小的代码:

from PyPDF2 import PdfFileReader
input1 = PdfFileReader(open('2x.pdf', 'rb'))
input1.getPage(0).mediaBox

Output: RectangleObject([0, 0, 3301, 5100])

查找图像大小的代码:

img = Image.open("output_2x.png")
img.size

Output: (13755, 21250)

宽度增加约 4 倍,而高度增加约 8 倍。

4

0 回答 0