#! /bin/tcsh -f # # create an image of a 4.65" CD label James Holton 8-19-07 # with the ALS logo and 8.3.1 insignia # # goto Setup Help: cat << EOF usage: makelabel.com [100dpi] [8.3.1] [CD|DVD] options: -beamline 8.3.1 - where 8.3.1 is the beamline to print in the left margin -media DVD - where DVD is the media type text to print in the left margin -dpi 200 - where 200 is the number of pixels per inch to use in rendering the label -title "Title" - where "Title" is the bold text to print at the top and bottom of the disk -note "Note" - where "Note" is the text to print under the logo in the right margin -serial "1234" - where "1234" is the DVD serial number to print onto the label EOF exit 9 Setup: # label is 4.65" wide, 1.6" center # set tempfile = /tmp/meritline_label$$ set tempfile = tempfile set synchrotron = ALS set beamline = "8.3.1" set logo_URL = "http://www.lbl.gov/imagesmain/logo.gif" set dpi = 200 set media = DVD set outfile = label.miff #touch this >& /dev/null #if( $status) set outfile = /tmp/$outfile # seems to work for latest version of ImageMagick set bfont = Helvetica-Bold set font = Helvetica set syncpos = ( 0.322 2.2765 ) set blpos = ( 0.3229 2.7975 ) set mediapos = ( 0.1725 1.742 ) set logopos = ( 3.325 1.845 ) # test to see if this font works set test = `convert -size 10x10 -depth 1 -font $bfont -draw "text 5,5 xxx" NULL:white BMP:/dev/null |& wc -l` if("$test" != "0") then set bfont = ArialBold set font = Arial set syncpos = ( 0.325 2.295 ) set blpos = ( 0.3279 2.8175 ) set mediapos = ( 0.175 1.745 ) endif set test = `convert -size 10x10 -depth 1 -font $bfont -draw "text 5,5 xxx" NULL:white BMP:/dev/null |& wc -l` if("$test" != "0") then echo "ERROR: no valid fonts" endif #echo "font=$font" set i = 0 while ( $i < $#argv ) @ i = ( $i + 1 ) @ j = ( $i + 1 ) set arg = "$argv[$i]" if("$arg" =~ *dpi) then set dpi = `echo $arg | awk '{print $1+0}'` continue endif if("$arg" == "-dpi" && $#argv > $j) then set dpi = `echo "$argv[$j]" | awk '{printf "%d", $1}'` @ i = ( $i + 1 ) continue endif if("$arg" == "CD") then set media = "CD" continue endif if("$arg" == "DVD") then set media = "DVD" continue endif if("$arg" == "-media" && $#argv > $j) then set media = "$argv[$j]" @ i = ( $i + 1 ) continue endif if("$arg" == "-beamline" && $#argv >= $j) then set beamline = "$argv[$j]" @ i = ( $i + 1 ) continue endif if("$arg" == "-synchrotron" && $#argv >= $j) then set synchrotron = "$argv[$j]" @ i = ( $i + 1 ) continue endif set temp = `echo $arg | awk -F "[.]" 'NF==3 && $1+0>0 && $1+0<13 && $2!~/[^0-9]/ && $3!~/[^0-9]/'` if("$temp" != "") then set beamline = "$arg" continue endif end set logo_URL = "http://www.lbl.gov/imagesmain/logo.gif" if("$synchrotron" == "SSRL") set logo_URL = "http://www-ssrl.slac.stanford.edu/images/logoheader.gif" if("$synchrotron" == "APS") set logo_URL = "" if("$synchrotron" == "ESRF") set logo_URL = "" echo "making $media label: $outfile at ${dpi}dpi for $synchrotron $beamline" ################################################# # graphics # create a template CD/DVD label rm -f $outfile >& /dev/null set labelsize = `echo $dpi | awk '{printf "%dx%d", 4.65*$1, 4.65*$1}'` #convert -size $labelsize -depth 8 -fill white -draw "color 0,0 reset" nutn.NULL $outfile convert -size $labelsize -depth 8 -colorspace RGB -fill white -draw "color 1,1 reset" NULL:white $outfile circles: ################################################# # circles if (! $?debug) goto logo # make the outer circle set circle = `echo 2.325 2.325 2.325 $dpi | awk '{printf "%d,%d %d,%d", $1*$NF, $2*$NF, ($1+$3)*$NF, $2*$NF}'` # make the inner circle set circle2 = `echo 2.325 2.325 0.8 $dpi | awk '{printf "%d,%d %d,%d", $1*$NF, $2*$NF, ($1+$3)*$NF, $2*$NF}'` convert -fill none -stroke black -strokewidth 1 -draw "circle $circle" -draw "circle $circle2" $outfile ${tempfile}.miff mv ${tempfile}.miff $outfile logo: ################################################# # LOGO # make sure we have the logo image if(-e /data/calibrations/images/logo.gif) then cp -p /data/calibrations/images/logo.gif ${tempfile}logo.gif endif if(! -e ${tempfile}logo.gif) then wget -O ${tempfile}logo.gif $logo_URL >& /dev/null if (-s ${tempfile}logo.gif && ! -e "/data/calibrations/images/logo.gif" && -w /data/calibrations/images) then cp ${tempfile}logo.gif /data/calibrations/images/logo.gif endif endif set pos1 = `echo $syncpos $dpi | awk '{printf "%d,%d", $1*$NF,$2*$NF}'` set pos2 = `echo $blpos $dpi | awk '{printf "%d,%d", $1*$NF,$2*$NF}'` set pos3 = `echo $mediapos $dpi | awk '{printf "%d,%d", $1*$NF,$2*$NF}'` set pos4 = `echo 1.8 2.5 $dpi | awk '{printf "%d,%d", $1*$NF,$2*$NF}'` set psize_big = `echo 45 $dpi | awk '{printf "%d", $1*$2/100}'` set psize_date = `echo 17 $dpi | awk '{printf "%d", $1*$2/100}'` set psize_file = `echo 14 $dpi | awk '{printf "%d", $1*$2/100}'` set image = `echo $logopos 1.21 0.81 $dpi | awk '{printf "%d,%d %d,%d", $1*$NF, $2*$NF, $3*$NF, $4*$NF}'` convert -depth 8 -colorspace RGB \ -fill black -font $bfont -pointsize $psize_big \ -draw "text $pos1 '${synchrotron}'" \ -draw "text $pos2 '${beamline}'" \ -fill black -font $font -pointsize $psize_date \ -draw "text $pos3 '${media}-R data archive'" \ -draw "image Over $image ${tempfile}logo.gif" \ $outfile ${outfile}.miff mv ${outfile}.miff $outfile rm -f ${tempfile}logo.gif exit ################################################# ################################################# #################################################