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 <jluth@mail.com> Reviewed-by: László Németh <nemeth@numbertext.org>
This commit is contained in:
parent
4a9a6c6786
commit
a50f65d6cc
1 changed files with 8 additions and 4 deletions
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue