Fix page rotation regression

Page size fixes in commit b26749 did accounted for a "kept" rotation,
but not a corrected rotation.

Fixes #730.
This commit is contained in:
James R. Barlow
2021-02-15 01:47:09 -08:00
parent 8770fff968
commit 064f935699
4 changed files with 169 additions and 4 deletions
+6 -2
View File
@@ -584,7 +584,9 @@ def create_visible_page_jpg(image: Path, page_context: PageContext) -> Path:
return output_file
def create_pdf_page_from_image(image: Path, page_context: PageContext):
def create_pdf_page_from_image(
image: Path, page_context: PageContext, orientation_correction
):
# We rasterize a square DPI version of each page because most image
# processing tools don't support rectangular DPI. Use the square DPI as it
# accurately describes the image. It would be possible to resample the image
@@ -595,7 +597,8 @@ def create_pdf_page_from_image(image: Path, page_context: PageContext):
pageinfo = page_context.pageinfo
pagesize = 72.0 * float(pageinfo.width_inches), 72.0 * float(pageinfo.height_inches)
if pageinfo.rotation % 180 == 90:
effective_rotation = (pageinfo.rotation - orientation_correction) % 360
if effective_rotation % 180 == 90:
pagesize = pagesize[1], pagesize[0]
# This create a single page PDF
@@ -607,6 +610,7 @@ def create_pdf_page_from_image(image: Path, page_context: PageContext):
imfile, with_pdfrw=False, layout_fun=layout_fun, outputstream=pdf
)
log.debug('convert done')
return output_file
+1 -1
View File
@@ -204,7 +204,7 @@ def exec_page_sync(page_context: PageContext):
if filtered_image:
visible_image_out = filtered_image
pdf_page_from_image_out = create_pdf_page_from_image(
visible_image_out, page_context
visible_image_out, page_context, orientation_correction
)
if options.pdf_renderer.startswith('hocr'):