mirror of
https://github.com/ocrmypdf/OCRmyPDF.git
synced 2026-05-07 06:07:58 -04:00
Fix hookspec of rasterize_pdf_page to remove default parameters
This commit is contained in:
@@ -81,8 +81,8 @@ def rasterize_pdf(
|
|||||||
raster_device: str,
|
raster_device: str,
|
||||||
raster_dpi: Resolution,
|
raster_dpi: Resolution,
|
||||||
pageno: int = 1,
|
pageno: int = 1,
|
||||||
page_dpi: Resolution = None,
|
page_dpi: Optional[Resolution] = None,
|
||||||
rotation: int = None,
|
rotation: Optional[int] = None,
|
||||||
filter_vector: bool = False,
|
filter_vector: bool = False,
|
||||||
):
|
):
|
||||||
"""Rasterize one page of a PDF at resolution raster_dpi in canvas units."""
|
"""Rasterize one page of a PDF at resolution raster_dpi in canvas units."""
|
||||||
|
|||||||
@@ -332,8 +332,10 @@ def rasterize_preview(input_file: Path, page_context: PageContext):
|
|||||||
output_file=output_file,
|
output_file=output_file,
|
||||||
raster_device='jpeggray',
|
raster_device='jpeggray',
|
||||||
raster_dpi=canvas_dpi,
|
raster_dpi=canvas_dpi,
|
||||||
page_dpi=page_dpi,
|
|
||||||
pageno=page_context.pageinfo.pageno + 1,
|
pageno=page_context.pageinfo.pageno + 1,
|
||||||
|
page_dpi=page_dpi,
|
||||||
|
rotation=0,
|
||||||
|
filter_vector=False,
|
||||||
)
|
)
|
||||||
return output_file
|
return output_file
|
||||||
|
|
||||||
@@ -433,7 +435,7 @@ def rasterize(
|
|||||||
|
|
||||||
device = colorspaces[device_idx]
|
device = colorspaces[device_idx]
|
||||||
|
|
||||||
log.debug(f"Rasterize with {device}")
|
log.debug(f"Rasterize with {device}, rotation {correction}")
|
||||||
|
|
||||||
# Produce the page image with square resolution or else deskew and OCR
|
# Produce the page image with square resolution or else deskew and OCR
|
||||||
# will not work properly.
|
# will not work properly.
|
||||||
@@ -534,6 +536,9 @@ def create_ocr_image(image: Path, page_context: PageContext):
|
|||||||
|
|
||||||
# Pillow requires integer DPI
|
# Pillow requires integer DPI
|
||||||
dpi = tuple(round(coord) for coord in im.info['dpi'])
|
dpi = tuple(round(coord) for coord in im.info['dpi'])
|
||||||
|
if page_context.pageinfo.rotation != 0:
|
||||||
|
log.info(f"Rotating {page_context.pageinfo.rotation}")
|
||||||
|
im = im.rotate(page_context.pageinfo.rotation)
|
||||||
im.save(output_file, dpi=dpi)
|
im.save(output_file, dpi=dpi)
|
||||||
return output_file
|
return output_file
|
||||||
|
|
||||||
|
|||||||
@@ -61,9 +61,9 @@ def rasterize_pdf_page(
|
|||||||
raster_device,
|
raster_device,
|
||||||
raster_dpi,
|
raster_dpi,
|
||||||
pageno,
|
pageno,
|
||||||
page_dpi=None,
|
page_dpi,
|
||||||
rotation=None,
|
rotation,
|
||||||
filter_vector=False,
|
filter_vector,
|
||||||
):
|
):
|
||||||
ghostscript.rasterize_pdf(
|
ghostscript.rasterize_pdf(
|
||||||
input_file,
|
input_file,
|
||||||
|
|||||||
@@ -89,9 +89,9 @@ def rasterize_pdf_page(
|
|||||||
raster_device: str,
|
raster_device: str,
|
||||||
raster_dpi: Resolution,
|
raster_dpi: Resolution,
|
||||||
pageno: int,
|
pageno: int,
|
||||||
page_dpi: Optional[Resolution] = None,
|
page_dpi: Optional[Resolution],
|
||||||
rotation: Optional[int] = None,
|
rotation: Optional[int],
|
||||||
filter_vector: bool = False,
|
filter_vector: bool,
|
||||||
) -> Path:
|
) -> Path:
|
||||||
"""Rasterize one page of a PDF at resolution raster_dpi in canvas units.
|
"""Rasterize one page of a PDF at resolution raster_dpi in canvas units.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user