diff options
author | Thomas Deutschmann <whissi@gentoo.org> | 2019-10-15 12:24:12 +0200 |
---|---|---|
committer | Thomas Deutschmann <whissi@gentoo.org> | 2020-08-13 11:26:55 +0200 |
commit | e088156d5b620e5e639580dacf85c6dc13823c74 (patch) | |
tree | 57f5c025e203279944da512166c20bc0521d8ccd /toolbin/tests/make_two_pdfversions | |
download | ghostscript-gpl-patches-e088156d5b620e5e639580dacf85c6dc13823c74.tar.gz ghostscript-gpl-patches-e088156d5b620e5e639580dacf85c6dc13823c74.tar.bz2 ghostscript-gpl-patches-e088156d5b620e5e639580dacf85c6dc13823c74.zip |
Import Ghostscript 9.50ghostscript-9.50
Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
Diffstat (limited to 'toolbin/tests/make_two_pdfversions')
-rwxr-xr-x | toolbin/tests/make_two_pdfversions | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/toolbin/tests/make_two_pdfversions b/toolbin/tests/make_two_pdfversions new file mode 100755 index 00000000..e02dc616 --- /dev/null +++ b/toolbin/tests/make_two_pdfversions @@ -0,0 +1,90 @@ +#!/usr/bin/env python +# -*- Mode: python -*- + +# Copyright (C) 2001-2019 Artifex Software, Inc. +# All Rights Reserved. +# +# This software is provided AS-IS with no warranty, either express or +# implied. +# +# This software is distributed under license and may not be copied, +# modified or distributed except as expressly authorized under the terms +# of the license contained in the file LICENSE in this distribution. +# +# Refer to licensing information at http://www.artifex.com or contact +# Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato, +# CA 94945, U.S.A., +1(415)492-9861, for further information. +# + + +# +# make_two_versions <filename> [<device> [<res>]] +# +# this script creates two versions of the file specified +# one from baseline, and one from head +# these are appropriate for a visual diff + +import gstestgs +import gsconf +import rasterdb +import os, sys +import string + +def make_version(ifile, ofile, device, dpi, baseline=0): + gs = gstestgs.Ghostscript() + gs.log_stdout = gsconf.log_stdout + gs.log_stderr = gsconf.log_stderr + + if baseline: + gs.command = gsconf.baselinegs + else: + gs.command = gsconf.comparegs + + gs.infile = gsconf.comparefiledir + ifile + gs.dpi = dpi + gs.band = 0 + + # make file->PDF + + tfile = ofile + ".pdf" + gs.outfile = tfile + gs.device = 'pdfwrite' + + if not gs.process(): + print "error creating pdf." + return + + gs.infile = tfile + gs.outfile = ofile + gs.device = device + + if not gs.process(): + print "error rasterizing pdf." + os.unlink(tfile) + +if len(sys.argv) < 2: + print "\n usage: make_two_pdfversions filename [ device:ppmraw [ res:72 ] ]\n" + sys.exit() + +file = os.path.basename(sys.argv[1]) +if len(sys.argv) > 2: + device = sys.argv[2] +else: + device = 'ppmraw' +if len(sys.argv) > 3: + res = int(sys.argv[3]) +else: + res = 72 + +dbfile = "%s.pdf.%s.%d.%d" % (file, device, res, 0) +ofile = "%s.pdf.%s.baseline.pnm" % (file, device) + +# check for cached raster and use that if it exists +if rasterdb.exists(dbfile): + rasterdb.get_file(dbfile, output=ofile) +else: + make_version(file, ofile, device, res, baseline=1) + +ofile = "%s.pdf.%s.compare.pnm" % (file, device) + +make_version(file, ofile, device, res, baseline=0) |