Пример #1
0
/*
	As of version 4.2.5 you can now "chain" your image processing for the same
	image. That is, you can process the same image to produce multiple different
	outputs. 
	For example, say you need 3 sizes of an image. By calling reset() after each 
	save, you can freely apply new transformations to produce the next image.
*/
require_once '../php_image_magician.php';
/*	Purpose: Open image
 *	Usage:	 resize('filename.type')
 * 	Params:	 filename.type - the filename to open
 */
$magicianObj = new imageLib('sample_images/racecar.jpg');
// *** Resize and add a border to the first	copy
$magicianObj->resizeImage(300, 200, 'crop');
$magicianObj->addBorder(5, '#f0f0f0');
$magicianObj->addCaptionBox('b', 40, 0, '#000', 50);
$magicianObj->addTextToCaptionBox('Racecar 2000');
$magicianObj->saveImage('output_15.1_a.png', 100);
$magicianObj->reset();
# resets the image resource
// *** Resize and add a border to the second copy
$magicianObj->resizeImage(200, 100, 'crop');
$magicianObj->addBorder(5, '#333');
$magicianObj->saveImage('output_15.1_b.png', 100);
$magicianObj->reset();
# resets the image resource
// *** Resize and add a border to the third	copy
$magicianObj->resizeImage(200, 200, 'crop');
$magicianObj->addBorder(5, '#333');
$magicianObj->saveImage('output_15.1_c.png', 100);
Пример #2
0
 public function manipImageUpload($tableName, $tableIdVal, $sDim = '', $mDim = '', $bDim = '', $exact = false, $isDebug = false, $mbDim = '', $lDim = '', $boDim = '', $resizeType = 'crop')
 {
     //var_dump($this->fileNameNew);
     if ($this->validate(IMG_EXTENSION, IMG_MAX_SIZE)) {
         //if ($this->uploadPhysical(PROJECT_UPLOAD_LRG_PATH, $this->fileNameNew, '', $this->fileNameNew)) {
         if ($this->uploadPhysical(PROJECT_UPLOAD_LRG_PATH, $this->fileNameNew, PROJECT_UPLOAD_LRG_PATH, $this->fileNameNew)) {
             $lWidth = $this->image['width'];
             $lHeight = $this->image['height'];
             $lDimensions = $lWidth . 'x' . $lHeight;
             // *** 1) Initialise / load image
             $resizeObj = new imageLib(PROJECT_UPLOAD_LRG_PATH . $this->getNameNew());
             /**
              * Resize copy to PROJECT_UPLOAD_SML_PATH if $sDim passed
              */
             $sWidth = 0;
             $sHeight = 0;
             $sDimensions = '';
             if ($sDim) {
                 $sDimensions = split('x', $sDim);
                 $sWidth = $sDimensions[0];
                 $sHeight = $sDimensions[1];
                 // *** 2) Resize image (options: exact, portrait, landscape, auto, crop)
                 $resizeObj->resizeImage($sWidth, $sHeight, $resizeType);
                 // *** 3) Save image
                 $resizeObj->saveImage(PROJECT_UPLOAD_SML_PATH . $this->getNameNew(), 100);
                 $resizeObj->reset();
                 //$sWidth = round($this->image['widthNew'], 0);
                 //$sHeight = round($this->image['heightNew'], 0);
                 //$sDimensions = $sWidth . 'x' . $sHeight;
             }
             /**
              * Resize copy to PROJECT_UPLOAD_MED_PATH if $mDim passed
              */
             $mWidth = 0;
             $mHeight = 0;
             $mDimensions = '';
             if ($mDim) {
                 $mDimensions = split('x', $mDim);
                 $mWidth = $mDimensions[0];
                 $mHeight = $mDimensions[1];
                 //$resizeObj = new imageLib(PROJECT_UPLOAD_LRG_PATH . $this->getNameNew());
                 $resizeObj->resizeImage($mWidth, $mHeight, $resizeType);
                 $resizeObj->saveImage(PROJECT_UPLOAD_MED_PATH . $this->getNameNew(), 100);
                 $resizeObj->reset();
                 //$mWidth = round($this->image['widthNew'], 0);
                 //$mHeight = round($this->image['heightNew'], 0);
                 //$mDimensions = $mWidth . 'x' . $mHeight;
             }
             /**
              * Resize copy to PROJECT_UPLOAD_MEDBIG_PATH if $mbDim passed
              */
             $mbWidth = 0;
             $mbHeight = 0;
             $mbDimensions = '';
             if ($mbDim) {
                 $mbDimensions = split('x', $mbDim);
                 $mbWidth = $mbDimensions[0];
                 $mbHeight = $mbDimensions[1];
                 //$resizeObj = new imageLib(PROJECT_UPLOAD_LRG_PATH . $this->getNameNew());
                 $resizeObj->resizeImage($mbWidth, $mbHeight, $resizeType);
                 $resizeObj->saveImage(PROJECT_UPLOAD_MEDBIG_PATH . $this->getNameNew(), 100);
                 $resizeObj->reset();
                 //$mbWidth = round($this->image['widthNew'], 0);
                 //$mbHeight = round($this->image['heightNew'], 0);
                 //$mbDimensions = $mbWidth . 'x' . $mbHeight;
             }
             /**
              * Resize copy to PROJECT_UPLOAD_BIG_PATH if $bDim passed
              */
             if ($bDim) {
                 $bDimensions = split('x', $bDim);
                 $bWidth = $bDimensions[0];
                 $bHeight = $bDimensions[1];
                 //$resizeObj = new imageLib(PROJECT_UPLOAD_LRG_PATH . $this->getNameNew());
                 $resizeObj->resizeImage($bWidth, $bHeight, $resizeType);
                 $resizeObj->saveImage(PROJECT_UPLOAD_BIG_PATH . $this->getNameNew(), 100);
                 $resizeObj->reset();
                 //$bWidth = round($this->image['widthNew'], 0);
                 //$bHeight = round($this->image['heightNew'], 0);
                 //$bDimensions = $bWidth . 'x' . $bHeight;
             }
             /**
              * Resize copy to PROJECT_UPLOAD_LRG_PATH if $bDim passed
              */
             if ($lDim) {
                 $lDimensions = split('x', $lDim);
                 $lWidth = $lDimensions[0];
                 $lHeight = $lDimensions[1];
                 //$resizeObj = new imageLib(PROJECT_UPLOAD_LRG_PATH . $this->getNameNew());
                 $resizeObj->resizeImage($lWidth, $lHeight, $resizeType);
                 $resizeObj->saveImage(PROJECT_UPLOAD_LRG_PATH . $this->getNameNew(), 100);
                 $resizeObj->reset();
                 //$lWidth = round($this->image['widthNew'], 0);
                 //$lHeight = round($this->image['heightNew'], 0);
                 //$lDimensions = $lWidth . 'x' . $lHeight;
             }
             if ($boDim) {
                 $boDimensions = split('x', $boDim);
                 $boWidth = $boDimensions[0];
                 $boHeight = $boDimensions[1];
                 //$resizeObj = new imageLib(PROJECT_UPLOAD_LRG_PATH . $this->getNameNew());
                 $resizeObj->resizeImage($boWidth, $boHeight, 'crop');
                 $resizeObj->saveImage(PROJECT_UPLOAD_BO_PATH . $this->getNameNew(), 100);
                 $resizeObj->reset();
                 //$lWidth = round($this->image['widthNew'], 0);
                 //$lHeight = round($this->image['heightNew'], 0);
                 //$lDimensions = $lWidth . 'x' . $lHeight;
             }
             return true;
         } else {
             $_SESSION['errorMsgs'] = "Sorry! An error occured while uploading the file \"{$this->fileName}\"";
             $this->ErrorMsg = "Sorry! An error occured while uploading the file \"{$this->fileName}\"";
             return false;
         }
     } else {
         return false;
     }
 }