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


PHP Imagick::destroy方法代碼示例

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


在下文中一共展示了Imagick::destroy方法的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: deInitialize

 /**
  * @return $this
  */
 public function deInitialize()
 {
     if ($this->im instanceof \Imagick) {
         $this->im->destroy();
     }
     return $this;
 }
開發者ID:scr-be,項目名稱:teavee-image-magic-bundle,代碼行數:10,代碼來源:ImageMagickProcessor.php

示例3: __destruct

 /**
  * Destroys allocated imagick resources
  */
 public function __destruct()
 {
     if ($this->imagick instanceof \Imagick) {
         $this->imagick->clear();
         $this->imagick->destroy();
     }
 }
開發者ID:scisahaha,項目名稱:generator-craft,代碼行數:10,代碼來源:Image.php

示例4: __destruct

 /**
  * Destructor.
  *
  * @access  public
  */
 public function __destruct()
 {
     if ($this->image instanceof Imagick) {
         $this->image->destroy();
     }
     if ($this->snapshot instanceof Imagick) {
         $this->snapshot->destroy();
     }
 }
開發者ID:muhammetardayildiz,項目名稱:framework,代碼行數:14,代碼來源:ImageMagick.php

示例5: save

 public function save($file, $gray = false, $quality = 100)
 {
     if ($gray) {
         $this->gray();
     }
     $res = $this->image->writeImages($file, true);
     $this->image->clear();
     $this->image->destroy();
     return $res;
 }
開發者ID:NareshChennuri,項目名稱:pyng,代碼行數:10,代碼來源:Imagick.php

示例6: _adapt

 /**
  * Adaptation the image.
  * @param int $width
  * @param int $height
  * @param int $offset_x
  * @param int $offset_y
  */
 protected function _adapt($width, $height, $offset_x, $offset_y)
 {
     $image = new \Imagick();
     $image->newImage($width, $height, 'none');
     $image->compositeImage($this->im, \Imagick::COMPOSITE_ADD, $offset_x, $offset_y);
     $this->im->clear();
     $this->im->destroy();
     $this->im = $image;
     $this->width = $image->getImageWidth();
     $this->height = $image->getImageHeight();
 }
開發者ID:dgan89,項目名稱:yii2-image,代碼行數:18,代碼來源:Imagick.php

示例7: createThumbnailWithImagick

 /**
  * Creates a thumbnail with imagick.
  *
  * @param  File    $fileObject           FileObject to add properties
  * @param  string  $httpPathToMediaDir   Http path to file
  * @param  string  $pathToMediaDirectory Local path to file
  * @param  string  $fileName             Name of the image
  * @param  string  $fileExtension        Fileextension
  * @param  integer $width                Width of thumbnail, if omitted, size will be proportional to height
  * @param  integer $height               Height of thumbnail, if omitted, size will be proportional to width
  *
  * @throws ThumbnailCreationFailedException              If imagick is not supported
  * @throws InvalidArgumentException      If both, height and width are omitted or file format is not supported
  */
 private static function createThumbnailWithImagick(File &$fileObject, $httpPathToMediaDir, $pathToMediaDirectory, $fileName, $fileExtension, $width = null, $height = null)
 {
     if (!extension_loaded('imagick')) {
         throw new ExtensionNotLoadedException('Imagick is not loaded on this system');
     }
     if ($width === null && $height === null) {
         throw new InvalidArgumentException('Either width or height must be provided');
     }
     // create thumbnails with imagick
     $imagick = new \Imagick();
     if (!in_array($fileExtension, $imagick->queryFormats("*"))) {
         throw new ThumbnailCreationFailedException('No thumbnail could be created for the file format');
     }
     // read image into imagick
     $imagick->readImage(sprintf('%s/%s.%s', $pathToMediaDirectory, $fileName, $fileExtension));
     // set size
     $imagick->thumbnailImage($width, $height);
     // null values allowed
     // write image
     $imagick->writeImage(sprintf('%s/%sx%s-thumbnail-%s.%s', $pathToMediaDirectory, $imagick->getImageWidth(), $imagick->getImageHeight(), $fileName, $fileExtension));
     $fileObject->setThumbnailLink(sprintf('%s/%sx%s-thumbnail-%s.%s', $httpPathToMediaDir, $imagick->getImageWidth(), $imagick->getImageHeight(), $fileName, $fileExtension));
     $fileObject->setLocalThumbnailPath(sprintf('%s/%sx%s-thumbnail-%s.%s', $pathToMediaDirectory, $imagick->getImageWidth(), $imagick->getImageHeight(), $fileName, $fileExtension));
     // free up associated resources
     $imagick->destroy();
 }
開發者ID:rmatil,項目名稱:angular-cms,代碼行數:39,代碼來源:ThumbnailHandler.php

示例8: refresh

 /**
  * @param Thumbnail $thumbnail
  * @return void
  * @throws Exception\NoThumbnailAvailableException
  */
 public function refresh(Thumbnail $thumbnail)
 {
     try {
         $filenameWithoutExtension = pathinfo($thumbnail->getOriginalAsset()->getResource()->getFilename(), PATHINFO_FILENAME);
         $temporaryLocalCopyFilename = $thumbnail->getOriginalAsset()->getResource()->createTemporaryLocalCopy();
         $documentFile = sprintf(in_array($thumbnail->getOriginalAsset()->getResource()->getFileExtension(), $this->getOption('paginableDocuments')) ? '%s[0]' : '%s', $temporaryLocalCopyFilename);
         $width = $thumbnail->getConfigurationValue('width') ?: $thumbnail->getConfigurationValue('maximumWidth');
         $height = $thumbnail->getConfigurationValue('height') ?: $thumbnail->getConfigurationValue('maximumHeight');
         $im = new \Imagick();
         $im->setResolution($this->getOption('resolution'), $this->getOption('resolution'));
         $im->readImage($documentFile);
         $im->setImageFormat('png');
         $im->setImageBackgroundColor('white');
         $im->setImageCompose(\Imagick::COMPOSITE_OVER);
         $im->setImageAlphaChannel(\Imagick::ALPHACHANNEL_RESET);
         $im->thumbnailImage($width, $height, true);
         $im->flattenImages();
         // Replace flattenImages in imagick 3.3.0
         // @see https://pecl.php.net/package/imagick/3.3.0RC2
         // $im->mergeImageLayers(\Imagick::LAYERMETHOD_MERGE);
         $resource = $this->resourceManager->importResourceFromContent($im->getImageBlob(), $filenameWithoutExtension . '.png');
         $im->destroy();
         $thumbnail->setResource($resource);
         $thumbnail->setWidth($width);
         $thumbnail->setHeight($height);
     } catch (\Exception $exception) {
         $filename = $thumbnail->getOriginalAsset()->getResource()->getFilename();
         $sha1 = $thumbnail->getOriginalAsset()->getResource()->getSha1();
         $message = sprintf('Unable to generate thumbnail for the given document (filename: %s, SHA1: %s)', $filename, $sha1);
         throw new Exception\NoThumbnailAvailableException($message, 1433109652, $exception);
     }
 }
開發者ID:mgoldbeck,項目名稱:neos-development-collection,代碼行數:37,代碼來源:DocumentThumbnailGenerator.php

示例9: cropImage

 public static function cropImage($dataPathRoot, $imageFileRelativeName, $imageThumbFileRelativeName, $width, $height)
 {
     $cloudStorage = CloudHelper::getCloudModule(CloudHelper::CLOUD_MODULE_STORAGE);
     $tempSrcFilePath = $cloudStorage->createTempFileForStorageFile($dataPathRoot, $imageFileRelativeName);
     $tempDestFilePath = $cloudStorage->getTempFilePath();
     //生成縮略圖
     if (extension_loaded('imagick')) {
         // 如果有 imagick 模塊,優先選擇 imagick 模塊,因為生成的圖片質量更高
         $img = new \Imagick($tempSrcFilePath);
         $img->stripimage();
         //去除圖片信息
         $img->setimagecompressionquality(95);
         //保證圖片的壓縮質量,同時大小可以接受
         $img->cropimage($width, $height, 0, 0);
         $img->writeimage($tempDestFilePath);
         $cloudStorage->moveFileToStorage($dataPathRoot, $imageThumbFileRelativeName, $tempDestFilePath);
         //主動釋放資源,防止程序出錯
         $img->destroy();
         unset($img);
     } else {
         // F3 框架的 Image 類限製隻能操作 UI 路徑中的文件,所以我們這裏需要設置 UI 路徑
         global $f3;
         $f3->set('UI', dirname($tempSrcFilePath));
         $img = new \Image('/' . basename($tempSrcFilePath));
         $img->resize($width, $height, true);
         $img->dump('jpeg', $tempDestFilePath);
         $cloudStorage->moveFileToStorage($dataPathRoot, $imageThumbFileRelativeName, $tempDestFilePath);
         //主動釋放資源,防止程序出錯
         $img->__destruct();
         unset($img);
     }
     // 刪除臨時文件
     @unlink($tempSrcFilePath);
     @unlink($tempDestFilePath);
 }
開發者ID:jackycgq,項目名稱:bzfshop,代碼行數:35,代碼來源:StorageImage.php

示例10: softThumb

 public function softThumb($width, $height, $path, $bg = 'transparent')
 {
     if ($this->originImage) {
         echo "\nWrite image to `{$path}`\n";
         $resizeParams = $this->getSizes($width, $height);
         $overlay = clone $this->originImage;
         $overlay->scaleImage($resizeParams['width'], $resizeParams['height']);
         $overlayGeo = $overlay->getImageGeometry();
         if ($overlayGeo['width'] > $overlayGeo['height']) {
             $resizeParams['top'] = ($height - $overlayGeo['height']) / 2;
             $resizeParams['left'] = 0;
         } else {
             $resizeParams['top'] = 0;
             $resizeParams['left'] = ($width - $overlayGeo['width']) / 2;
         }
         $thumb = new \Imagick();
         $thumb->newImage($width, $height, $bg);
         $thumb->setImageFormat("png");
         $thumb->setCompression(\Imagick::COMPRESSION_ZIP);
         $thumb->setImageCompressionQuality(0);
         $thumb->compositeImage($overlay, \Imagick::COMPOSITE_DEFAULT, $resizeParams['left'], $resizeParams['top']);
         $thumb->writeImageFile(fopen($path, "wb"));
         $thumb->destroy();
     } else {
         throw new \Exception("As first You must load image", 404);
     }
 }
開發者ID:iryska,項目名稱:nagginua,代碼行數:27,代碼來源:ImageEditor.php

示例11: alfath_svg_compiler

function alfath_svg_compiler($options)
{
    global $wp_filesystem;
    if (!class_exists('Imagick')) {
        return new WP_Error('class_not_exist', 'Your server not support imagemagick');
    }
    $im = new Imagick();
    $im->setBackgroundColor(new ImagickPixel('transparent'));
    if (empty($wp_filesystem)) {
        require_once ABSPATH . '/wp-admin/includes/file.php';
        WP_Filesystem();
    }
    $file = get_template_directory() . '/assets/img/nav.svg';
    $target = get_template_directory() . '/assets/img/nav-bg.png';
    if ($wp_filesystem->exists($file)) {
        //check for existence
        $svg = $wp_filesystem->get_contents($file);
        if (!$svg) {
            return new WP_Error('reading_error', 'Error when reading file');
        }
        //return error object
        $svg = preg_replace('/fill="#([0-9a-f]{6})"/', 'fill="' . $options['secondary-color'] . '"', $svg);
        $im->readImageBlob($svg);
        $im->setImageFormat("png24");
        $im->writeImage($target);
        $im->clear();
        $im->destroy();
    } else {
        return new WP_Error('not_found', 'File not found');
    }
}
開發者ID:ArgiaCyber,項目名稱:alfath,代碼行數:31,代碼來源:functions.php

示例12: save

 protected function save($path)
 {
     $pathinfo = pathinfo($path);
     if (!file_exists($pathinfo['dirname'])) {
         mkdir($pathinfo['dirname'], 0777, true);
     }
     try {
         $image = new \Imagick($this->source);
         $image->thumbnailImage($this->width, $this->height, true);
         if ($this->color) {
             $thumb = $image;
             $image = new \Imagick();
             $image->newImage($this->width, $this->height, $this->color, $pathinfo['extension']);
             $size = $thumb->getImageGeometry();
             $x = ($this->width - $size['width']) / 2;
             $y = ($this->height - $size['height']) / 2;
             $image->compositeImage($thumb, \imagick::COMPOSITE_OVER, $x, $y);
             $thumb->destroy();
         }
         $image->writeImage($path);
         $image->destroy();
     } catch (\Exception $e) {
     }
     return $this;
 }
開發者ID:disdain,項目名稱:thumb,代碼行數:25,代碼來源:Thumb.php

示例13: 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

示例14: save

 public function save()
 {
     $success = parent::save();
     if ($success && isset($this->tempFile)) {
         $extension = $this->getExtension();
         //	save original
         $original = $this->name . "." . $extension;
         $path = $this->getPath(null, true);
         $this->logger->log("moving " . $this->tempFile["tmp_name"] . " to " . $path);
         $success = move_uploaded_file($this->tempFile["tmp_name"], $path);
         if ($success && $this->isImage()) {
             $thumbs = array(array('width' => 200, 'suffix' => 'small'), array('width' => 500, 'suffix' => 'med'));
             foreach ($thumbs as $thumb) {
                 $thumb_path = $this->getPath($thumb['suffix'], true);
                 $this->logger->log("thumbnailing " . $this->tempFile["tmp_name"] . " to " . $thumb_path);
                 $image = new Imagick($path);
                 $image->scaleImage($thumb['width'], 0);
                 $image->writeImage($thumb_path);
                 $image->destroy();
             }
         } else {
             if (!$success) {
                 $this->errorMessage = "Oops! We had trouble moving the file. Please try again later.";
                 $success = false;
             }
         }
     } else {
         $this->status = "Sorry, there was an error with the file: " . $this->tempFile["error"];
         $success = false;
     }
     return $success;
 }
開發者ID:npedrini,項目名稱:artefacts,代碼行數:32,代碼來源:media.class.php

示例15: destroy

 public function destroy()
 {
     if ($this->image !== null) {
         $this->image->destroy();
         $this->image = null;
     }
 }
開發者ID:anp135,項目名稱:altocms,代碼行數:7,代碼來源:Imagick.php


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