當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Imagick::getimagewidth方法代碼示例

本文整理匯總了PHP中Imagick::getimagewidth方法的典型用法代碼示例。如果您正苦於以下問題:PHP Imagick::getimagewidth方法的具體用法?PHP Imagick::getimagewidth怎麽用?PHP Imagick::getimagewidth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Imagick的用法示例。


在下文中一共展示了Imagick::getimagewidth方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 public function __construct(EntityManager $entityManager)
 {
     // Tag
     $this->add(array('name' => 'tag', 'required' => true, 'filters' => array(), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array(\Zend\Validator\NotEmpty::IS_EMPTY => 'Please enter a Squad Tag'))))));
     // Name
     $this->add(array('name' => 'name', 'required' => true, 'filters' => array(), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array(\Zend\Validator\NotEmpty::IS_EMPTY => 'Please enter a Squad Name'))))));
     // Homepage
     $this->add(array('name' => 'homepage', 'required' => false, 'filters' => array(), 'validators' => array(array('name' => 'Zend\\Validator\\Uri', 'break_chain_on_failure' => true, 'options' => array('allowRelative' => false, 'messages' => array(\Zend\Validator\Uri::INVALID => 'FRONTEND_SQUAD_URL_INVALID_FORMAT', \Zend\Validator\Uri::NOT_URI => 'FRONTEND_SQUAD_URL_INVALID_FORMAT'))))));
     // Title
     $this->add(array('name' => 'title', 'required' => false, 'filters' => array(), 'validators' => array()));
     // Email
     $this->add(array('name' => 'email', 'required' => false, 'filters' => array(), 'validators' => array(array('name' => 'Zend\\Validator\\EmailAddress', 'break_chain_on_failure' => true, 'options' => array('messages' => array(\Zend\Validator\EmailAddress::INVALID => 'FRONTEND_SQUAD_EMAIL_INVALID_FORMAT'))))));
     // DeleteLogo
     $this->add(array('name' => 'deleteLogo', 'required' => false, 'filters' => array(), 'validators' => array()));
     // Upload
     $this->add(array('name' => 'logo', 'required' => false, 'filters' => array(), 'validators' => array(array('name' => 'Zend\\Validator\\File\\Extension', 'break_chain_on_failure' => true, 'options' => array('extension' => array('jpg', 'jpeg', 'gif', 'png'), 'messages' => array(\Zend\Validator\File\Extension::FALSE_EXTENSION => 'Es werden folgende Logos unterstützt: png,jpg,jpeg,gif'))), array('name' => 'Callback', 'options' => array('message' => array(\Zend\Validator\Callback::INVALID_VALUE => 'FRONTEND_SQUAD_LOGO_INVALID_FORMAT'), 'callback' => function ($value) {
         if ($value['error'] != 0) {
             return false;
         }
         try {
             $image = new \Imagick($value['tmp_name']);
             if ($image->getimageheight() == $image->getimagewidth() && in_array($image->getimageheight(), array(16, 32, 64, 128, 256))) {
                 return true;
             } else {
                 return false;
             }
         } catch (\Exception $e) {
             return false;
         }
         return false;
     })))));
 }
開發者ID:GlitchedMan,項目名稱:armasquads,代碼行數:32,代碼來源:Squad.php

示例2: rotate

 /**
  * @param  $angle
  * @param bool $autoResize
  * @param string $color
  * @return Pimcore_Image_Adapter_Imagick
  */
 public function rotate($angle)
 {
     $this->resource->rotateImage(new ImagickPixel('none'), $angle);
     $this->setWidth($this->resource->getimagewidth());
     $this->setHeight($this->resource->getimageheight());
     $this->reinitializeImage();
     return $this;
 }
開發者ID:shanky0110,項目名稱:pimcore-custom,代碼行數:14,代碼來源:Imagick.php

示例3: createBowl

 /**
  * 
  * @param string $dishUrl
  * @param int $w Width of the Output Image
  * @param int $h Height of Output Image
  * @return string Path of genrated Image
  */
 public function createBowl($dishUrl = null, $w = 140, $h = 0)
 {
     $bowl = new Imagick("tmpl/img/bowl.png");
     $mask = new Imagick("tmpl/img/mask.png");
     $dish = new Imagick($dishUrl);
     $dish->scaleimage($bowl->getimagewidth(), $bowl->getimageheight());
     // Set As per bowl image
     $dish->compositeimage(new Imagick("tmpl/img/mask.png"), \Imagick::COMPOSITE_COPYOPACITY, 0, 0, Imagick::CHANNEL_ALPHA);
     $dish->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
     $bowl->compositeimage($dish, \Imagick::COMPOSITE_ATOP, 0, 0, Imagick::CHANNEL_ALPHA);
     $bowl->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
     $bowl->setimageformat("jpg");
     $bowl->setImageFileName($url = "img_tmp/" . $this->randomString(10) . "-GE.jpg");
     //    $bowl->setinterlacescheme(\Imagick::INTERLACE_PNG);
     $bowl->scaleimage($w, $h);
     $bowl->writeimage();
     $bowl->destroy();
     return $url;
 }
開發者ID:ashutoshdev,項目名稱:pickmeals-web,代碼行數:26,代碼來源:Recipe.php

示例4: resizeImage

 /**
  * Resize image and save
  * @param string $sPathSrc Path to source image
  * @param string $sPathDst Path to output image
  * @param integer $iWidth Width of output image
  * @param integer $iHeight Height of output image
  * @param string $sMode Transformation mode
  * @param string $sImageForZoomPath Path for zoom thumbnail
  */
 public static function resizeImage($sPathSrc, $sPathDst, $iWidth, $iHeight, $sMode = "out", $sImageForZoomPath = null)
 {
     if (empty($sPathDst)) {
         $sPathDst = $sPathSrc;
     }
     if ($sMode == 'noresize') {
         return AM_Tools_Standard::getInstance()->copy($sPathSrc, $sPathDst);
     }
     $oSrcImage = new Imagick($sPathSrc);
     $iSrcWidth = $oSrcImage->getimagewidth();
     $iSrcHeight = $oSrcImage->getimageheight();
     //For images with horizontal proportions in vertical issue
     if ($iSrcWidth > $iSrcHeight && $iWidth < $iHeight && $sMode == 'width') {
         $iTmpHeight = $iHeight;
         $iHeight = $iWidth;
         $iWidth = $iTmpHeight;
     }
     self::_resizeImage($sPathSrc, $sPathDst, $iWidth, $iHeight, $sMode);
     if (!is_null($sImageForZoomPath)) {
         self::_resizeImage($sPathSrc, $sImageForZoomPath, $iWidth * 2, $iHeight * 2, $sMode);
     }
 }
開發者ID:pansot2,項目名稱:PadCMS-backend,代碼行數:31,代碼來源:Image.php

示例5: createBowl

function createBowl($dishUrl = null, $w = 140, $h = 0)
{
    $du = explode("/", $dishUrl);
    $du = explode(".", $du[count($du) - 1]);
    $uri = $du[count($du) - 2];
    $bowl = new Imagick("img/bowl.png");
    $mask = new Imagick("img/mask.png");
    $dish = new Imagick($dishUrl);
    $dish->scaleimage($bowl->getimagewidth(), $bowl->getimageheight());
    // Set As per bowl image
    $dish->compositeimage(new Imagick("img/mask.png"), \Imagick::COMPOSITE_COPYOPACITY, 0, 0, Imagick::CHANNEL_ALPHA);
    $dish->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
    $bowl->compositeimage($dish, \Imagick::COMPOSITE_ATOP, 0, 0, Imagick::CHANNEL_ALPHA);
    $bowl->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
    $bowl->setimageformat("jpg");
    $bowl->setImageFileName($url = "gen/" . $uri . ".jpg");
    //    $bowl->setinterlacescheme(\Imagick::INTERLACE_PNG);
    $bowl->scaleimage($w, $h);
    $bowl->writeimage();
    $bowl->destroy();
    return $url;
}
開發者ID:ashutoshdev,項目名稱:pickmeals-web,代碼行數:22,代碼來源:index.php

示例6: saveImage

 /**
  * @param $fileArray
  * @param bool $create_thumb
  * @param $destination // relative to app/public/files directory, no trailing slash
  * @return bool|string
  */
 public function saveImage($fileArray, $create_thumb = false, $destination = false)
 {
     $tmp_file = $fileArray['tmp_name'];
     $name = $fileArray['name'];
     if (!$destination) {
         $dest = $this->dest;
     } else {
         $dest = $this->dest . DS . $destination;
     }
     $img = new \Imagick($tmp_file);
     $img_width = $img->getimagewidth();
     $img_height = $img->getimageheight();
     if ($this->_height == 'auto' && is_numeric($this->_width) && $img_width > $this->_width) {
         // resize only width
         $img->resizeimage($img_width, 0, \Imagick::FILTER_LANCZOS, 1);
     } elseif ($this->_width == 'auto' && is_numeric($this->_height) && $img_height > $this->_height) {
         $img->resizeimage(0, $img_height, \Imagick::FILTER_LANCZOS, 1);
     } elseif (is_numeric($this->_height) && is_numeric($this->_width)) {
         $img->resizeimage($img_width, $img_height, \Imagick::FILTER_LANCZOS, 1, 1);
     }
     #dpi
     $img->setImageUnits(\Imagick::RESOLUTION_PIXELSPERINCH);
     $img->setImageResolution($this->_dpi, $this->_dpi);
     #compression
     $img->setImageCompressionQuality($this->_compression);
     $name = substr(md5(microtime()), 0, 4) . $name;
     $name = str_replace(' ', '', $name);
     try {
         $img->writeimage($dest . DS . $name);
     } catch (\Exception $e) {
         return false;
     }
     if ($create_thumb) {
         $this->createThumb($tmp_file, $dest . DS . 'thumb_' . $name, $this->_thumb_width, $this->_thumb_height);
     }
     return $name;
 }
開發者ID:stonedz,項目名稱:pff2-img_manager,代碼行數:43,代碼來源:Img.php

示例7: readImageFromImagick

 /**
  * Load actual image pixels from Imagick object
  * 
  * @param Imagick $im Image to load from
  */
 public function readImageFromImagick(Imagick $im)
 {
     /* Threshold */
     $im->setImageType(Imagick::IMGTYPE_TRUECOLOR);
     // Remove transparency (good for PDF's)
     $max = $im->getQuantumRange();
     $max = $max["quantumRangeLong"];
     $im->thresholdImage(0.5 * $max);
     /* Make a string of 1's and 0's */
     $geometry = $im->getimagegeometry();
     $this->imgHeight = $im->getimageheight();
     $this->imgWidth = $im->getimagewidth();
     $this->imgData = str_repeat("", $this->imgHeight * $this->imgWidth);
     for ($y = 0; $y < $this->imgHeight; $y++) {
         for ($x = 0; $x < $this->imgWidth; $x++) {
             /* Faster to average channels, blend alpha and negate the image here than via filters (tested!) */
             $cols = $im->getImagePixelColor($x, $y);
             $cols = $cols->getcolor();
             $greyness = (int) (($cols['r'] + $cols['g'] + $cols['b']) / 3) >> 7;
             // 1 for white, 0 for black
             $this->imgData[$y * $this->imgWidth + $x] = 1 - $greyness;
             // 1 for black, 0 for white
         }
     }
 }
開發者ID:brndwgn,項目名稱:escpos-php,代碼行數:30,代碼來源:EscposImage.php

示例8: open

 /**
  * Open a image and get informations
  * @param string $path to file image
  * @return array with image, width and height, or false
  */
 private static function open($path)
 {
     // get file name
     $file_name = basename($path);
     if (Image::use_magic()) {
         logger::debug('imagick available');
         $image = new Imagick($path);
         $image_information = array($image->getimagewidth(), $image->getimageheight());
     } else {
         logger::debug('imagick NOT available');
         // ensure this is a valid file
         if (!($image_information = Safe::GetImageSize($path))) {
             if ($verbose) {
                 Logger::error(sprintf(i18n::s('No image information in %s.'), $file_name));
             }
             return FALSE;
         }
         // GIF image
         if ($image_information[2] == 1 && is_callable('ImageCreateFromGIF')) {
             $image = ImageCreateFromGIF($path);
         } elseif ($image_information[2] == 2 && is_callable('ImageCreateFromJPEG')) {
             $image = ImageCreateFromJPEG($path);
         } elseif ($image_information[2] == 3 && is_callable('ImageCreateFromPNG')) {
             $image = ImageCreateFromPNG($path);
         }
         // sanity check
         if (!isset($image)) {
             if ($verbose) {
                 Logger::error(sprintf(i18n::s('No GD support, or unknown image type in %s.'), $file_name));
             }
             return FALSE;
         }
     }
     $info = array($image, $image_information);
     return $info;
 }
開發者ID:rair,項目名稱:yacs,代碼行數:41,代碼來源:image.php

示例9: createThali

 public function createThali($dishArray = array(), $w = 140, $h = 0)
 {
     Configure::write('debug', 2);
     ini_set("max_execution_time", -1);
     $thali = new Imagick("tmpl/img/thali.png");
     $mask_1 = new Imagick("tmpl/img/thali-mask1.png");
     $mask_2 = new Imagick("tmpl/img/thali-mask2.png");
     $mask_3 = new Imagick("tmpl/img/thali-mask3.png");
     $mask_4 = new Imagick("tmpl/img/thali-mask4.png");
     $mask_5 = new Imagick("tmpl/img/thali-mask5.png");
     if (!is_array($dishArray)) {
         return false;
     }
     $mask_cnt = 0;
     foreach ($dishArray as $dish) {
         if ($mask_cnt > 4) {
             // Mask Locking (Modify if masks will be increased or decreased)
             break;
         }
         $dish = new Imagick($dish);
         if ($mask_cnt + 1 == 5) {
             $dish = new Imagick("tmpl/dishes/rice.jpg");
             // Fixed Rice for Mask No. 1
         }
         $dish->scaleimage($thali->getimagewidth(), $thali->getimageheight());
         // Set As per bowl image
         $dish->compositeimage(new Imagick("tmpl/img/thali-mask" . ($mask_cnt + 1) . ".png"), \Imagick::COMPOSITE_COPYOPACITY, 0, 0, Imagick::CHANNEL_ALPHA);
         $dish->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
         $thali->compositeimage($dish, \Imagick::COMPOSITE_ATOP, 0, 0, Imagick::CHANNEL_ALPHA);
         $thali->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
         $mask_cnt++;
     }
     $thali->setimageformat("jpg");
     $thali->setImageFileName($url = "files/thali_images/" . $this->randomString(6) . "-Thali.jpg");
     //    $thali->setinterlacescheme(\Imagick::INTERLACE_PNG);
     $thali->scaleimage($w, $h);
     $thali->writeimage();
     $thali->destroy();
     return $url;
 }
開發者ID:ashutoshdev,項目名稱:pickmeals-web,代碼行數:40,代碼來源:TestsController.php

示例10: actiongoPhotoFB

 public function actiongoPhotoFB()
 {
     ignore_user_abort(1);
     set_time_limit(0);
     $urlPhoto = $_POST['urlPhoto'];
     $f = $_POST['filter'];
     $capPhoto = $_POST['capPhoto'];
     Helper::debugConsole("post ok");
     $namePhoto = Helper::getLastPath($urlPhoto);
     $min_rand = rand(0, 1000);
     $max_rand = rand(100000000000, 10000000000000000);
     $name_file = rand($min_rand, $max_rand);
     //this part is for creating random name for image
     $ext = end(explode(".", $namePhoto));
     //gets extension
     $file = Yii::app()->request->baseUrl . "photo/" . $name_file . "." . $ext;
     // Save Photo From Facebook And Add Filter
     Helper::save_image($urlPhoto, $file);
     $filter = Instagraph::factory($file, $file);
     $filter->{$f}();
     Helper::debugConsole("Save Photo From Facebook And Add Filter ok");
     // 320 Show Preview
     $immid = new Imagick($file);
     if ($immid->getimagewidth() > 320) {
         $immid->thumbnailImage(320, null);
         $immid->writeImage(Yii::app()->request->baseUrl . "thumb/thumb320_" . $name_file . "." . $ext);
         $immid->destroy();
         chmod(Yii::app()->request->baseUrl . "thumb/thumb320_" . $name_file . "." . $ext, 0777);
     } else {
         $immid->writeImage(Yii::app()->request->baseUrl . "thumb/thumb320_" . $name_file . "." . $ext);
         $immid->destroy();
         chmod(Yii::app()->request->baseUrl . "thumb/thumb320_" . $name_file . "." . $ext, 0777);
     }
     Helper::debugConsole("320 Show Preview ok");
     // null x 230 show last upload
     $imlast = new Imagick($file);
     $imlast->thumbnailimage(null, 230);
     $imlast->writeImage(Yii::app()->request->baseUrl . "thumb/thumb230_" . $name_file . "." . $ext);
     $imlast->destroy();
     chmod(Yii::app()->request->baseUrl . "thumb/thumb230_" . $name_file . "." . $ext, 0777);
     Helper::debugConsole("null x 230 show last upload ok");
     // 130 x 110 thumbmail
     $im = new Imagick($file);
     $im->thumbnailImage(130, 110);
     $im->writeImage(Yii::app()->request->baseUrl . "thumb/thumb_" . $name_file . "." . $ext);
     chmod(Yii::app()->request->baseUrl . "thumb/thumb_" . $name_file . "." . $ext, 0777);
     $im->destroy();
     Helper::debugConsole("130 x 110 thumbmail ok");
     $photo = new Photo();
     $photo->link = $file;
     $photo->fbid = Yii::app()->facebook->getUser();
     $photo->ip = $_SERVER['REMOTE_ADDR'];
     Helper::debugConsole("set data ok");
     if ($photo->save()) {
         $id = $photo->id;
         $cr = "\n" . "http://www.pla2gram.com/?p=" . $id . "&theater=1";
         $capFB = $capPhoto . $cr;
         Helper::debugConsole("set fb ok");
         // Post to Facebook
         $args = array('message' => $capFB);
         $args['image'] = '@' . realpath($file);
         Yii::app()->facebook->api('/me/photos', 'post', $args);
         Helper::debugConsole("save fb ok");
         Helper::redir("/?p=" . $id, 0);
     } else {
         print_r($photo->getErrors());
     }
 }
開發者ID:aommiez,項目名稱:pla2gram,代碼行數:68,代碼來源:SiteController.php

示例11: waterMark

 /**
  * @return mixed
  */
 protected function waterMark()
 {
     $oWaterMarkImg = new Imagick($this->_sWaterMarkImgPath);
     $iWaterMarkWidth = $oWaterMarkImg->getimagewidth();
     $iWaterMarkHeight = $oWaterMarkImg->getimageheight();
     $iImgWidth = $this->oImage->getimagewidth();
     $iImgHeight = $this->oImage->getimageheight();
     //圖片大小小於水印大小加上30 就不打水印了
     if ($iImgWidth < $iWaterMarkWidth + 30 || $iImgHeight < $iWaterMarkHeight + 30) {
         return true;
     }
     switch ($this->_sWaterMarkPosition) {
         //左下
         case "bottom-left":
             $iDesX = 30;
             $iDesY = $iImgHeight - $iWaterMarkHeight - 30;
             break;
             //右下
         //右下
         case "bottom-right":
             $iDesX = $iImgWidth - $iWaterMarkWidth - 30;
             $iDesY = $iImgHeight - $iWaterMarkHeight - 30;
             break;
             //中下
         //中下
         case "bottom-middle":
             $iDesX = $iImgHeight / 2 - 15;
             $iDesY = $iImgHeight - $iWaterMarkHeight - 30;
             break;
             //左上
         //左上
         case "top-left":
             $iDesX = 30;
             $iDesY = 30;
             break;
             break;
             //中上
         //中上
         case "top-middle":
             $iDesX = $iImgHeight / 2 - 15;
             $iDesY = 30;
             break;
             break;
             //右上
         //右上
         case "top-right":
             $iDesX = $iImgWidth - $iWaterMarkWidth - 30;
             $iDesY = 30;
             break;
             break;
             //默認右下
         //默認右下
         default:
             $iDesX = $iImgWidth - $iWaterMarkWidth - 30;
             $iDesY = $iImgHeight - $iWaterMarkHeight - 30;
             break;
     }
     if ($this->oImage->getimageformat() == 'GIF') {
         $aFrame = $this->oImage->coalesceImages();
         $draw = new ImagickDraw();
         $draw->composite($oWaterMarkImg->getImageCompose(), $iDesX, $iDesY, $iWaterMarkWidth, $iWaterMarkHeight, $oWaterMarkImg);
         foreach ($aFrame as $frame) {
             $frame->drawImage($draw);
         }
         $aFrame->optimizeimagelayers();
         $this->oImage = $aFrame;
     } else {
         $draw = new ImagickDraw();
         $draw->composite($oWaterMarkImg->getImageCompose(), $iDesX, $iDesY, $iWaterMarkWidth, $iWaterMarkHeight, $oWaterMarkImg);
         $this->oImage->drawImage($draw);
     }
 }
開發者ID:pancke,項目名稱:yyaf,代碼行數:75,代碼來源:ImageMagick.php

示例12: RenderImage

 public function RenderImage($strPath = null)
 {
     $objImage = new Imagick();
     $objImage->ReadImage($this->strImagePath);
     // Get Image Size
     $intSourceWidth = $objImage->getimagewidth();
     $intSourceHeight = $objImage->getimageheight();
     // We need to calculate the following values:
     $intDestinationWidth = null;
     $intDestinationHeight = null;
     $intCanvasWidth = null;
     $intCanvasHeight = null;
     /////////////////////////////////////////////
     // Calculate Dimensions: Based ONLY on WIDTH
     /////////////////////////////////////////////
     if ($this->strWidth && !$this->strHeight) {
         // DIMENSIONS THE SAME -- Flow Through
         if ($this->strWidth == $intSourceWidth) {
             $intDestinationWidth = $intSourceWidth;
             $intDestinationHeight = $intSourceHeight;
             $intCanvasWidth = $intSourceWidth;
             $intCanvasHeight = $intSourceHeight;
             // DESTINATION LARGER than source
         } else {
             if ($this->strWidth > $intSourceWidth) {
                 // Do NOT Scale "Up"
                 if (!$this->blnScaleImageUp) {
                     // Scale Canvas -- Flow Through
                     if ($this->blnScaleCanvasDown) {
                         $intDestinationWidth = $intSourceWidth;
                         $intDestinationHeight = $intSourceHeight;
                         $intCanvasWidth = $intSourceWidth;
                         $intCanvasHeight = $intSourceHeight;
                         // Do NOT Scale Canvas -- Canvas width matches requested width. Destionation matches Source dimensions.
                     } else {
                         $intDestinationWidth = $intSourceWidth;
                         $intDestinationHeight = $intSourceHeight;
                         $intCanvasWidth = $this->strWidth;
                         $intCanvasHeight = $intSourceHeight;
                     }
                     // SCALE UP source image -- Canvas and Destination widths both match requested width.  Canvas and Destination height both need to scale up.
                 } else {
                     $intDestinationWidth = $this->strWidth;
                     $intDestinationHeight = $intSourceHeight * $this->strWidth / $intSourceWidth;
                     $intCanvasWidth = $this->strWidth;
                     $intCanvasHeight = $intSourceHeight * $this->strWidth / $intSourceWidth;
                 }
                 // DESTINATION SMALLER than source -- Scale Down Source Image.  Canvas is size of image
             } else {
                 $intDestinationWidth = $this->strWidth;
                 $intDestinationHeight = $intSourceHeight * $this->strWidth / $intSourceWidth;
                 $intCanvasWidth = $intDestinationWidth;
                 $intCanvasHeight = $intDestinationHeight;
             }
         }
         /////////////////////////////////////////////
         // Calculate Dimensions: Based ONLY on HEIGHT
         /////////////////////////////////////////////
     } else {
         if ($this->strHeight && !$this->strWidth) {
             // DIMENSIONS THE SAME -- Flow Through
             if ($this->strHeight == $intSourceHeight) {
                 $intDestinationWidth = $intSourceWidth;
                 $intDestinationHeight = $intSourceHeight;
                 $intCanvasWidth = $intSourceWidth;
                 $intCanvasHeight = $intSourceHeight;
                 // DESTINATION LARGER than source
             } else {
                 if ($this->strHeight > $intSourceHeight) {
                     // Do NOT Scale "Up"
                     if (!$this->blnScaleImageUp) {
                         // Scale Canvas -- Flow Through
                         if ($this->blnScaleCanvasDown) {
                             $intDestinationWidth = $intSourceWidth;
                             $intDestinationHeight = $intSourceHeight;
                             $intCanvasWidth = $intSourceWidth;
                             $intCanvasHeight = $intSourceHeight;
                             // Do NOT Scale Canvas -- Canvas height matches requested height. Destionation matches Source dimensions.
                         } else {
                             $intDestinationWidth = $intSourceWidth;
                             $intDestinationHeight = $intSourceHeight;
                             $intCanvasWidth = $intSourceWidth;
                             $intCanvasHeight = $this->strHeight;
                         }
                         // SCALE UP source image -- Canvas and Destination heights both match requested height.  Canvas and Destination widths both need to scale up.
                     } else {
                         $intDestinationWidth = $intSourceWidth * $this->strHeight / $intSourceHeight;
                         $intDestinationHeight = $this->strHeight;
                         $intCanvasWidth = $intSourceWidth * $this->strHeight / $intSourceHeight;
                         $intCanvasHeight = $this->strHeight;
                     }
                     // DESTINATION SMALLER than source -- Scale Down Source Image.  Canvas is size of image
                 } else {
                     $intDestinationWidth = $intSourceWidth * $this->strHeight / $intSourceHeight;
                     $intDestinationHeight = $this->strHeight;
                     $intCanvasWidth = $intDestinationWidth;
                     $intCanvasHeight = $intDestinationHeight;
                 }
             }
             /////////////////////////////////////////////
//.........這裏部分代碼省略.........
開發者ID:alcf,項目名稱:chms,代碼行數:101,代碼來源:TiffImageControl.class.php

示例13: processBook

 /**
  * Primary processing routine for the source
  */
 private function processBook()
 {
     // Get Media manager and preset page parameters
     $mediaManager = new MediaManager($this->bookId);
     $pageCount = count($this->sourceFiles) + count($this->sourceAssets);
     $pageNumber = 1;
     // Prepare the progress
     $this->progress->startProgress($pageCount * 2);
     $this->updatePageCount(0);
     $bookSizeFound = false;
     // Loop through source files
     foreach ($this->sourceFiles as $source) {
         CakeLog::debug('[ImageProcessor::processBook] processing source file ' . $source);
         // Get book size
         if (!$bookSizeFound) {
             $bookWidth = 0;
             $bookHeight = 0;
             $this->getBookSizeImage($source, $bookWidth, $bookHeight);
             CakeLog::debug('[ImageProcessor::processBook] Book dimensions set to ' . $bookWidth . ' x ' . $bookHeight);
             $this->updateBookSize($bookWidth, $bookHeight);
             $bookSizeFound = true;
         }
         // Convert to png as needed
         if (MediaManager::isConvertableImage($source)) {
             CakeLog::debug('[ImageProcessor::processBook] Converting ' . $source . ' to png');
             $mediaManager->imageConvertToPng($source, $source);
         }
         // Resize image to max dimension.
         $image = new Imagick($source);
         $width = $image->getimagewidth();
         $height = $image->getimageheight();
         // Get new width and height
         list($newWidth, $newHeight) = $this->getResizedDimensionsForMaxPixels($width, $height);
         if ($newHeight != $height || $newWidth != $width) {
             CakeLog::debug('[ImageProcessor::processBook] ' . $source . ' resized for max pixel limits to ' . $newWidth . 'x' . $newHeight);
             // Resize the original image
             $img = new Imagick($source);
             $img->resizeimage($newWidth, $newHeight, Imagick::FILTER_LANCZOS, 1, false);
             $img->writeimage();
         }
         $this->addImageAssetToBook($source, 'images/backgrounds/');
         $this->savePageHTML('', $pageNumber, null, '../images/backgrounds/' . basename($source));
         @unlink($source);
         $this->savePageCSS('', $pageNumber);
         // Count page
         $pageNumber++;
         // Update the progress in database every 10th page.
         $this->progress->incrementStep();
     }
     //handle any non-source assets included with the book source files
     $this->importSourceAssets();
     $this->setCoverImage();
     // Save default book CSS
     $this->saveBookCSS('');
     // Generate thumbnails
     $this->generateThumbnails(1, $pageCount);
     $this->updatePageCount($pageCount);
     CakeLog::debug('[ImageProcessor::processBook] Book Processing Complete');
 }
開發者ID:skypeter1,項目名稱:webapps,代碼行數:62,代碼來源:ImageProcessor.php

示例14: getImageInfo

 /**
  * 
  * 獲取圖片信息
  * @param unknown_type $img
  */
 public function getImageInfo($img)
 {
     $image = new Imagick($img);
     $handle = $image->readimage($img);
     if (!$handle) {
         return false;
     }
     $width = $image->getimagewidth();
     $height = $image->getimageheight();
     $mime = $image->getimagemimetype();
     $type = $image->getimageformat();
     $size = $image->getimagesize();
     $resolution = $image->getimageresolution();
     $unit = $image->getimageunits();
     $info = array('width' => $width, 'height' => $height, 'mime' => $mime, 'type' => $type, 'size' => $size, 'resolution' => $resolution, 'unit' => $unit);
     $image->destroy();
     return $info;
 }
開發者ID:h3len,項目名稱:Project,代碼行數:23,代碼來源:imagick.class.php

示例15: genImgRunner

 private function genImgRunner($rugpngs, $colors = array(), $location = "files/temp/")
 {
     if (is_file($location . "runner.png")) {
         return $location;
     }
     ini_set("max_execution_time", -1);
     $layers = array();
     $bg = null;
     foreach ($rugpngs as $rp) {
         if ($rp['type'] == "LAYER") {
             $layers[] = new Imagick($rp['path']);
         } else {
             $bg = new Imagick($rp['path']);
         }
     }
     if ($bg == NULL) {
         $bg = new Imagick();
         $bg->newImage(910, 475, new ImagickPixel('none'));
         $bg->setimageformat('png');
     }
     foreach ($layers as $layer) {
         //$layer->resizeImage(910, 475, Imagick::FILTER_LANCZOS, 1, TRUE);
         $layer->setimageformat("png");
     }
     $bg->resizeImage($layer->getimagewidth(), $layer->getimageheight(), Imagick::FILTER_LANCZOS, 1, TRUE);
     $bg->setimageformat("png");
     $cnt_a = 0;
     foreach ($layers as $layer) {
         $layer->paintopaqueimage(new ImagickPixel('#000'), $colors[$cnt_a], 900000);
         $bg->compositeimage($layer, \Imagick::COMPOSITE_MULTIPLY, 0, 0);
         $cnt_a++;
         $layer->destroy();
     }
     $bg->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
     $bg = $this->getBgPresp($bg, 60);
     $rnd = new Imagick("files/templates/new/runner/angle.png");
     $bg->scaleimage(0, $rnd->getimageheight());
     $rnd->compositeimage($bg, \Imagick::COMPOSITE_MULTIPLY, 0, 0);
     $rnd->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
     $rnd->compositeimage(new Imagick("files/templates/new/runner/angle_trim.png"), \Imagick::COMPOSITE_COPYOPACITY, 0, 0, Imagick::CHANNEL_ALPHA);
     $rnd->setimageformat("png");
     $rnd->setImageFileName($location . "runner.png");
     $rnd->setinterlacescheme(\Imagick::INTERLACE_PNG);
     $rnd->scaleimage(733, 0);
     $rnd->writeimage();
     $rnd->destroy();
     $rnd = new Imagick("files/templates/new/runner/flip.png");
     $bg->scaleimage(0, $rnd->getimageheight());
     $rnd->compositeimage($bg, \Imagick::COMPOSITE_MULTIPLY, 0, 0);
     $rnd->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
     $rnd->compositeimage(new Imagick("files/templates/new/runner/flip_trim.png"), \Imagick::COMPOSITE_COPYOPACITY, 0, 0, Imagick::CHANNEL_ALPHA);
     $rnd->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
     $rnd->compositeimage(new Imagick("files/templates/new/runner/flip.png"), \Imagick::COMPOSITE_DSTOVER, 0, 0, Imagick::CHANNEL_ALPHA);
     $rnd->setimageformat("png");
     $rnd->setImageFileName($location . "runner1.png");
     $rnd->setinterlacescheme(\Imagick::INTERLACE_PNG);
     $rnd->scaleimage(733, 0);
     $rnd->writeimage();
     $rnd->destroy();
     $rnd = new Imagick("files/templates/new/runner/straight.png");
     $bg->scaleimage($rnd->getimagewidth(), 0);
     $rnd->compositeimage($bg, \Imagick::COMPOSITE_MULTIPLY, 0, 0);
     $rnd->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
     $rnd->compositeimage(new Imagick("files/templates/new/runner/straight_trim.png"), \Imagick::COMPOSITE_COPYOPACITY, 0, 0, Imagick::CHANNEL_ALPHA);
     $rnd->setimageformat("png");
     $rnd->setImageFileName($location . "runner2.png");
     $rnd->setinterlacescheme(\Imagick::INTERLACE_PNG);
     $rnd->scaleimage(733, 0);
     $rnd->writeimage();
     $rnd->destroy();
     /*
      $rnd = new Imagick("files/templates/runner/runners-4.png");
      $rnd->compositeimage($bg, \Imagick::COMPOSITE_MULTIPLY, 0, 200);
      $rnd->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
     
      $rnd->compositeimage(new Imagick("files/templates/runner/runners-4.png"), \Imagick::COMPOSITE_COPYOPACITY, 0, 0, Imagick::CHANNEL_ALPHA);
      $rnd->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
      $rnd->compositeimage(new Imagick("files/templates/runner/runners-5.png"), \Imagick::COMPOSITE_DEFAULT, 0, 0, Imagick::CHANNEL_ALPHA);
      $rnd->setimageformat("png");
      $rnd->setImageFileName($location . "runner3.png");
      $rnd->writeimage();
      $rnd->destroy();
     */
     return $location;
 }
開發者ID:ashutoshdev,項目名稱:openrug.com,代碼行數:85,代碼來源:RugsController.php


注:本文中的Imagick::getimagewidth方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。