| 1 |
#!/bin/ksh |
| 2 |
|
| 3 |
set -x |
| 4 |
|
| 5 |
purpose="manual" |
| 6 |
rotation="" |
| 7 |
|
| 8 |
# arguments for ImageMagick's 'convert' utility. |
| 9 |
# note that docbook seems to have some problems when given PNG files with |
| 10 |
# transparency. Unfortunately, convert seems to like to *sometimes* generate |
| 11 |
# an image with transparency. The plethora of options below seems to be |
| 12 |
# necessary in order to avoid this. It also trims the white border from the image which |
| 13 |
# allows it to be larger on the page. |
| 14 |
|
| 15 |
full_density=90 |
| 16 |
thumb_density=50 |
| 17 |
antialias="" # "+antialias" |
| 18 |
convert_args="-bordercolor white -border 1 -trim +matte" |
| 19 |
|
| 20 |
for arg;do |
| 21 |
if [[ $arg = "-h" || $arg = "-help" || $arg = "--help" ]] |
| 22 |
then |
| 23 |
echo "" |
| 24 |
echo "convert_example_outputs" |
| 25 |
echo "Possible options:" |
| 26 |
echo " -manual : convert the examples for the manual (default)" |
| 27 |
echo " -tutorial : convert the examples for the tutorial" |
| 28 |
echo "" |
| 29 |
exit |
| 30 |
fi |
| 31 |
|
| 32 |
if [[ $arg = "-tutorial" ]] |
| 33 |
then |
| 34 |
purpose="tutorial" |
| 35 |
rotation=" -rotate 90 " |
| 36 |
fi |
| 37 |
|
| 38 |
if [[ $arg = "-manual" ]] |
| 39 |
then |
| 40 |
purpose="manual" |
| 41 |
rotation=" -rotate 90 " |
| 42 |
fi |
| 43 |
|
| 44 |
done |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
# create any directories that do not already exist |
| 50 |
|
| 51 |
# mkdir -p examples/fortran/epsi |
| 52 |
mkdir -p examples/$purpose/fortran/png |
| 53 |
mkdir -p examples/$purpose/c/png |
| 54 |
# mkdir -p examples/magml/epsi |
| 55 |
mkdir -p examples/$purpose/magml/png |
| 56 |
mkdir -p examples/$purpose/python/png |
| 57 |
|
| 58 |
|
| 59 |
# convert all PostScript output files in 'ps' directory |
| 60 |
# to epsi and png formats and place in in 'epsi' and 'png' directories. |
| 61 |
|
| 62 |
for psfile in examples/$purpose/fortran/ps/*.ps |
| 63 |
do |
| 64 |
echo "[Converting $psfile]" |
| 65 |
bname=`basename $psfile .ps` |
| 66 |
outdir="examples/$purpose/fortran/png" |
| 67 |
# ps2epsi $psfile "examples/fortran/epsi/$bname.epsi" |
| 68 |
convert -density $full_density $antialias $rotation $convert_args $psfile "$outdir/$bname.png" |
| 69 |
|
| 70 |
# for the tutorial, we want to have slightly smaller images for the HTML pages |
| 71 |
if [[ $purpose = "tutorial" ]] |
| 72 |
then |
| 73 |
thumbname="${bname}_thumb" |
| 74 |
convert -density $thumb_density $antialias $rotation $convert_args $psfile "$outdir/$thumbname.png" |
| 75 |
fi |
| 76 |
|
| 77 |
done |
| 78 |
|
| 79 |
for psfile in examples/$purpose/c/ps/*.ps |
| 80 |
do |
| 81 |
echo "[Converting $psfile]" |
| 82 |
bname=`basename $psfile .ps` |
| 83 |
outdir="examples/$purpose/c/png" |
| 84 |
# ps2epsi $psfile "examples/fortran/epsi/$bname.epsi" |
| 85 |
convert -density $full_density $antialias $rotation $convert_args $psfile "$outdir/$bname.png" |
| 86 |
|
| 87 |
# for the tutorial, we want to have slightly smaller images for the HTML pages |
| 88 |
if [[ $purpose = "tutorial" ]] |
| 89 |
then |
| 90 |
thumbname="${bname}_thumb" |
| 91 |
convert -density $thumb_density $antialias $rotation $convert_args $psfile "$outdir/$thumbname.png" |
| 92 |
fi |
| 93 |
|
| 94 |
done |
| 95 |
|
| 96 |
for psfile in examples/$purpose/magml/ps/*.ps |
| 97 |
do |
| 98 |
echo "[Converting $psfile]" |
| 99 |
bname=`basename $psfile .ps` |
| 100 |
outdir="examples/$purpose/magml/png" |
| 101 |
# ps2epsi $psfile "examples/magml/epsi/$bname.epsi" |
| 102 |
convert -density $full_density $antialias $rotation $convert_args $psfile "$outdir/$bname.png" |
| 103 |
|
| 104 |
# for the tutorial, we want to have slightly smaller images for the HTML pages |
| 105 |
if [[ $purpose = "tutorial" ]] |
| 106 |
then |
| 107 |
thumbname="${bname}_thumb" |
| 108 |
convert -density $thumb_density $antialias $rotation $convert_args $psfile "$outdir/$thumbname.png" |
| 109 |
fi |
| 110 |
|
| 111 |
done |
| 112 |
|
| 113 |
for psfile in examples/$purpose/python/ps/*.ps |
| 114 |
do |
| 115 |
echo "[Converting $psfile]" |
| 116 |
bname=`basename $psfile .ps` |
| 117 |
outdir="examples/$purpose/python/png" |
| 118 |
# ps2epsi $psfile "examples/magml/epsi/$bname.epsi" |
| 119 |
convert -density $full_density $antialias $rotation $convert_args $psfile "$outdir/$bname.png" |
| 120 |
|
| 121 |
# for the tutorial, we want to have slightly smaller images for the HTML pages |
| 122 |
if [[ $purpose = "tutorial" ]] |
| 123 |
then |
| 124 |
thumbname="${bname}_thumb" |
| 125 |
convert -density $thumb_density $antialias $rotation $convert_args $psfile "$outdir/$thumbname.png" |
| 126 |
fi |
| 127 |
|
| 128 |
done |
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
# perform any customised steps for particular plots |
| 133 |
|
| 134 |
#dir="examples/tutorial/fortran/png" |
| 135 |
# |
| 136 |
#for root in coast_3 |
| 137 |
#do |
| 138 |
# file=$dir/${root}_m69_CYLINDRICAL_01_thumb.png |
| 139 |
# convert -rotate 270 $convert_args $file out.png |
| 140 |
# mv out.png $file |
| 141 |
# |
| 142 |
# file=$dir/${root}_m69_CYLINDRICAL_01.png |
| 143 |
# convert -rotate 270 $convert_args $file out.png |
| 144 |
# mv out.png $file |
| 145 |
# |
| 146 |
# file=$dir/${root}_01_thumb.png |
| 147 |
# convert -rotate 270 $convert_args $file out.png |
| 148 |
# mv out.png $file |
| 149 |
# |
| 150 |
# file=$dir/${root}_01.png |
| 151 |
# convert -rotate 270 $convert_args $file out.png |
| 152 |
# mv out.png $file |
| 153 |
#done |
| 154 |
|
| 155 |
|