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 # +# Date: 14-Jun-16 +# Edited: J. Sovetkin +# # 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