dpi and pdfa convertion do not reflect #98

Closed
opened 3 years ago by SnukY · 4 comments
SnukY commented 3 years ago

Hi there,

I am using a list in a python script to create multiple pdfs

dpi = 300
with open('pdf/'+workitemid+'_'+filenames+'_'+nextpage+'.pdf', "wb") as m:
	m.write(img2pdf.convert(document, dpi=dpi, x=None, y=None, pdfa=None))

changing the dpi does not reflect any changes in the output and using pdfa also does not convert it to a pdfa format.

I am not sure if this is not supported to use like this or if it is not working.

The scripts otherwise works fine and does what is should do convert multiple picture files tiff & jpgs to pdf.

Hi there, I am using a list in a python script to create multiple pdfs ``` dpi = 300 with open('pdf/'+workitemid+'_'+filenames+'_'+nextpage+'.pdf', "wb") as m: m.write(img2pdf.convert(document, dpi=dpi, x=None, y=None, pdfa=None)) ``` changing the dpi does not reflect any changes in the output and using pdfa also does not convert it to a pdfa format. I am not sure if this is not supported to use like this or if it is not working. The scripts otherwise works fine and does what is should do convert multiple picture files tiff & jpgs to pdf.
josch commented 3 years ago
Owner

This should indeed be fixed in the docs. Until it is the solution to setting the dpi is to pass a different layout function. Since changing the dpi is a common task, img2pdf brings a handy wrapper that you can use like this:

layout_fun = img2pdf.get_fixed_dpi_layout_fun((300, 300))
img2pdf.convert(image1, layout_fun=layout_fun, ... )

The pdfa argument expects the path to an icc profile. So you have to call convert like this:

img2pdf.convert(..., pdfa="/usr/share/color/icc/sRGB.icc", ...)
This should indeed be fixed in the docs. Until it is the solution to setting the dpi is to pass a different layout function. Since changing the dpi is a common task, img2pdf brings a handy wrapper that you can use like this: layout_fun = img2pdf.get_fixed_dpi_layout_fun((300, 300)) img2pdf.convert(image1, layout_fun=layout_fun, ... ) The pdfa argument expects the path to an icc profile. So you have to call `convert` like this: img2pdf.convert(..., pdfa="/usr/share/color/icc/sRGB.icc", ...)
SnukY commented 3 years ago
Poster

Thanks a lot for the fast response. I just tried to set the dpi as suggested. Script still working but the size of the pdf does not change.
I'm pretty new to converting files but shouldn't it lower the quality with lower dpi and the file should become smaller? (tried 50,50 150,150 300,300 600,600)

About the pdfa, thanks I will look into that.

Thanks a lot for the fast response. I just tried to set the dpi as suggested. Script still working but the size of the pdf does not change. I'm pretty new to converting files but shouldn't it lower the quality with lower dpi and the file should become smaller? (tried 50,50 150,150 300,300 600,600) About the pdfa, thanks I will look into that.
josch commented 3 years ago
Owner

Consult the README. img2pdf is always lossless and refuses to work if it cannot do its job without loss of information. This means that the size is the same independent of the dpi. The dpi value only influences the page size (as in cm).

Consult the README. img2pdf is always lossless and refuses to work if it cannot do its job without loss of information. This means that the size is the same independent of the dpi. The dpi value only influences the page size (as in cm).
SnukY commented 3 years ago
Poster

ah okay, very nice.
PDFA is working too with providing an icc profile.

Thanks, solved for me then.

ah okay, very nice. PDFA is working too with providing an icc profile. Thanks, solved for me then.
josch referenced this issue from a commit 3 years ago
josch closed this issue 3 years ago
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: josch/img2pdf#98
Loading…
There is no content yet.