#!/usr/bin/zsh # Hard coded hack for the standard definition images of our XL30S # On mag = 29736.822, 1 um scale bar measured 215 pixels wide w=712 h=484 mag=`awk '/Magnif/ {print $3}' $1 | sed 's/.$//'` echo Magnification $mag tifftopnm $1 | pnmdepth 65535 > $1.tmp xsize=$((712.0/215.0/$mag*29736.822)) ysize=$((484.0/215.0/$mag*29736.822)) echo $xsize $ysize #sed doesn't work in cygwin so well: it still does the newline conversions even if you give it the -b option head -n2 $1.tmp > $1.pgm cat <> $1.pgm #xmin 0 #xmax $xsize #xunit Microns #yunit Microns #zunit SEM Signal #ymin 0 #ymax $ysize 65535 EOF #tcut -s 3 $1.tmp >> $1.pgm # Awk BINMODE also does not work awk 'BEGIN {BINMODE = "rw"} // {if (NR>3) print $0}' $1.tmp >> $1.pgm #sed -b '3 i #xmin 0\n#xmax '$xsize'\n#xunit Microns\n#yunit Microns\n#zunit SEM Signal\n#ymin 0\n#ymax '$ysize < $1.tmp > $1.pgm rm $1.tmp #cp $1.pgm $1.ppm