/**
		 * create the image
		 * @param string Name and path of the image to create
		 */
		function createImage($imagename) {
		    global $panic, $debug;
			$content = getDBCell("pgn_label", "CONTENT", "FKID = $this->fkid");
			$image = new NXImageApi("", $imagename, false);
			$image->createCanvas($this->getOption("NUMBER2"),$this->getOption("NUMBER3"), $this->getOption("TEXT3"));
			$image->font = $this->getOption("TEXT4");
  			$image->fontsize = $this->getOption("NUMBER1");
  			$image->fontstyle = $this->getOption("TEXT5");
  			$image->gravity = $this->getOption("TEXT1");  			
  			$image->fillcolor = $this->getOption("TEXT2");
  			$image->drawText($content, 0, 0);  			
  			$image->save();	
		}
		/**
		 * apply automatic modifications of the uploaded images as specified in a ClusterTemplateItem.
		 */
		function applyAutoMod($filename) {
			global $c;
			$maxwidth = $this->pgnref->getOption("TEXT1");
			$maxheight = $this->pgnref->getOption("TEXT2");
			
			if (($maxwidth != "") || ($maxheight != "")) {
				$imageapi = new NXImageApi($c["devfilespath"]."orig_".$filename, $c["devfilespath"].$filename);
				if (stristr($maxwidth, "%") && stristr($maxheight, "%")) {
					$imageapi->resizeRelative($maxwidth, $maxheight);
				} else if (is_numeric($maxwidth) && is_numeric($maxwidth)) {
					$imageapi->resizeAbsolute($maxwidth, $maxheight);
				}
				$imageapi->save();
			}
		}
 /**
  * resize only content of an image keeping original canvas dimensions. "empty" parts will have $bgcolor. (constrained proportions)
  * @param integer delta number of pixels to grow or shrink
  * @param string background-color
  * @param optional boolean set to true to allow image to grow
  * @param optional string filter used to resize (grow) the image. Choose from Cubic, Quadratic, Gaussian, Bessel, Hamming, Mitchell, Triangle, Lanczos (default), Sinc, Catrom, Hermite, Hanning, Blackman, Point, Box		 
  */
 function resizeContent($delta, $bgcolor, $allowgrow = false, $filter = "")
 {
     $tmp = new NXImageApi($this->tempfile, $this->tempfile, $this->debug);
     $this->createCanvas($this->width(), $this->height(), $bgcolor);
     $tmp->resizeAbsolute($tmp->width() + $delta, $tmp->height() + $delta, $allowgrow, $filter);
     $gravity = isset($this->gravity) ? " -gravity {$this->gravity} " : "";
     $this->_execute("composite {$gravity} -compose Over {$tmp->tempfile} {$this->tempfile} {$this->tempfile}");
     $tmp->deltemp();
 }
	  /**
	   * Paints a text as image.
	   * All configuration variables must be set before!
	   * @param string TExt to paint
	   * @param integer Offset on X-Axis
	   * @param integer Offset on Y-Axis
	   */
	  function paint($text, $x=0, $y=0) {
	  		global $cds;
	  		$name = $this->getImageName($text);
	  		if ($name != "") {
	  			$image = new NXImageApi("", $cds->path."images/".$name, false);
				$image->createCanvas($this->width, $this->height, $this->bgcolor);
				$image->font = $this->font;
  				$image->fontsize = $this->fontsize;
  				$image->gravity = $this->gravity;  			
  				$image->fillcolor = $this->textcolor;
  				$image->fontstyle = $this->fontstyle;
  				$image->drawText($text, $x, $y);  			
  				$image->save();	  				
	  		} 
			return '<img src="'.$cds->docroot.'images/'.$this->getImageName2($text).'" width="'.$this->width.'" height="'.$this->height.'" alt="'.$text.'" border="0">';
	  }