Use the convert argument '-define "pdf:use-cropbox=true"' when creating thumbnails. That way cropboxes, if present, gets respected for thumbnail generation.

This commit is contained in:
Henning Bunk 2024-01-24 02:15:02 +01:00
parent 88ae60a4a0
commit 21818010b9
No known key found for this signature in database
GPG Key ID: 0E6C529A574BC728
5 changed files with 8 additions and 0 deletions

View File

@ -290,6 +290,7 @@ class Command(BaseCommand):
strip=True,
trim=False,
auto_orient=True,
define="pdf:use-cropbox=true",
input_file=f"{thumbnail_path}[0]",
output_file=str(document.thumbnail_path),
)

View File

@ -94,6 +94,8 @@ def move_documents_and_create_thumbnails(apps, schema_editor):
"500x5000",
"-alpha",
"remove",
"-define",
"pdf:use-cropbox=true",
orig_target,
os.path.join(thumb_temp, "convert-%04d.png"),
),

View File

@ -27,6 +27,7 @@ def _do_convert(work_package):
strip=True,
trim=False,
auto_orient=True,
define="pdf:use-cropbox=true",
input_file=f"{existing_thumbnail}[0]",
output_file=str(converted_thumbnail),
)

View File

@ -53,6 +53,7 @@ def _do_convert(work_package):
strip=True,
trim=False,
auto_orient=True,
define="pdf:use-cropbox=true",
input_file=f"{decrypted_thumbnail}[0]",
output_file=str(converted_decrypted_thumbnail),
)

View File

@ -140,6 +140,7 @@ def run_convert(
type=None,
depth=None,
auto_orient=False,
define=None,
extra=None,
logging_group=None,
) -> None:
@ -158,6 +159,7 @@ def run_convert(
args += ["-type", str(type)] if type else []
args += ["-depth", str(depth)] if depth else []
args += ["-auto-orient"] if auto_orient else []
args += ["-define", str(define)] if define else []
args += [input_file, output_file]
logger.debug("Execute: " + " ".join(args), extra={"group": logging_group})
@ -229,6 +231,7 @@ def make_thumbnail_from_pdf(in_path, temp_dir, logging_group=None) -> str:
strip=True,
trim=False,
auto_orient=True,
define="pdf:use-cropbox=true",
input_file=f"{in_path}[0]",
output_file=out_path,
logging_group=logging_group,