fitwidth: wrong calculation? #30
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?
By Erik on 2016-05-24T13:42:41.418Z
File: img2pdf.py
Line: 806
Using
-b 0in:0.5in
results in debug outputborder -> (0.0, 36.0)
.I understand that
border = (top-bottom-border, left-right-border)
, according to the documentation.Thus,
newborder
should follow the same pattern.If this is true,
fitwidth
andfitwidth
use the wrong list position ofnewborder
.fitwidth
should be computed usingnewborder[1]
andfitheight
usingnewborder[0]
. Like below:By josch on 2016-05-25T19:07:49.802Z
I do not understand your bug report. Where do you see the problem?
If I run:
Then I get a PDF file with a large border on the left and right and a small border at the top and bottom. This is exactly what the documentation says should happen:
So where is the bug?
By Erik on 2016-05-25T22:40:44.461Z
Well, the technical aspect of the bug is that
fitwidth
is mixed with the top-bottom-border. Andfitheight
is mixed with the left-right-border. According to the code snippet I posted above.Now, to your example. I downloaded a fresh zip and modified the code in question to exclude side effects. I ran your original code and then the modified code. The goal is a PDF with a narrow top-bottom margin and a wider left-right margin.
I opened both PDFs and measured the margins manually. In your_code the top-bottom margins are 0.5in each. In my_code the top-bottom margins are 0.25in each, as expected.
Please refer to the images attached.
Input image with border
0020.jp2
Your code
ve/bin/img2pdf -S 6inx9in -b 0.25in:0.5in -C L -o tmp_your_code.pdf 0020.jp2
tmp_your_code.pdf
Modified code
ve/bin/img2pdf -S 6inx9in -b 0.25in:0.5in -C L -o tmp_my_code.pdf 0020.jp2
tmp_my_code.pdf
By josch on 2016-05-26T06:19:55.790Z
Status changed to closed by commit
d78b2cbdbc