#!/bin/bash # convert a png file into eps file # Usage: # png2eps pngfile.png [-q JPGQuality -r FigResizePercentage] # e.g., # png2eps aa.png bb.png -q 100 -r 60 # http://scriptdemo.blogspot.com if [ $# == 0 ]; then sed -n '3,6p' png2eps exit fi JPGQuality='100' FileResize='80' nfile=0 while test -n "$1" do case "$1" in -q|-quality) JPGQuality=$2 shift ;; -r|-resize) FileResize=$2 shift ;; *) if [ -e $1 ]; then pngfiles[$nfile]=$1 nfile=`expr $nfile + 1` fi shift ;; esac done for pngfile in ${pngfiles[*]} do #convert to jpg file first to keep high resolution jpgfile=${pngfile%%.*}.jpg epsfile=${pngfile%%.*}.eps eval "convert -quality ${JPGQuality} -resize ${FileResize}% ${pngfile} ${jpgfile}" [ -e ${epsfile} ] && epsfile=tmp_${epsfile} eval "convert ${jpgfile} eps3:${epsfile} && rm -f ${jpgfile}" done |
#!/bin/bash # convert a png file into eps file [using pngtopnm, pnmtops] # Usage: # png2eps2 pngfile.png -scale reScale [-o outfile.eps] # e.g., # png2eps2 aa.png -scale 0.3 -o aa.eps # http://scriptdemo.blogspot.com if [ $# == 0 ]; then sed -n '3,6p' png2eps2 exit fi reScale='0.3' nfile=0 while test -n "$1" do case "$1" in -s|-r|-scale|-rescale) reScale=$2 shift ;; -o|-output) epsfile=$2 shift ;; *) if [ -e $1 ]; then pngfiles[$nfile]=$1 nfile=`expr $nfile + 1` fi shift ;; esac done for pngfile in ${pngfiles[*]} do #convert to jpg file first and resize [ ! -n "$epsfile" ] && epsfile=${pngfile%%.*}.eps [ $nfile -gt 1 ] && epsfile=${pngfile%%.*}.eps [ -e ${epsfile} ] && epsfile=tmp_${epsfile} eval "pngtopnm ${pngfile} | pnmtops -noturn -nocenter -scale ${reScale} - >${epsfile}" eps2eps -dLanguageLevel=3 ${epsfile} thisTmp${epsfile} && mv thisTmp${epsfile} ${epsfile} done |