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


PHP Imagick::clear方法代碼示例

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


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

示例1: __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

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

示例3: loadFile

 /**
  * @see	\wcf\system\image\adapter\IImageAdapter::loadFile()
  */
 public function loadFile($file)
 {
     try {
         $this->imagick->clear();
         $this->imagick->readImage($file);
     } catch (\ImagickException $e) {
         throw new SystemException("Image '" . $file . "' is not readable or does not exist.");
     }
     $this->readImageDimensions();
 }
開發者ID:nick-strohm,項目名稱:WCF,代碼行數:13,代碼來源:ImagickImageAdapter.class.php

示例4: _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

示例5: apply

 /**
  * {@inheritDoc}
  */
 public function apply($absolutePath)
 {
     $info = pathinfo($absolutePath);
     if (isset($info['extension']) && false !== strpos(strtolower($info['extension']), 'pdf')) {
         // If it doesn't exists, extract the first page of the PDF
         if (!file_exists("{$absolutePath}.png")) {
             $this->imagick->readImage($absolutePath . '[0]');
             $this->imagick->setImageFormat('png');
             $this->imagick->writeImage("{$absolutePath}.png");
             $this->imagick->clear();
         }
         $absolutePath .= '.png';
     }
     return $absolutePath;
 }
開發者ID:ashutosh-srijan,項目名稱:findit_akeneo,代碼行數:18,代碼來源:PdfTransformer.php

示例6: create_thumb

function create_thumb($source_file, $thumb_file, $edge = THUMBNAIL_CROP_EDGE, &$src_w = NULL, &$src_h = NULL)
{
    $composite_img = new Imagick($source_file);
    $blank_img = new Imagick();
    $src_w = $composite_img->getImageWidth();
    $src_h = $composite_img->getImageHeight();
    if ($src_h > $edge && $src_w > $edge) {
        $composite_img->cropThumbnailImage($edge, $edge);
        $composite_img->setImageFormat('jpeg');
        $composite_img->writeImage($thumb_file);
        $composite_img->clear();
        $blank_img = $composite_img;
    } else {
        $blank_img->newImage($edge, $edge, new ImagickPixel('#DEF'), "jpg");
        if ($src_w > $src_h) {
            $crop_x = $src_w / 2 - $edge / 2;
            $crop_y = 0;
            $offset_x = 0;
            $offset_y = $edge / 2 - $src_h / 2;
        } else {
            $crop_x = 0;
            $crop_y = $src_h / 2 - $edge / 2;
            $offset_x = $edge / 2 - $src_w / 2;
            $offset_y = 0;
        }
        $composite_img->cropImage($edge, $edge, $crop_x, $crop_y);
        $blank_img->compositeImage($composite_img, Imagick::COMPOSITE_OVER, $offset_x, $offset_y);
        $blank_img->setImageFormat('jpeg');
        $blank_img->writeImage($thumb_file);
        $blank_img->clear();
    }
    return $blank_img;
}
開發者ID:hoogle,項目名稱:ttt,代碼行數:33,代碼來源:index.php

示例7: destroyWatermarkResource

 public function destroyWatermarkResource()
 {
     if ($this->watermark) {
         $this->watermark->clear();
         $this->watermark = null;
     }
 }
開發者ID:kankje,項目名稱:xi-filelib,代碼行數:7,代碼來源:WatermarkCommand.php

示例8: watermarkPrint_imagick

 private function watermarkPrint_imagick($src, $watermark, $dest_x, $dest_y, $quality, $transparency, $watermarkImgInfo)
 {
     try {
         // Open the original image
         $img = new Imagick($src);
         // Open the watermark
         $watermark = new Imagick($watermark);
         // Set transparency
         if (strtoupper($watermark->getImageFormat()) !== 'PNG') {
             $watermark->setImageOpacity($transparency / 100);
         }
         // Overlay the watermark on the original image
         $img->compositeImage($watermark, imagick::COMPOSITE_OVER, $dest_x, $dest_y);
         // Set quality
         if (strtoupper($img->getImageFormat()) === 'JPEG') {
             $img->setImageCompression(imagick::COMPRESSION_JPEG);
             $img->setCompressionQuality($quality);
         }
         $result = $img->writeImage($src);
         $img->clear();
         $img->destroy();
         $watermark->clear();
         $watermark->destroy();
         return $result ? true : false;
     } catch (Exception $e) {
         return false;
     }
 }
開發者ID:devsnippet,項目名稱:yona-cms,代碼行數:28,代碼來源:plugin.php

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

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

示例11: Imagick

 function imagick_thumbnail($image, $timage, $ext, $thumbnail_name, $imginfo)
 {
     try {
         $imagick = new Imagick();
         $fullpath = "./" . $this->thumbnail_path . "/" . $timage[0] . "/" . $thumbnail_name;
         if ($ext == "gif") {
             $imagick->readImage($image . '[0]');
         } else {
             $imagick->readImage($image);
         }
         $info = $imagick->getImageGeometry();
         $this->info[0] = $info['width'];
         $this->info[1] = $info['height'];
         $imagick->thumbnailImage($this->dimension, $this->dimension, true);
         if ($ext == "png" || $ext == "gif") {
             $white = new Imagick();
             $white->newImage($this->dimension, $this->dimension, "white");
             $white->compositeimage($image, Imagick::COMPOSITE_OVER, 0, 0);
             $white->writeImage($fullpath);
             $white->clear();
         } else {
             $imagick->writeImage($fullpath);
         }
         $imagick->clear();
     } catch (Exception $e) {
         echo "Unable to load image." . $e->getMessage();
         return false;
     }
     return true;
 }
開發者ID:logtcn,項目名稱:gelbooru-fork,代碼行數:30,代碼來源:image.class.php

示例12: apply

 /**
  * Apply the transformer on the absolute path and return an altered version of it.
  *
  * @param string $absolutePath
  *
  * @return string|false
  */
 public function apply($absolutePath)
 {
     $info = pathinfo($absolutePath);
     if (isset($info['extension']) && false !== strpos(strtolower($info['extension']), 'pdf') && file_exists($absolutePath)) {
         // If it doesn't exist yet, extract the first page of the PDF
         $previewFilename = $this->getPreviewFilename($absolutePath);
         if (!file_exists($previewFilename)) {
             $this->imagick->readImage($absolutePath . '[0]');
             $this->imagick->setImageFormat('jpg');
             $this->imagick->flattenimages();
             $this->imagick->writeImage($previewFilename);
             $this->imagick->clear();
         }
         $absolutePath = $previewFilename;
     }
     return $absolutePath;
 }
開發者ID:hyrmedia,項目名稱:KunstmaanBundlesCMS,代碼行數:24,代碼來源:PdfTransformer.php

示例13: destroy

 /**
  * @return  void
  */
 protected function destroy()
 {
     if ($this->resource) {
         $this->resource->clear();
         $this->resource->destroy();
         $this->resource = null;
     }
 }
開發者ID:Gerhard13,項目名稱:pimcore,代碼行數:11,代碼來源:Imagick.php

示例14:

 function _resize_image($image_path, $max_width = 100, $max_height = 100)
 {
     $imagick = new \Imagick(realpath($image_path));
     $imagick->thumbnailImage($max_width, $max_height, true);
     $blob = $imagick->getImageBlob();
     $imagick->clear();
     return $blob;
 }
開發者ID:maxmumford,項目名稱:j9-photo-manager,代碼行數:8,代碼來源:PhotoManager.php

示例15: testImageThumbnail

 public function testImageThumbnail()
 {
     var_dump("123 Inside Image Thumbnail");
     $thumb = new \Imagick('/home/vagrant/www/consult-api/app/myimage.jpg');
     $thumb->scaleImage(200, 200, 1);
     $thumb->writeImage('/home/vagrant/www/consult-api/app/mythumb.jpg');
     $thumb->clear();
     $thumb->destroy();
 }
開發者ID:nandanprac,項目名稱:capi,代碼行數:9,代碼來源:DoctorManagerTest.php


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