This is not working as expected. Problems with dpi and borders. #177
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
img2pdf 0.4.4
Brew installed.
I am trying to get an output file that is letter size with 300dpi resolution and images fit to pages centered with padding if necessary.
So far I have tried:
img2pdf -o out.pdf -S letter *.jpg
This gave me centered images at full size, like I want.
img2pdf -o out.pdf -S letter -s 300x300 *.jpg
img2pdf -o out.pdf -S letter -s 300 *.jpg
Images centered inside enormous borders.
img2pdf -o out.pdf -S letter -s 300dpix300dpi *.jpg
Image cut off at top and sides and bottom cut off.
No matter what I try, I always get the same result.
magick identify out.pdf
:Resolution: 72x72
Print size: 8.5x11
What is the proper way to achieve what I want?
Resolution: 300x300
Print size: 8.5x11
Can you send me your input image?
If you want letter pages with 300dpi images, then
should be doing what you want. If it does not, maybe there is a bug somewhere.
img2pdf -o out.pdf -S letter -s 300dpix300dpi "arthurrackhamtre00rack_0018.arthurrackham2.gcv.im.jpg"
Resolution: 72x72
Print size: 8.5x11
So that input image is 3032x4063 pixels. If you scale that to 300 dpi, then that's 10.1 x 13.5 inch. This means it does not fit onto the letter paper format and it makes sense that parts are cut off.
I don't see the bug. What do you think would happen?
Using
img2pdf -o "$of" -s 300dpix300dpi "arthurrackhamtre00rack_0018.arthurrackham2.gcv.im.jpg"
gives:Page Size: 10.11 x 13.54 in
Image Size: 3032x4063
If I resize the image to 2550x3417 (300 dpi) and use
img2pdf -o out -S letter "arthurrackhamtre00rack_0018.arthurrackham2.gcv.im.w=2550.px.jpg"
, I get:Page Size: 8.50 x 11.00 in
Image Size: 2550x3417
This is what I want. How do I do this with
img2pdf
without resizing the original image? I see the -f FIT option but it is not clear which option to use. Is it possible to specify page size and dpi and fit this somehow automatically without knowing image size?If I do
img2pdf -o "out8.5x11.pdf" -S letter "arthurrackhamtre00rack_0018.arthurrackham2.gcv.im.jpg"
, I get:Page Size: 8.50 x 11.00 in
Image Size: 3032×4063
I'd rather have Image Size: 2550x3417 without having to resize original image.
Oh, wait, just to confirm: you have your original image of 3032x4063 pixels and you would like img2pdf to change that so that the final image in the pdf is at around 2550x3417 pixels? You expect img2pdf to change the image for you?
I'm hoping that
img2pdf
can fit the original image scaled to 300 dpi into an 8.5x11 pdf likeimagemagick
can:I made the background black to show where the width of the image was fit without stretching.
arthurrackhamtre00rack_0018.arthurrackham2.gcv.im.jpg
arthurrackhamtre00rack_0018.arthurrackham2.gcv.im.300dpi.pdf
Can the -f FIT option do this?
Hi, I think I now understand the problem. Let me quote the very first sentence of the README:
Or the first point of the list below in bold font:
The word "lossless" is mentioned ten times in the README. The whole point of why img2pdf exists is to provide lossless conversion of images into the PDF container format. If you do not want this property, then there exist plenty of other pieces of software that can do that, see the five "Comparison" sections at the bottom of the README.
What you want is to scale the image by changing its resolution. That operation is clearly not lossless and that's why img2pdf cannot do it. If imagemagick can do what you want then you should just use that as the tool for your job.
I'm a bit puzzled that this property of img2pdf was not clear from the README. Can you point out what I could change so that you wouldn't have have been misled into thinking that img2pdf could actually change your image? I thought stating that it would be "always lossless" would make that quite clear. Should I add more explanations?