From f7dbf94071d1e23e55ead96c3cfee13464d80e98 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Thu, 18 Oct 2018 01:23:31 -0700 Subject: [PATCH] pipeline: if vector graphic objects exist, ensure the DPI is reasonable --- src/ocrmypdf/_pipeline.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ocrmypdf/_pipeline.py b/src/ocrmypdf/_pipeline.py index bc95e6e9..e114d6b6 100644 --- a/src/ocrmypdf/_pipeline.py +++ b/src/ocrmypdf/_pipeline.py @@ -206,8 +206,12 @@ def get_pageinfo(input_file, context): def get_page_dpi(pageinfo, options): "Get the DPI when nonsquare DPI is tolerable" - xres = max(pageinfo.xres or VECTOR_PAGE_DPI, options.oversample or 0) - yres = max(pageinfo.yres or VECTOR_PAGE_DPI, options.oversample or 0) + xres = max(pageinfo.xres or VECTOR_PAGE_DPI, + options.oversample or 0, + VECTOR_PAGE_DPI if pageinfo.has_vector else 0) + yres = max(pageinfo.yres or VECTOR_PAGE_DPI, + options.oversample or 0, + VECTOR_PAGE_DPI if pageinfo.has_vector else 0) return (float(xres), float(yres)) @@ -219,6 +223,7 @@ def get_page_square_dpi(pageinfo, options): return float(max( (xres * userunit) or VECTOR_PAGE_DPI, (yres * userunit) or VECTOR_PAGE_DPI, + VECTOR_PAGE_DPI if pageinfo.has_vector else 0, options.oversample or 0)) @@ -227,6 +232,7 @@ def get_canvas_square_dpi(pageinfo, options): return float(max( (pageinfo.xres) or VECTOR_PAGE_DPI, (pageinfo.yres) or VECTOR_PAGE_DPI, + VECTOR_PAGE_DPI if pageinfo.has_vector else 0, options.oversample or 0))