procedure putlabel(image,text,xpos,ypos) string image ="" {prompt="image name"} string text ="" {prompt="text to put in image"} int xpos =1 {prompt="x position label"} int ypos =1 {prompt="y position label"} string fclass ="roman" {prompt="font class (roman,greek,italic)",enum="r|g|i|roman|greek|italic"} real tvalue =32768. {prompt="text intensity value"} # @(#) task putlabel Author: R.A. Jansen -- Feb 20 1998 # @(#) # @(#) task to write a text label directly in to an IRAF image using a # @(#) pixel font library (home$pixfonts/font6x11.def). Only one size # @(#) fonts is supported at this time. The actual access of the image # @(#) pixels is done by a FORTRAN routine 'ptext.f'. This script is # @(#) just a user interface to that routine. # @(#) If 'text' begins with a '@', the remainder of 'text' is assumed # @(#) to be a file containing one or more text labels, one per line. # @(#) the format should be: [xpos] [ypos] [r|g|i] [label text]. # @(#) In this case the values of task parameters 'xpos' and 'ypos' are # @(#) ignored. Uses user-task: chkimg.cl # @(#) begin string img, txt, ftyp real val int x0, y0, ncol, nrow img = image txt = text x0 = xpos y0 = ypos ftyp = fclass val = tvalue # Check whether image exists... chkimg (img, "access", verbose=yes) if ( !chkimg.ok ) { return } img = substr(img,1,chkimg.imglen) # Check whether 'txt' refers to an input file with multiple strings... if ( substr(txt,1,1) == "@" ) { if ( !access(substr(txt,2,strlen(txt))) ) { print ("Input text file "//substr(txt,2,strlen(txt))//" not found!") return } } # Check image size... imgets(img, "i_naxis1"); ncol = int(imgets.value) imgets(img, "i_naxis1"); ncol = int(imgets.value) imgets(img, "i_naxis2"); nrow = int(imgets.value) if ( x0 < 1 ) { x0 = 1 } if ( y0 < 1 ) { y0 = 1 } if ( x0 > ncol-7 ) { x0 = ncol - 7 } if ( y0 > nrow-11 ) { y0 = nrow -11 } if ( ftyp == "roman" ) { ftyp = "r" } if ( ftyp == "greek" ) { ftyp = "g" } if ( ftyp == "italic") { ftyp = "i" } # Run executable 'ptext.exe'... if ( access("tmpptlbl.cl") ) { delete ("tmpptlbl.cl", yes, verify=no) } if ( !access("ptext.exe") ) { copy ("tasks$generic/ptext.exe", ".", verbose=no) } print ("!ptext.exe "//envget("home")//"pixfonts/font6x11 "//ftyp//" "//img//" "//str(x0)//" "//str(y0)//" "//str(val)//" "//txt, > "tmpptlbl.cl") cl < tmpptlbl.cl # Rename output image and clean up... chkimg (img//"t", "access", verbose=yes) if (chkimg.ok) { imdelete (img, yes, verify=no) imrename (img//"t", img, verbose=no) } delete ("tmpptlbl.cl", yes, verify=no) delete ("ptext.exe", yes, verify=no) end