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


PHP Imagick::resizeImage方法代碼示例

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


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

示例1: IMAGEN_tipo_normal

function IMAGEN_tipo_normal()
{
    $escalado = 'IMG/i/m/' . $_GET['ancho'] . '_' . $_GET['alto'] . '_' . $_GET['sha1'];
    $origen = 'IMG/i/' . $_GET['sha1'];
    $ancho = $_GET['ancho'];
    $alto = $_GET['alto'];
    if (@($ancho * $alto) > 562500) {
        die('La imagen solicitada excede el límite de este servicio');
    }
    if (!file_exists($escalado)) {
        $im = new Imagick($origen);
        $im->setCompression(Imagick::COMPRESSION_JPEG);
        $im->setCompressionQuality(85);
        $im->setImageFormat('jpeg');
        $im->stripImage();
        $im->despeckleImage();
        $im->sharpenImage(0.5, 1);
        //$im->reduceNoiseImage(0);
        $im->setInterlaceScheme(Imagick::INTERLACE_PLANE);
        $im->resizeImage($ancho, $alto, imagick::FILTER_LANCZOS, 1);
        $im->writeImage($escalado);
        $im->destroy();
    }
    $im = new Imagick($escalado);
    $output = $im->getimageblob();
    $outputtype = $im->getFormat();
    $im->destroy();
    header("Content-type: {$outputtype}");
    header("Content-length: " . filesize($escalado));
    echo $output;
}
開發者ID:vlad88sv,項目名稱:360,代碼行數:31,代碼來源:imagen.php

示例2: copyResizedImage

 static function copyResizedImage($inputFile, $outputFile, $width, $height = null, $crop = true)
 {
     if (extension_loaded('gd')) {
         $image = new GD($inputFile);
         if ($height) {
             if ($width && $crop) {
                 $image->cropThumbnail($width, $height);
             } else {
                 $image->resize($width, $height);
             }
         } else {
             $image->resize($width);
         }
         return $image->save($outputFile);
     } elseif (extension_loaded('imagick')) {
         $image = new \Imagick($inputFile);
         if ($height && !$crop) {
             $image->resizeImage($width, $height, \Imagick::FILTER_LANCZOS, 1, true);
         } else {
             $image->resizeImage($width, null, \Imagick::FILTER_LANCZOS, 1);
         }
         if ($height && $crop) {
             $image->cropThumbnailImage($width, $height);
         }
         return $image->writeImage($outputFile);
     } else {
         throw new HttpException(500, 'Please install GD or Imagick extension');
     }
 }
開發者ID:nanodesu88,項目名稱:easyii,代碼行數:29,代碼來源:Image.php

示例3: draw

 public function draw(OsuSignature $signature)
 {
     parent::draw($signature);
     if ($this->width != -1 || $this->height != -1) {
         $this->image->resizeImage($this->width == -1 ? $this->image->getImageWidth() : $this->width, $this->height == -1 ? $this->image->getImageHeight() : $this->height, 1, $this->filter);
     }
     $signature->getCanvas()->compositeImage($this->image, $this->composite, $this->x, $this->y);
 }
開發者ID:BTCTaras,項目名稱:osusig,代碼行數:8,代碼來源:ComponentImage.php

示例4: executeFilterImagick

 /**
  * Applies the image effect on an Imagick object. This function should be overridden by the effect.
  * @param \Imagick The image object to work with
  * @return \Imagick The new image object to use
  */
 protected function executeFilterImagick(\Imagick $imageData)
 {
     $width = $imageData->getImageWidth();
     $height = $imageData->getImageHeight();
     $imageData->resizeImage(ceil($width / $this->pixelatePercentage), ceil($height / $this->pixelatePercentage), \Imagick::FILTER_LANCZOS, 0, false);
     $imageData->resizeImage($width, $height, \Imagick::FILTER_LANCZOS, 0, false);
     return $imageData;
 }
開發者ID:Superbeest,項目名稱:Core,代碼行數:13,代碼來源:PixelateEffect.class.php

示例5: _resize

 protected function _resize($width, $height)
 {
     if ($this->im->getNumberImages() > 1) {
         $this->im = $this->im->coalesceImages();
         foreach ($this->im as $animation) {
             //                $animation->setImagePage( $animation->getImageWidth(), $animation->getImageHeight(), 0, 0 );
             $animation->resizeImage($width, $height, Imagick::FILTER_CUBIC, 0.5);
         }
     } else {
         if ($this->im->resizeImage($width, $height, Imagick::FILTER_CUBIC, 0.5)) {
             $this->width = $this->im->getImageWidth();
             $this->height = $this->im->getImageHeight();
         }
     }
 }
開發者ID:navi8602,項目名稱:wa-shop-ppg,代碼行數:15,代碼來源:waImageImagick.class.php

示例6: writeNewpic

function writeNewpic($old, $new)
{
    $maxsize = 600;
    $image = new Imagick($old);
    if ($image->getImageHeight() <= $image->getImageWidth()) {
        $image->resizeImage($maxsize, 0, Imagick::FILTER_LANCZOS, 1);
    } else {
        $image->resizeImage(0, $maxsize, Imagick::FILTER_LANCZOS, 1);
    }
    $image->setImageCompression(Imagick::COMPRESSION_JPEG);
    $image->setImageCompressionQuality(90);
    $image->stripImage();
    $image->writeImage($new);
    $image->destroy();
}
開發者ID:buaacotest,項目名稱:cotest,代碼行數:15,代碼來源:imgConstructor.php

示例7: createMissingThumbsAction

 public function createMissingThumbsAction()
 {
     $this->initCommonParams($this->getRequest());
     $this->outputMessage('[light_cyan]Creating missing thumbs.');
     $dbAdapter = $this->getServiceLocator()->get('dbAdapter');
     $apartments = $dbAdapter->createStatement('
     SELECT ai.*, a.`name`
     FROM `ga_apartment_images` ai LEFT JOIN `ga_apartments` a
       ON ai.`apartment_id` = a.`id`
     ')->execute();
     foreach ($apartments as $apartment) {
         $this->outputMessage('[cyan]Looking into [light_blue]' . $apartment['name'] . '[cyan] images...');
         for ($i = 1; $i <= 32; $i++) {
             if ($apartment['img' . $i]) {
                 $imgPathComponents = explode('/', $apartment['img' . $i]);
                 $originalFileName = array_pop($imgPathComponents);
                 $originalFilePath = DirectoryStructure::FS_GINOSI_ROOT . DirectoryStructure::FS_IMAGES_ROOT . DirectoryStructure::FS_IMAGES_APARTMENT . $apartment['apartment_id'] . '/' . $originalFileName;
                 $thumbFilePath = str_replace('_orig.', '_555.', $originalFilePath);
                 if (!file_exists($originalFilePath)) {
                     $this->outputMessage('[error] Original file for image ' . $i . ' is missing.');
                 } else {
                     if (file_exists($thumbFilePath)) {
                         $this->outputMessage('[light_blue] Thumb for image ' . $i . ' exists.');
                     } else {
                         $thumb = new \Imagick($originalFilePath);
                         $thumb->resizeImage(555, 370, \Imagick::FILTER_LANCZOS, 1);
                         $thumb->writeImage($thumbFilePath);
                         $this->outputMessage('[success] Added thumb for image ' . $i);
                     }
                 }
             }
         }
     }
     $this->outputMessage('Done!');
 }
開發者ID:arbi,項目名稱:MyCode,代碼行數:35,代碼來源:OneTimeController.php

示例8: beforeSave

 public function beforeSave($options = array())
 {
     if (isset($this->data['Candidate']['image']) && is_array($this->data['Candidate']['image'])) {
         if (!empty($this->data['Candidate']['image']['size'])) {
             $im = new Imagick($this->data['Candidate']['image']['tmp_name']);
             $im->resizeImage(512, 512, Imagick::FILTER_CATROM, 1, true);
             $path = WWW_ROOT . 'media';
             $fileName = str_replace('-', '/', String::uuid()) . '.jpg';
             if (!file_exists($path . '/' . dirname($fileName))) {
                 mkdir($path . '/' . dirname($fileName), 0777, true);
             }
             $im->writeImage($path . '/' . $fileName);
             if (file_exists($path . '/' . $fileName)) {
                 $this->data['Candidate']['image'] = $fileName;
             } else {
                 unset($this->data['Candidate']['image']);
             }
         } else {
             unset($this->data['Candidate']['image']);
         }
     }
     if (isset($this->data['Candidate']['name'])) {
         $this->data['Candidate']['name'] = str_replace(array('&amp;bull;', '&bull;', '‧', '.', '•', '..'), '.', $this->data['Candidate']['name']);
     }
     return parent::beforeSave($options);
 }
開發者ID:parker00811,項目名稱:elections,代碼行數:26,代碼來源:Candidate.php

示例9: renderOriginalImage

 function renderOriginalImage()
 {
     $imagick = new \Imagick(realpath("../imagick/images/FineDetail.png"));
     $imagick->resizeImage($imagick->getImageWidth() * 4, $imagick->getImageHeight() * 4, \Imagick::FILTER_POINT, 1);
     \header('Content-Type: image/png');
     echo $imagick->getImageBlob();
 }
開發者ID:sdmmember,項目名稱:Imagick-demos,代碼行數:7,代碼來源:setSamplingFactors.php

示例10: thumbImage

 public static function thumbImage($imgPath, $width, $height, $blur = 1, $bestFit = 0, $cropZoom = 1)
 {
     $dir = dirname($imgPath);
     $imagick = new \Imagick(realpath($imgPath));
     if ($imagick->getImageHeight() > $imagick->getImageWidth()) {
         $w = $width;
         $h = 0;
     } else {
         $h = $height;
         $w = 0;
     }
     $imagick->resizeImage($w, $h, $imagick::DISPOSE_UNDEFINED, $blur, $bestFit);
     $cropWidth = $imagick->getImageWidth();
     $cropHeight = $imagick->getImageHeight();
     if ($cropZoom) {
         $imagick->cropImage($width, $height, ($imagick->getImageWidth() - $width) / 2, ($imagick->getImageHeight() - $height) / 2);
     }
     $direct = 'thumbs/';
     $pathToWrite = $dir . "/" . $direct;
     //var_dump($pathToWrite);
     if (!file_exists($pathToWrite)) {
         mkdir($pathToWrite, 0777, true);
     }
     $newImageName = 'thumb_' . basename($imgPath);
     //var_dump($newImageName);
     $imagick->writeImage($pathToWrite . 'thumb_' . basename($imgPath));
     return $pathToWrite . $newImageName;
 }
開發者ID:Snuchycovich,項目名稱:ExifGallery,代碼行數:28,代碼來源:UploadManager.php

示例11: makeThumb

 public function makeThumb($path, $W = NULL, $H = NULL)
 {
     $image = new Imagick();
     $image->readImage($ImgSrc);
     // Trasformo in RGB solo se e` il CMYK
     if ($image->getImageColorspace() == Imagick::COLORSPACE_CMYK) {
         $image->transformImageColorspace(Imagick::COLORSPACE_RGB);
     }
     $image->profileImage('*', NULL);
     $image->stripImage();
     $imgWidth = $image->getImageWidth();
     $imgHeight = $image->getImageHeight();
     if ((!$H || $H == null || $H == 0) && (!$W || $W == null || $W == 0)) {
         $W = $imgWidth;
         $H = $imgHeight;
     } elseif (!$H || $H == null || $H == 0) {
         $H = $W * $imgHeight / $imgWidth;
     } elseif (!$W || $W == null || $W == 0) {
         $W = $H * $imgWidth / $imgHeight;
     }
     $image->resizeImage($W, $H, Imagick::FILTER_LANCZOS, 1);
     /** Scrivo l'immagine */
     $image->writeImage($path);
     /** IMAGE OUT */
     header('X-MHZ-FLY: Nice job!');
     header(sprintf('Content-type: image/%s', strtolower($image->getImageFormat())));
     echo $image->getImageBlob();
     $image->destroy();
     die;
 }
開發者ID:andreaganduglia,項目名稱:dpr-detector,代碼行數:30,代碼來源:image_processor.php

示例12: resize

 public function resize($file, $size = array('width' => 100, 'height' => 100), $type = 'png', $fixed = false)
 {
     $image = new Imagick($this->file);
     $image->setBackgroundColor(new ImagickPixel('transparent'));
     $image->setImageFormat($type);
     if ($fixed === true) {
         $newWidth = $size['width'];
         $newHeight = $size['height'];
     } else {
         $imageprops = $image->getImageGeometry();
         $width = $imageprops['width'];
         $height = $imageprops['height'];
         if ($width > $height) {
             $newHeight = $size['height'];
             $newWidth = $size['height'] / $height * $width;
         } else {
             $newWidth = $size['width'];
             $newHeight = $size['width'] / $width * $height;
         }
     }
     $image->resizeImage($newWidth, $newHeight, imagick::FILTER_LANCZOS, 1);
     $image->writeImage($file . '.' . $type);
     $image->clear();
     $image->destroy();
 }
開發者ID:Nnamso,項目名稱:tbox,代碼行數:25,代碼來源:thumb.php

示例13: handleSave

 /**
  * @param Asset $asset
  * @return string
  */
 public function handleSave(Asset $asset)
 {
     $newImage = new \Imagick($asset->getUploadedFile()->getRealPath());
     $asset->setHeight($newImage->getImageHeight());
     $asset->setWidth($newImage->getImageWidth());
     /** @var array $requiredImage */
     foreach ($this->requiredImages as $requiredImage) {
         $newImage = new \Imagick($asset->getUploadedFile()->getRealPath());
         $newFilename = pathinfo($asset->getFilename(), PATHINFO_FILENAME) . '-' . $requiredImage['name'] . '.' . pathinfo($asset->getFilename(), PATHINFO_EXTENSION);
         $imageWidth = $newImage->getImageWidth();
         $imageHeight = $newImage->getImageHeight();
         $isLandscapeFormat = $imageWidth > $imageHeight;
         $orientation = $newImage->getImageOrientation();
         $newImage->setCompression(\Imagick::COMPRESSION_JPEG);
         $newImage->setImageCompressionQuality($requiredImage['quality']);
         if ($isLandscapeFormat) {
             $desiredWidth = $requiredImage['long'];
             $newImage->resizeImage($desiredWidth, 0, \Imagick::FILTER_LANCZOS, 1);
             if (isset($requiredImage['short']) && boolval($requiredImage['crop']) == true) {
                 $newImage->cropImage($desiredWidth, $requiredImage['short'], 0, 0);
             } else {
                 $newImage->resizeImage(0, $requiredImage['short'], \Imagick::FILTER_LANCZOS, 1);
             }
         } else {
             $desiredHeight = $requiredImage['long'];
             $newImage->resizeImage(0, $desiredHeight, \Imagick::FILTER_LANCZOS, 1);
             if (isset($requiredImage['short']) && boolval($requiredImage['crop']) == true) {
                 $newImage->cropImage($requiredImage['short'], $desiredHeight, 0, 0);
             } else {
                 $newImage->resizeImage($requiredImage['short'], 0, \Imagick::FILTER_LANCZOS, 1);
             }
         }
         /**
          * This unfortunately kills the orientation. Leave EXIF-Info for now.
          *
          * $newImage->stripImage();
          * $newImage->setImageOrientation($orientation);
          */
         $this->assetStorage->uploadFile($newFilename, $newImage);
         $subAsset = new SubAsset();
         $subAsset->setFilename($newFilename);
         $subAsset->setType($requiredImage['name']);
         $subAsset->setHeight($newImage->getImageHeight());
         $subAsset->setWidth($newImage->getImageWidth());
         $asset->addSubAsset($subAsset);
     }
 }
開發者ID:keylightberlin,項目名稱:util,代碼行數:51,代碼來源:ImageAssetHandler.php

示例14: getOriginalImageResponse

 public function getOriginalImageResponse()
 {
     $imagePath = $this->getOriginalImagePath();
     $imagick = new \Imagick(realpath($imagePath));
     $imagick->resizeImage($imagick->getImageWidth() * 4, $imagick->getImageHeight() * 4, \Imagick::FILTER_POINT, 1);
     header('Content-Type: image/png');
     echo $imagick->getImageBlob();
 }
開發者ID:danack,項目名稱:imagick-demos,代碼行數:8,代碼來源:setSamplingFactors.php

示例15: resize

 /**
  * {@inheritdoc}
  *
  * @return ImageInterface
  */
 public function resize(BoxInterface $size, $filter = ImageInterface::FILTER_UNDEFINED)
 {
     try {
         $this->imagick->resizeImage($size->getWidth(), $size->getHeight(), $this->getFilter($filter), 1);
     } catch (\ImagickException $e) {
         throw new RuntimeException('Resize operation failed', $e->getCode(), $e);
     }
     return $this;
 }
開發者ID:scisahaha,項目名稱:generator-craft,代碼行數:14,代碼來源:Image.php


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