Hello, I'm writing a hentai downloader that downloads images and should convert them to PDF. This works for most images, but some spontaneously get reencoded as PNG with a crazy high input DPI which leads to img2pdf assuming a too small image size. Here's a debug log with several pages working up until the failure:
DEBUG PIL format = PNG
DEBUG imgformat = PNG
DEBUG input dpi = 96 x 96
DEBUG rotation = 0°
DEBUG input colorspace = P
DEBUG width x height = 966px x 1400px
DEBUG read_images() embeds a PNG
DEBUG STREAM b'IHDR' 16 13
DEBUG STREAM b'PLTE' 41 51
DEBUG STREAM b'IDAT' 104 258147
DEBUG PIL format = PNG
DEBUG imgformat = PNG
DEBUG input dpi = 96 x 96
DEBUG rotation = 0°
DEBUG input colorspace = P
DEBUG width x height = 966px x 1400px
DEBUG read_images() embeds a PNG
DEBUG STREAM b'IHDR' 16 13
DEBUG STREAM b'PLTE' 41 51
DEBUG STREAM b'IDAT' 104 233215
DEBUG PIL format = PNG
DEBUG imgformat = PNG
DEBUG input dpi = 96 x 96
DEBUG rotation = 0°
DEBUG input colorspace = P
DEBUG width x height = 970px x 1400px
DEBUG read_images() embeds a PNG
DEBUG STREAM b'IHDR' 16 13
DEBUG STREAM b'PLTE' 41 51
DEBUG STREAM b'IDAT' 104 343431
DEBUG PIL format = PNG
DEBUG imgformat = PNG
DEBUG input dpi = 96 x 96
DEBUG rotation = 0°
DEBUG input colorspace = P
DEBUG width x height = 970px x 1400px
DEBUG read_images() embeds a PNG
DEBUG STREAM b'IHDR' 16 13
DEBUG STREAM b'PLTE' 41 51
DEBUG STREAM b'IDAT' 104 268655
DEBUG PIL format = PNG
DEBUG imgformat = PNG
DEBUG input dpi = 96 x 96
DEBUG rotation = 0°
DEBUG input colorspace = P
DEBUG width x height = 970px x 1400px
DEBUG read_images() embeds a PNG
DEBUG STREAM b'IHDR' 16 13
DEBUG STREAM b'PLTE' 41 51
DEBUG STREAM b'IDAT' 104 243649
DEBUG PIL format = PNG
DEBUG imgformat = PNG
DEBUG input dpi = 96 x 96
DEBUG rotation = 0°
DEBUG input colorspace = P
DEBUG width x height = 970px x 1400px
DEBUG read_images() embeds a PNG
DEBUG STREAM b'IHDR' 16 13
DEBUG STREAM b'pHYs' 41 9
DEBUG STREAM b'tEXt' 62 10
DEBUG STREAM b'tEXt' 84 14
DEBUG STREAM b'tEXt' 110 12
DEBUG STREAM b'IDAT' 134 8192
DEBUG PIL format = PNG
DEBUG imgformat = PNG
DEBUG Converting frame: 0
DEBUG input dpi = 94069 x 94069
DEBUG rotation = 0°
DEBUG input colorspace = RGB
DEBUG width x height = 970px x 1400px
DEBUG Colorspace is OK: Colorspace.RGB
DEBUG read_images() encoded an image as PNG
WARNING pdf width or height is below 3.00 - too small for some viewers!
[2024-02-07T20:09:12] ERROR Converting to PDF failed with ValueError. Error message: ('Page size must be between 3 and 14400 PDF units',).
I am calling the function like this: PDF=img2pdf.convert(images_filepath, rotation=img2pdf.Rotation.ifvalid) I do not wish to use a fixed page size or dpi, because I want to keep the images in their complete original form.
Can you help me mitigate this error or is this a bug? Any help would be appreciated.
Hello, I'm writing a hentai downloader that downloads images and should convert them to PDF. This works for most images, but some spontaneously get reencoded as PNG with a crazy high input DPI which leads to img2pdf assuming a too small image size. Here's a debug log with several pages working up until the failure:
I am calling the function like this:
PDF=img2pdf.convert(images_filepath, rotation=img2pdf.Rotation.ifvalid)
I do not wish to use a fixed page size or dpi, because I want to keep the images in their complete original form.Can you help me mitigate this error or is this a bug? Any help would be appreciated.
9-FS