コード例 #1
0
ファイル: image.php プロジェクト: benmalcom/php-image-resize
 public function save()
 {
     $args_list = func_get_args();
     $response = "";
     for ($i = 0; $i < count($args_list); $i++) {
         if (empty($args_list[$i])) {
             $response = "Some fields are empty";
             break;
         }
     }
     $basename = basename($this->file['name']);
     $ext = substr($basename, strpos($basename, ".") + 1);
     if (empty($response)) {
         if (in_array($this->name, scandir($this->uploadDir))) {
             $response = "Image with this name already exists in the directory!";
         } else {
             if (move_uploaded_file($this->file['tmp_name'], $this->uploadDir . $basename)) {
                 $magic = new imageLib($this->uploadDir . $basename);
                 $magic->resizeImage($this->width, $this->height, 'exact', true);
                 $magic->saveImage($this->uploadDir . $this->name . "." . $ext, 100);
                 unlink($this->uploadDir . $basename);
                 $response = "Resized image stored as " . $this->uploadDir . $this->name . "." . $ext;
             }
         }
     }
     return $response;
 }
コード例 #2
0
function convertPngToBmp($name)
{
    // *** Include PHP Image Magician library
    require_once 'php_image_magician.php';
    // *** Open PNG image
    $magicianObj = new imageLib($name . '.png');
    // *** Save image as a BMP
    $magicianObj->saveImage($name . '.bmp');
}
コード例 #3
0
ファイル: utils.php プロジェクト: kirkbauer2/kirkxc
function create_img_gd($imgfile, $imgthumb, $newwidth, $newheight = "")
{
    require_once 'php_image_magician.php';
    $magicianObj = new imageLib($imgfile);
    // *** Resize to best fit then crop
    $magicianObj->resizeImage($newwidth, $newheight, 'crop');
    // *** Save resized image as a PNG
    $magicianObj->saveImage($imgthumb);
}
コード例 #4
0
ファイル: Api.php プロジェクト: korejwo/projekt2
 protected function resize($targetFolder, $file, $beforeName, $x, $y)
 {
     require_once APPPATH . 'i18n/php_image_magician.php';
     $magic = new imageLib($file);
     $magic->resizeImage($x, $y, 1);
     $newfile = $targetFolder . "/" . $beforeName . basename($file);
     $magic->saveImage($newfile);
     $magic_crop = new imageLib($newfile);
     $magic_crop->cropImage($x, $y);
     $magic_crop->saveImage($newfile);
 }
コード例 #5
0
ファイル: utils.php プロジェクト: alexmon1989/fcssadon.ru
function create_img($imgfile, $imgthumb, $newwidth, $newheight = "")
{
    if (image_check_memory_usage($imgfile, $newwidth, $newheight)) {
        require_once 'php_image_magician.php';
        $magicianObj = new imageLib($imgfile);
        $magicianObj->resizeImage($newwidth, $newheight, 'auto');
        $magicianObj->saveImage($imgthumb, 80);
        return true;
    } else {
        return false;
    }
}
コード例 #6
0
ファイル: utils.php プロジェクト: Vatia13/funtime
function create_img($imgfile, $imgthumb, $newwidth, $newheight = "", $option = "crop")
{
    $timeLimit = ini_get('max_execution_time');
    set_time_limit(30);
    $result = false;
    if (image_check_memory_usage($imgfile, $newwidth, $newheight)) {
        require_once 'php_image_magician.php';
        $magicianObj = new imageLib($imgfile);
        $magicianObj->resizeImage($newwidth, $newheight, $option);
        $magicianObj->saveImage($imgthumb, 80);
        $result = true;
    }
    set_time_limit($timeLimit);
    return $result;
}
コード例 #7
0
<?php

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/paradise.jpg');
/*	Purpose: Create image reflection
 *	Usage:	 addReflection([reflection_height], [starting_transparency], [inside_image], [background_color], [stretch])
 * 	Params:	 reflection_height - the height of the reflection
 *			 starting_transparency - The amount of transparency to start with
 *				100 = no transparency. Ideally you want this value between 0 
 *				and 15 for best results.
 *			 inside_image - if set to 'true' then the reflection will be 
 *				placed inside the image. I.E., the image will remain the 
 *				same size. The top of the image will become cropped. 
 *				'false' will append the reflect to the bottom of the image
 *				meaning the image height will increase by the reflection
 *				height amount.
 *			background_color - the color the transparency will fade to.
 *			stretch - If true, this will stretch the transparency mask to
 *				cover the whole of the reflection height specified. Set to 
 *				False by default as it can cause banding.
 *
 */
$magicianObj->addReflection(75, 10, false, '#fff', true);
/*	Purpose: Save image
 *	Usage:	 saveImage('[filename.type]', [quality])
 * 	Params:	 filename.type - the filename and file type to save as
 * 			 quality - (optional) 0-100 (100 being the highest (default))
コード例 #8
0
ファイル: 2.7_vintage.php プロジェクト: yasoon/yasoon
<?php

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');
/*	Purpose: Convert image to a vintage look
 *	Usage:	 vintage()
 * 	Params:	 n/a
 */
$magicianObj->vintage();
/*	Purpose: Save image
 *	Usage:	 saveImage('[filename.type]', [quality])
 * 	Params:	 filename.type - the filename and file type to save as
 * 			 quality - (optional) 0-100 (100 being the highest (default))
 *				Only applies to jpg & png only
 */
$magicianObj->saveImage('output_2.7.png', 100);
コード例 #9
0
ファイル: file2.class.php プロジェクト: aliihaidar/pso
 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;
     }
 }
コード例 #10
0
ファイル: imgs.php プロジェクト: Jakooth/forapi
 $file = "{$folder}/{$_POST['path']}-{$_POST['subtype']}.{$mime}";
 $convertFile = "{$folder}/{$_POST['path']}-{$_POST['subtype']}.jpg";
 /**
  * Check if driectory exists.
  */
 if (!file_exists($tagFolder)) {
     mkdir($tagFolder);
 }
 if (!file_exists($folder)) {
     mkdir($folder);
 }
 move_uploaded_file($_FILES['img']['tmp_name'], $file);
 /**
  * Now do the image resize and conversion.
  */
 $magic = new imageLib($file);
 $w = $magic->getOriginalWidth();
 $h = $magic->getOriginalHeight();
 switch ($_POST['subtype']) {
     case 'ps3':
         if ($w == '445' && $h == '512') {
             goto end;
         }
         $magic->resizeImage(445, 512, 'crop');
         break;
     case 'ps4':
     case 'one':
         if ($w == '410' && $h == '512') {
             goto end;
         }
         $magic->resizeImage(410, 512, 'crop');
コード例 #11
0
ファイル: 2.5_sepia.php プロジェクト: yasoon/yasoon
<?php

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');
/*	Purpose: Convert image to sepia
 *	Usage:	 sepia()
 * 	Params:	 n/a
 */
$magicianObj->sepia();
/*	Purpose: Save image
 *	Usage:	 saveImage('[filename.type]', [quality])
 * 	Params:	 filename.type - the filename and file type to save as
 * 			 quality - (optional) 0-100 (100 being the highest (default))
 *				Only applies to jpg & png only
 */
$magicianObj->saveImage('output_2.5.png', 100);
コード例 #12
0
ファイル: images.php プロジェクト: PotsonHumer/OGS_V2
 public static function resize($path = false, $width = false, $height = false, $save = false)
 {
     require_once ROOT_PATH . "class/editor/filemanager/include/php_image_magician.php";
     require_once ROOT_PATH . "class/editor/filemanager/include/utils.php";
     switch (true) {
         case (empty($width) || $width == 'auto') && (empty($height) || $height == 'auto'):
             return false;
             break;
         case empty($width) || $width == 'auto':
             $option = 1;
             break;
         case empty($height) || $height == 'auto':
             $option = 2;
             break;
         default:
             $option = 0;
             break;
     }
     $path = str_replace(CORE::$cfg['host'], ROOT_PATH, $path);
     $magicianObj = new imageLib($path);
     #$magicianObj->setForceStretch(false);
     $magicianObj->resizeImage($width, $height, $option);
     #$imagick = new Imagick($path);
     #$imagick->resizeImage($width,$height,Imagick::FILTER_LANCZOS,false);
     #$imagick->scaleImage($width,$height);
     $filename = basename($path);
     $file_extension = strtolower(substr(strrchr($filename, "."), 1));
     /*
     switch($file_extension){
         case "gif": $ctype="image/gif"; break;
         case "png": $ctype="image/png"; break;
         case "jpeg":
         case "jpg": $ctype="image/jpeg"; break;
         default:
     }
     
     header('Content-type: '.$ctype);
     */
     #echo $imagick->getImageBlob();
     if (empty($save)) {
         $magicianObj->displayImage($file_extension);
     } else {
         $magicianObj->saveImage($save, 100);
     }
 }
コード例 #13
0
<?php

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');
/*	Purpose: Add a watermark to your image
 *	Usage:	 addWatermark([watermark_image], [position], [padding])
 * 	Params:	 watermark_image - the image to use as your watermark
 * 			 position - choose from the below options
 * 
 * 				tl = top left,
 * 				t  = top (middle), 
 * 				tr = top right,
 * 				l  = left,
 * 				m  = middle,
 * 				r  = right,
 * 				bl = bottom left,
 * 				b  = bottom (middle),
 * 				br = bottom right
 *
 * 			 padding - This moves the image away from the edges (in pixels)
 *	Output:	 Adds a watermark image to the bottom-right corner, 50px away 
 *  		 from the bottom and right edges, of your image
 */
$magicianObj->addWatermark('sample_images/monkey.png', 'br', 50);
/*	Purpose: Save image
 *	Usage:	 saveImage('[filename.type]', [quality])
 * 	Params:	 filename.type - the filename and file type to save as
コード例 #14
0
<?php

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');
/*	Purpose: Convert image to greyscale
 *	Usage:	 greyScaleDramatic()
 * 	Params:	 n/a
 */
$magicianObj->greyScaleDramatic();
/*	Purpose: Save image
 *	Usage:	 saveImage('[filename.type]', [quality])
 * 	Params:	 filename.type - the filename and file type to save as
 * 			 quality - (optional) 0-100 (100 being the highest (default))
 *				Only applies to jpg & png only
 */
$magicianObj->saveImage('output_2.3.png', 100);
コード例 #15
0
<?php

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');
/*	Purpose: Convert image to greyscale
 *	Usage:	 greyScaleEnhanced()
 * 	Params:	 n/a
 */
$magicianObj->greyScaleEnhanced();
/*	Purpose: Save image
 *	Usage:	 saveImage('[filename.type]', [quality])
 * 	Params:	 filename.type - the filename and file type to save as
 * 			 quality - (optional) 0-100 (100 being the highest (default))
 *				Only applies to jpg & png only
 */
$magicianObj->saveImage('output_2.2.png', 100);
コード例 #16
0
ファイル: 5.2_text_advanced.php プロジェクト: yasoon/yasoon
<?php

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');
/*	Purpose: Add text to your image
 *	Usage:	 addText([text], [position], [padding], [font_color], [font_size], [angle], [font])
 * 	Params:	 text - the string of text to add
 * 			 position - Specified by "width x height". EG: 200 x 300
 * 			 padding - Ignored when specifying exact pixel location
 *			 font_color - The color of the font
 *			 font_size - The size of the font in pixels
 *			 angle - The angle of the text in degress
 *			 font - You can supply your own ttf font. Pass in the name and
 *				path
 *	Output:	 This will add the word "test" 20px in and 30px down on the 
 *			 original image. The text will be gray (#ccc), 12px high, read
 * 				left to right (angle = 0) and will use the font arialbd.ttf
 *			 default color, white.
 */
$magicianObj->addText('test', '20x30', 0, '#ccc', 12, 0, 'image_lib/fonts/arimo.ttf');
/*	Purpose: Save image
 *	Usage:	 saveImage('[filename.type]', [quality])
 * 	Params:	 filename.type - the filename and file type to save as
 * 			 quality - (optional) 0-100 (100 being the highest (default))
 *				Only applies to jpg & png only
 */
$magicianObj->saveImage('output_5.2.png', 100);
コード例 #17
0
ファイル: 3.1_rotate_basic.php プロジェクト: yasoon/yasoon
<?php

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');
/*	Purpose: Rotate image
 *	Usage:	 rotate([direction])
 * 	Params:	 direction - choose from the below options
 *
 *				left - rotate the image left (90 degress)
 *				right - rotate the image right (270 degrees)
 *				upside - rotate the image upside down (180 degress)
 */
$magicianObj->rotate('left');
/*	Purpose: Save image
 *	Usage:	 saveImage('[filename.type]', [quality])
 * 	Params:	 filename.type - the filename and file type to save as
 * 			 quality - (optional) 0-100 (100 being the highest (default))
 *				Only applies to jpg & png only
 */
$magicianObj->saveImage('output_3.1.png', 100);
コード例 #18
0
<?php

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/zoex.jpg');
$magicianObj = new imageLib('sample_images/racecar.jpg');
/*	Purpose: Add a caption box to your image. The intended purpose is to 
 *			 allow text to be easier to read by placing it on a caption box
 *	Usage:	 addCaptionBox([side], [thickness], [padding], [color], [transparency])
 * 	Params:	 side - the side of the image to display the box. The options are:
 *
 *     			t = top of the image
 *				r = right side of the image
 *				b = bottom of the image
 *				l = left side of the image
 *
 *			thickness - how wide you want the caption box, in pixel.
 *			padding - distance from the caption box to the image edge.
 *			color - the color of the caption box
 *			transparency - how transparent the caption box is. 0-100. 
 *				100 being not transparent at all.
 */
$magicianObj->addCaptionBox('b', 40, 0, '#000', 50);
$magicianObj->addTextToCaptionBox('Racecar 2000');
/*	Purpose: Save image
 *	Usage:	 saveImage('[filename.type]', [quality])
 * 	Params:	 filename.type - the filename and file type to save as
 * 			 quality - (optional) 0-100 (100 being the highest (default))
コード例 #19
0
ファイル: 2.6_negative.php プロジェクト: yasoon/yasoon
<?php

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');
/*	Purpose: Convert image to a negative
 *	Usage:	 negative()
 * 	Params:	 n/a
 */
$magicianObj->negative();
/*	Purpose: Save image
 *	Usage:	 saveImage('[filename.type]', [quality])
 * 	Params:	 filename.type - the filename and file type to save as
 * 			 quality - (optional) 0-100 (100 being the highest (default))
 *				Only applies to jpg & png only
 */
$magicianObj->saveImage('output_2.6.png', 100);
コード例 #20
0
<?php

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');
/*	Purpose: Resize image
 *	Usage:	 resizeImage([width], [height], [resize type], [sharpen])
 * 	Params:	 width - the new width to resize to
 *			 height - the new height to resize to
 *			 resize type - choose from the below options
 *
 *      exact = The exact height and width dimensions you set. (Default)
 *      portrait = Whatever height is passed in will be the height that
 *          is set. The width will be calculated and set automatically 
 *          to a the value that keeps the original aspect ratio. 
 *      landscape = The same but based on the width. We try make the image 
 *         the biggest size we can while stil fitting inside the box size
 *      auto = Depending whether the image is landscape or portrait, this
 *          will automatically determine whether to resize via 
 *          dimension 1,2 or 0
 *      crop = Will resize and then crop the image for best fit. You can 
 *			pass in an array with the crop position ("t", "bl", etc) or
 *			the exact position. eg. "50x60".
 *	
 *			 sharpen - set as true if you would like shapening applied to 
 *				to your resized image    
 */
$magicianObj->resizeImage(200, 200, array('crop', 'tr'), true);
コード例 #21
0
ファイル: 6.1_border.php プロジェクト: yasoon/yasoon
<?php

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');
/*	Purpose: Add a border to the inside of your image
 *	Usage:	 addBorder([size], [color])
 * 	Params:	 size - Size in pixels
 *			 color - the color of the boder	(optional. Default is white)
 *	Output:	 This will add a 5px gray border to your image
 */
$magicianObj->addBorder(5, '#cccccc');
/*	Purpose: Save image
 *	Usage:	 saveImage('[filename.type]', [quality])
 * 	Params:	 filename.type - the filename and file type to save as
 * 			 quality - (optional) 0-100 (100 being the highest (default))
 *				Only applies to jpg & png only
 */
$magicianObj->saveImage('output_6.1.png', 100);
コード例 #22
0
ファイル: utils.php プロジェクト: despark/ignicms
/**
* Create new image from existing file
*
* @param  string  $imgfile    Source image file name
* @param  string  $imgthumb   Thumbnail file name
* @param  int     $newwidth   Thumbnail width
* @param  int     $newheight  Optional thumbnail height
* @param  string  $option     Type of resize
*
* @return bool
* @throws \Exception
*/
function create_img($imgfile, $imgthumb, $newwidth, $newheight = null, $option = "crop")
{
    $result = false;
    if (file_exists($imgfile) || strpos($imgfile, 'http') === 0) {
        if (strpos($imgfile, 'http') === 0 || image_check_memory_usage($imgfile, $newwidth, $newheight)) {
            require_once 'php_image_magician.php';
            $magicianObj = new imageLib($imgfile);
            $magicianObj->resizeImage($newwidth, $newheight, $option);
            $magicianObj->saveImage($imgthumb, 80);
            $result = true;
        }
    }
    return $result;
}
コード例 #23
0
<?php

/*
	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');
コード例 #24
0
ファイル: 10.1_round_corners.php プロジェクト: yasoon/yasoon
<?php

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');
/*	Purpose: Round image corners
 *	Usage:	 roundCorners([radius], [bgColor])
 * 	Params:	 radius - the amount of curvature to be applied to the corner
 *			 bgColor -  the background color of the corner (allows transparency)
 */
$magicianObj->roundCorners(15, 'transparent');
/*	Purpose: Save image
 *	Usage:	 saveImage('[filename.type]', [quality])
 * 	Params:	 filename.type - the filename and file type to save as
 * 			 quality - (optional) 0-100 (100 being the highest (default))
 *				Only applies to jpg & png only
 */
$magicianObj->saveImage('output_10.1.png', 100);
コード例 #25
0
ファイル: 1.6_crop.php プロジェクト: yasoon/yasoon
<?php

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');
/*	Purpose: Resize image
 *	Usage:	 resizeImage([width], [height], [resize type], [sharpen])
 * 	Params:	 width - the width to crop to
 *			 height - the height to crop to
 *			 crop type 
 *  
 */
$magicianObj->cropImage(150, 150, 'br');
/*	Purpose: Save image
 *	Usage:	 saveImage('[filename.type]', [quality])
 * 	Params:	 filename.type - the filename and file type to save as
 * 			 quality - (optional) 0-100 (100 being the highest (default))
 *				Only applies to jpg & png only
 */
$magicianObj->saveImage('output_1.6.jpg', 100);
コード例 #26
0
ファイル: 7.1_exif.php プロジェクト: yasoon/yasoon
<?php

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/flower.jpg');
/*	Purpose: Get the EXIF information from your photo
 *	Usage:	 getExif
 * 	Params:	 n/a
 *	Output:	 Returns an array of your image EXIF information
 */
$exifArray = $magicianObj->getExif();
// *** Array values assigned to variables
$make = $exifArray['make'];
$model = $exifArray['model'];
$date = $exifArray['date'];
$exposure_time = $exifArray['exposure time'];
$aperture_value = $exifArray['aperture value'];
$f_stop = $exifArray['f-stop'];
$fnumber = $exifArray['fnumber'];
$fnumber_value = $exifArray['fnumber value'];
$iso = $exifArray['iso'];
$focal_length = $exifArray['focal length'];
$xposure_program = $exifArray['exposure program'];
$etering_mode = $exifArray['metering mode'];
$flash_status = $exifArray['flash status'];
$creator = $exifArray['creator'];
$copyright = $exifArray['copyright'];
// *** Display
コード例 #27
0
ファイル: ajax_calls.php プロジェクト: kipps/sri-lanka
         exit;
     }
     break;
 case 'save_img':
     $info = pathinfo($_POST['name']);
     if (strpos($_POST['path'], '/') === 0 || strpos($_POST['path'], '../') !== false || strpos($_POST['path'], './') === 0 || strpos($_POST['url'], 'http://s3.amazonaws.com/feather') !== 0 && strpos($_POST['url'], 'https://s3.amazonaws.com/feather') !== 0 || $_POST['name'] != fix_filename($_POST['name'], $transliteration, $convert_spaces, $replace_with) || !in_array(strtolower($info['extension']), array('jpg', 'jpeg', 'png'))) {
         response('wrong data', 400)->send();
         exit;
     }
     $image_data = file_get_contents($_POST['url']);
     if ($image_data === false) {
         response(trans('Aviary_No_Save'), 400)->send();
         exit;
     }
     require_once 'include/php_image_magician.php';
     $magicianObj = new imageLib($_POST['url']);
     $magicianObj->saveImage($current_path . $_POST['path'] . $_POST['name']);
     create_img($current_path . $_POST['path'] . $_POST['name'], $thumbs_base_path . $_POST['path'] . $_POST['name'], 122, 91);
     // TODO something with this function cause its blowing my mind
     new_thumbnails_creation($current_path . $_POST['path'], $current_path . $_POST['path'] . $_POST['name'], $_POST['name'], $current_path, $relative_image_creation, $relative_path_from_current_pos, $relative_image_creation_name_to_prepend, $relative_image_creation_name_to_append, $relative_image_creation_width, $relative_image_creation_height, $relative_image_creation_option, $fixed_image_creation, $fixed_path_from_filemanager, $fixed_image_creation_name_to_prepend, $fixed_image_creation_to_append, $fixed_image_creation_width, $fixed_image_creation_height, $fixed_image_creation_option);
     break;
 case 'extract':
     if (strpos($_POST['path'], '/') === 0 || strpos($_POST['path'], '../') !== false || strpos($_POST['path'], './') === 0) {
         response('wrong path', 400)->send();
         exit;
     }
     $path = $current_path . $_POST['path'];
     $info = pathinfo($path);
     $base_folder = $current_path . fix_dirname($_POST['path']) . "/";
     switch ($info['extension']) {
         case "zip":
コード例 #28
0
ファイル: 5.1_text_basic.php プロジェクト: yasoon/yasoon
<?php

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');
/*	Purpose: Add text to your image
 *	Usage:	 addText([text], [position], [padding])
 * 	Params:	 text - the string of text to add
 * 			 position - choose from the below options
 * 
 * 				tl = top left,
 * 				t  = top (middle), 
 * 				tr = top right,
 * 				l  = left,
 * 				m  = middle,
 * 				r  = right,
 * 				bl = bottom left,
 * 				b  = bottom (middle),
 * 				br = bottom right
 * 			 padding - This moves the image away from the edges (in pixels)
 *	Output:	 This will add the word "test" to the middle of your image in
 *			 default color, white.
 */
$magicianObj->addText('test', 'm');
/*	Purpose: Save image
 *	Usage:	 saveImage('[filename.type]', [quality])
 * 	Params:	 filename.type - the filename and file type to save as
 * 			 quality - (optional) 0-100 (100 being the highest (default))
コード例 #29
0
ファイル: 6.2_border_preset.php プロジェクト: yasoon/yasoon
<?php

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');
/*	Purpose: Apply a pre styled template to your image
 *	Usage:	 borderPreset([preset_name])
 * 	Params:	 preset name
 *	Output:	 mixed. Depends on the preset
 */
$magicianObj->borderPreset('simple');
/*	Purpose: Save image
 *	Usage:	 saveImage('[filename.type]', [quality])
 * 	Params:	 filename.type - the filename and file type to save as
 * 			 quality - (optional) 0-100 (100 being the highest (default))
 *				Only applies to jpg & png only
 */
$magicianObj->saveImage('output_6.2.png', 100);
?>

コード例 #30
0
ファイル: customresize.php プロジェクト: benjaco/fileeater
    case 'xbm':
        imagexbm($img, $imgname);
        break;
    default:
        imagejpeg($img, $imgname);
}
imagedestroy($img);
if ($fastemaal == "1") {
    /*$new_image = imagecreatetruecolor($ny_width, $ny_height);
        $aspect1 = $ny_height / $ny_width;
        $aspect1_o = $ny_width / $ny_height;
        $aspect2 = $after_croped_height / $after_croped_width;
    
        if ($aspect1 < $aspect2) {
            // lut i top og bund
            $start_y_f = round(($start_y/$full_height)*$height);
    
    
            imagecopy($img, $img, 0, $start_y_f, 0, 0, $ny_width, $ny_height);
        } else if ($aspect1 > $aspect2) {
    
        } else {
            imagecopy($img, $img, 0, 0, 0, 0, $ny_width, $ny_height);
        }*/
    include 'php_image_magician.class.php';
    $img = new imageLib($imgname);
    $img->resizeImage($ny_width, $ny_height, 4);
    $img->saveImage($imgname);
}
list($w, $h, $type, $attr) = getimagesize($imgname);
echo json_encode(array("width" => $w, "height" => $h, "class" => $w > $h ? 'lanscape' : ($w == $h ? 'kvadradic' : 'protrat')));