bin/diff-pdf-page.py |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

New commits:
commit a50f65d6cc42c5815574a361525ad6dfa83fd5b5
Author:     Justin Luth <[email protected]>
AuthorDate: Tue Oct 22 18:37:11 2024 -0400
Commit:     Justin Luth <[email protected]>
CommitDate: Thu Oct 24 15:54:17 2024 +0200

    diff-pdf-page.py: allow use of "magick" (on Windows)
    
    The ImageMagick package on Windows does not use convert,
    but uses magick (which is not used by Linux).
    
    So use a variable to make is simpler
    to make it usable under Windows.
    
    Note that cygwin's ImageMagick package does use "convert",
    overriding Windows built in disk convert tool.
    
    Change-Id: I658e0eb11400cf9e6c65ab4ba150ed2ab239c94e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175455
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <[email protected]>
    Reviewed-by: László Németh <[email protected]>

diff --git a/bin/diff-pdf-page.py b/bin/diff-pdf-page.py
index 0e60db34bdc2..958d487535fc 100755
--- a/bin/diff-pdf-page.py
+++ b/bin/diff-pdf-page.py
@@ -8,6 +8,8 @@
 # red is meant to reduce as fixing progresses. Sample usage:
 #
 # bin/diff-pdf-page.py reference.pdf test.pdf diff.png
+#
+# using the ImageMagick tooling
 
 import argparse
 import tempfile
@@ -26,15 +28,17 @@ def main():
     parser.add_argument("diff_png")
     args = parser.parse_args()
 
+    CONVERT_CMD="convert" # use "magick" if Windows has installed ImageMagick 
and GhostScript
+
     a_png = tempfile.NamedTemporaryFile(suffix=".png")
     a_pdf = args.a_pdf + "[" + args.page + "]"
-    run(["convert", "-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", 
"-fuzz", "95%", "-fill", "red", "-opaque", "black", a_png.name])
     b_png = tempfile.NamedTemporaryFile(suffix=".png")
     b_pdf = args.b_pdf + "[" + args.page + "]"
-    run(["convert", "-density", args.density, b_pdf, "-colorspace", "RGB", 
b_png.name])
+    run([CONVERT_CMD, "-density", args.density, b_pdf, "-colorspace", "RGB", 
b_png.name])
     composite_png = tempfile.NamedTemporaryFile(suffix=".png")
-    run(["convert", a_png.name, b_png.name, "-composite", composite_png.name])
-    run(["convert", composite_png.name, "-background", "white", "-flatten", 
args.diff_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])
 
 if __name__ == "__main__":
     main()

Reply via email to