[Rivet-svn] rivet: Tweak to 'convert' call to improve the thumbnail quality ...

Rivet Mercurial rivet at projects.hepforge.org
Mon Dec 12 10:30:02 GMT 2016


details:   https://rivet.hepforge.org/hg/rivet/rev/1be9d5e599f4
branches:  release-2-5-x
changeset: 5643:1be9d5e599f4
user:      Andy Buckley <andy at insectnation.org>
date:      Mon Dec 12 10:27:01 2016 +0000
description:
Tweak to 'convert' call to improve the thumbnail quality from rivet-mkhtml/make-plots.

diffs (48 lines):

--- a/ChangeLog	Thu Dec 08 17:08:43 2016 +0000
+++ b/ChangeLog	Mon Dec 12 10:27:01 2016 +0000
@@ -1,3 +1,7 @@
+2016-12-12  Andy Buckley  <andy.buckley at cern.ch>
+
+	* Tweak to 'convert' call to improve the thumbnail quality from rivet-mkhtml/make-plots.
+
 2016-12-07  Andy Buckley  <andy.buckley at cern.ch>
 
 	* Require Cython 0.24 or later.
--- a/bin/make-plots	Thu Dec 08 17:08:43 2016 +0000
+++ b/bin/make-plots	Mon Dec 12 10:27:01 2016 +0000
@@ -2489,12 +2489,20 @@
 
         # TODO: It'd be nice to be able to control the size of the PNG between thumb and full-size...
         #   currently defaults (and is used below) to a size suitable for thumbnails
-        def mkpng(infile, outfile, density=100):
+        def mkpngcmd(infile, outfile, outsize=450, density=300):
             if convertavailable:
-                pngcmd = ["convert", "-flatten", "-density", str(density), infile, "-quality", "100", "-sharpen", "0x1.0", outfile]
-                logging.debug(" ".join(pngcmd))
-                pngproc = subprocess.Popen(pngcmd, stdout=subprocess.PIPE, cwd=tempdir)
-                pngproc.wait()
+                pngcmd = ["convert",
+                          "-flatten",
+                          "-density", str(density),
+                          infile,
+                          "-quality", "100",
+                          "-resize", "{size:d}x{size:d}>".format(size=outsize),
+                          #"-sharpen", "0x1.0",
+                          outfile]
+                #logging.debug(" ".join(pngcmd))
+                #pngproc = subprocess.Popen(pngcmd, stdout=subprocess.PIPE, cwd=tempdir)
+                #pngproc.wait()
+                return pngcmd
             else:
                 raise Exception("Required PNG maker program (convert) not found")
             # elif ps2pnmavailable and pnm2pngavailable:
@@ -2548,7 +2556,8 @@
             dvcmd.append("-f")
             logging.debug(" ".join(dvcmd))
             dvproc = subprocess.Popen(dvcmd, stdout=subprocess.PIPE, cwd=tempdir)
-            pngcmd = ["convert", "-flatten", "-density", "100", "-", "-quality", "100", "-sharpen", "0x1.0", "%s.png" % filename]
+            #pngcmd = ["convert", "-flatten", "-density", "110", "-", "-quality", "100", "-sharpen", "0x1.0", "%s.png" % filename]
+            pngcmd = mkpngcmd("-", "%s.png" % filename)
             logging.debug(" ".join(pngcmd))
             pngproc = subprocess.Popen(pngcmd, stdin=dvproc.stdout, stdout=subprocess.PIPE, cwd=tempdir)
             pngproc.wait()


More information about the Rivet-svn mailing list