summarylogtreecommitdiffstats
path: root/qasm2png.patch
blob: fbf4727a6282a6bb8100a0d4c79843a7cf560b26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
diff --git a/qasm2png b/qasm2png
index f4cc8b8..2a3a4be 100755
--- a/qasm2png
+++ b/qasm2png
@@ -1,29 +1,35 @@
-#!/bin/csh
+#!/bin/bash
 #
 # File:   qasm2png
 # Date:   23-Mar-04
 # Author: I. Chuang <ichuang@mit.edu>
 #
+# Date:   14-Jun-16
+# Edited: J. Sovetkin <e.sovetkin@gmail.com>
+#
 # Shell script to convert qasm files to png, using the qasm2tex python script
 #
-# Usage:  qasm2png foo.qasm
+# Usage:  qasm2png foo.qasm dir/foo2.qasm
 #
-# Produces: foo.png  (and also foo.tex, foo.epsf)
-
-set GS = "gs -sDEVICE=pnmraw -r400 -dNOPAUSE"
-
-foreach i ($*)
-
-        set t = `echo $i | sed "s/.qasm//"`
+# Produces: foo1.png and foo2.png in the corresponding directories
+# (and also foo.tex, foo.epsf)
 
-	python qasm2tex.py $i >! $t.tex
-	if (-z $t.tex) then
-	    echo "error in qasm2tex on $t.tex! aborting."
-	else
-	    latex $t
-	    dvips -D2400 -E -o $t.eps $t
-	    ${GS} -sOutputFile=$t.pbm $t.eps -c quit
-	    pnmcrop $t.pbm | pnmtopng >! $t.png
-	    rm -f $t.pbm
-	endif
-end
+for file in "$@"
+do
+    local filename
+    filename="${filename%.*}"
+    
+    qasm2tex ${file} > ${filename}.tex
+    
+	  if [[ ! -f ${filename}.tex ]]
+    then
+	      echo "error in qasm2tex on ${filename}.tex! aborting."
+	  else
+	      latex ${filename}
+	      dvips -D2400 -E -o ${filename}.eps ${filename}
+	      gs -sDEVICE=pnmraw -r400 -dNOPAUSE \
+           -sOutputFile=${filename}.pbm ${filename}.eps -c quit
+	      pnmcrop ${filename}.pbm | pnmtopng >! ${filename}.png
+	      rm -f ${filename}.pbm
+    fi
+done
-- 
2.8.3