diff-pdf-page.py: change assumed background to transparent

The page background color of a document likely is white,
so at least the overlay (the second PNG) must be transparent.

[I saw (in Draw) that PRINT-TO-PDF tended to produce a PDF
that would have a transparent background when converted to PNG,
but that EXPORT-TO-PDF from LO would produce a white background
that obviously would fully overlay and obscure the first image.]

(Calc and Writer's export-to-pdf produced a transparent background.)

In any case, it makes sense to try to force both of these
to have a transparent background.

NOTE: It was important to place -transparent before -fuzz,
or else 95% of all colors will be considered white
and turned into transparent.

Change-Id: I26e6081fcd59e82b2aaedb86370bdbcc57b0a24e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175466
Reviewed-by: Justin Luth <jluth@mail.com>
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
This commit is contained in:
Justin Luth 2024-10-22 18:43:11 -04:00 committed by Justin Luth
parent a50f65d6cc
commit 9254ed4a8b

View file

@ -32,10 +32,10 @@ def main():
a_png = tempfile.NamedTemporaryFile(suffix=".png")
a_pdf = args.a_pdf + "[" + args.page + "]"
run([CONVERT_CMD, "-density", args.density, a_pdf, "-colorspace", "RGB", "-fuzz", "95%", "-fill", "red", "-opaque", "black", a_png.name])
run([CONVERT_CMD, "-density", args.density, a_pdf, "-colorspace", "RGB", "-transparent", "white", "-fuzz", "95%", "-fill", "red", "-opaque", "black", a_png.name])
b_png = tempfile.NamedTemporaryFile(suffix=".png")
b_pdf = args.b_pdf + "[" + args.page + "]"
run([CONVERT_CMD, "-density", args.density, b_pdf, "-colorspace", "RGB", b_png.name])
run([CONVERT_CMD, "-density", args.density, b_pdf, "-colorspace", "RGB", "-transparent", "white", b_png.name])
composite_png = tempfile.NamedTemporaryFile(suffix=".png")
run([CONVERT_CMD, a_png.name, b_png.name, "-composite", composite_png.name])
run([CONVERT_CMD, composite_png.name, "-background", "white", "-flatten", args.diff_png])