Esempio n. 1
0
 /**
  * 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();
 }
		/**
		 * 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();
			}
		}