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


PHP Imagick::setImageMatte方法代碼示例

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


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

示例1: _mask

 protected function _mask($maskimage)
 {
     extract(parent::_mask($maskimage));
     $wmimage = new \Imagick();
     $wmimage->readImage($maskimage);
     $wmimage->setImageMatte(false);
     $this->imagick->compositeImage($wmimage, \Imagick::COMPOSITE_COPYOPACITY, 0, 0);
 }
開發者ID:469306621,項目名稱:Languages,代碼行數:8,代碼來源:imagick.php

示例2: load

 /**
  * (non-PHPdoc)
  * @see Imagine\ImagineInterface::load()
  */
 public function load($string)
 {
     try {
         $imagick = new \Imagick();
         $imagick->readImageBlob($string);
         $imagick->setImageMatte(true);
         return new Image($imagick);
     } catch (\ImagickException $e) {
         throw new RuntimeException('Could not load image from string', $e->getCode(), $e);
     }
 }
開發者ID:nicodmf,項目名稱:Imagine,代碼行數:15,代碼來源:Imagine.php

示例3: load

 public function load($string)
 {
     try {
         $magick = new \Imagick();
         $magick->readImageBlob($string);
         $magick->setImageMatte(true);
         $palette = self::createPalette($magick->getImageColorspace());
     } catch (\ImagickException $e) {
         throw new RuntimeException("Imagick: Could not load image from string. {$e->getMessage()}", $e->getCode(), $e);
     }
     return new RImage($magick, $palette, self::$emptyBag);
 }
開發者ID:raadhuis,項目名稱:modx-basic,代碼行數:12,代碼來源:RImagine.php

示例4: applyMask

 /**
  * @param  $image
  * @return Pimcore_Image_Adapter_Imagick
  */
 public function applyMask($image)
 {
     $image = ltrim($image, "/");
     $image = PIMCORE_DOCUMENT_ROOT . "/" . $image;
     if (is_file($image)) {
         $this->resource->setImageMatte(1);
         $newImage = new Imagick();
         $newImage->readimage($image);
         $newImage->resizeimage($this->getWidth(), $this->getHeight(), Imagick::FILTER_UNDEFINED, 1, false);
         $this->resource->compositeImage($newImage, Imagick::COMPOSITE_DSTIN, 0, 0);
     }
     $this->reinitializeImage();
     return $this;
 }
開發者ID:shanky0110,項目名稱:pimcore-custom,代碼行數:18,代碼來源:Imagick.php

示例5: applyMask

 /**
  * @param  $image
  * @return self
  */
 public function applyMask($image)
 {
     $this->preModify();
     $image = ltrim($image, "/");
     $image = PIMCORE_DOCUMENT_ROOT . "/" . $image;
     if (is_file($image)) {
         $this->resource->setImageMatte(1);
         $newImage = new \Imagick();
         $newImage->readimage($image);
         $newImage->resizeimage($this->getWidth(), $this->getHeight(), \Imagick::FILTER_UNDEFINED, 1, false);
         $this->resource->compositeImage($newImage, \Imagick::COMPOSITE_COPYOPACITY, 0, 0, \Imagick::CHANNEL_ALPHA);
     }
     $this->postModify();
     $this->setIsAlphaPossible(true);
     return $this;
 }
開發者ID:Gerhard13,項目名稱:pimcore,代碼行數:20,代碼來源:Imagick.php

示例6: load

 /**
  * {@inheritdoc}
  */
 public function load($string)
 {
     try {
         $imagick = new Imagick();
         $imagick->readImageBlob($string);
         $imagick->setImageMatte(true);
         return new Image($imagick, $this->createPalette($imagick), $this->getMetadataReader()->readData($string));
     } catch (\ImagickException $e) {
         throw new RuntimeException('Could not load image from string', $e->getCode(), $e);
     }
 }
開發者ID:jmstan,項目名稱:craft-website,代碼行數:14,代碼來源:Imagine.php

示例7: addWatermarkTextMask

 public function addWatermarkTextMask($text = "Copyright", $font = "Courier", $size = 20, $color = "grey70", $maskColor = "grey30", $position = \Imagick::GRAVITY_SOUTHEAST)
 {
     $watermark = new \Imagick();
     $mask = new \Imagick();
     $draw = new \ImagickDraw();
     $width = $this->getWidth();
     $height = $this->getHeight();
     $watermark->newImage($width, $height, new \ImagickPixel($maskColor));
     $mask->newImage($width, $height, new \ImagickPixel('black'));
     $draw->setFont($font);
     $draw->setFontSize($size);
     $draw->setFillColor($color);
     $draw->setGravity($position);
     $watermark->annotateImage($draw, 10, 12, 0, $text);
     $draw->setFillColor('white');
     $mask->annotateImage($draw, 11, 13, 0, $text);
     $mask->annotateImage($draw, 10, 12, 0, $text);
     $draw->setFillColor('black');
     $mask->annotateImage($draw, 9, 11, 0, $text);
     $mask->setImageMatte(false);
     $watermark->compositeImage($mask, \Imagick::COMPOSITE_COPYOPACITY, 0, 0);
     return $this->getImage()->compositeImage($watermark, \Imagick::COMPOSITE_DISSOLVE, 0, 0);
 }
開發者ID:deltaphp,項目名稱:image,代碼行數:23,代碼來源:Imagick.php

示例8: dirname

    echo 'failed at hurdle 1';
    exit;
}
require_once $_SERVER['DOCUMENT_ROOT'] . '/ww.incs/basics.php';
if ($src[0] == '/') {
    $src = USERBASE . $src;
} else {
    $src = dirname(__FILE__) . '/' . $src;
}
if ($mask[0] == '/') {
    $mask = USERBASE . $mask;
} else {
    $mask = dirname(__FILE__) . '/' . $mask;
}
if (!file_exists($src) || !file_exists($mask)) {
    echo 'failed at hurdle 2';
    exit;
}
$md5 = md5(print_r($_REQUEST, true));
$cache = 'cache';
if (file_exists('cache/' . $md5 . '.png')) {
    header('Content-Type: image/png');
    readfile('cache/' . $md5 . '.png');
}
$src = new Imagick($src);
$mask = new Imagick($mask);
$src->setImageMatte(1);
$src->compositeImage($mask, Imagick::COMPOSITE_DSTIN, 0, 0);
$src->writeImage('cache/' . $md5 . '.png');
header('Content-Type: image/png');
echo $src;
開發者ID:AmandaSyachri,項目名稱:webworks-webme,代碼行數:31,代碼來源:jquery.maskImage.php

示例9: _convert

 /**
  * Image conversion abstraction.
  *
  * @param string $source
  * @param array $size
  * @return Imagick
  */
 protected function _convert($source, $size)
 {
     extract($size);
     $im = new Imagick();
     $js = 0;
     $hint = max($tw, $th) * $js;
     if ($hint > 0 && $hint < $sw && $hint < $sh) {
         if (pathinfo($source, PATHINFO_EXTENSION) === 'jpg') {
             $im->setOption('jpeg:size', sprintf('%dx%d', $hint, $hint));
         }
     }
     $im->readImage($source);
     if ($im->getNumberImages() > 1) {
         $im->flattenImages();
     }
     $colorspace = $im->getImageColorSpace();
     if ($colorspace !== Imagick::COLORSPACE_RGB && $colorspace !== Imagick::COLORSPACE_SRGB) {
         $im->setImageColorSpace(Imagick::COLORSPACE_SRGB);
     }
     if ($im->getImageMatte()) {
         $im->setImageMatte(false);
     }
     if ($this->doesTrimming()) {
         $im->cropImage($sw, $sh, $sx, $sy);
     }
     if ($this->doesResampling()) {
         $im->resizeImage($tw, $th, Imagick::FILTER_LANCZOS, 0.9, true);
     }
     $im->stripImage();
     $degrees = $this->getRotation();
     if ($degrees) {
         $bgcolor = $this->getBgColor();
         $bg = sprintf('rgb(%d,%d,%d)', $bgcolor[0], $bgcolor[1], $bgcolor[2]);
         $im->rotateImage(new ImagickPixel($bg), $degrees);
     }
     if ($this->isPng()) {
         $im->setFormat('PNG');
     } else {
         $im->setFormat('JPEG');
         if ($this->getQuality()) {
             $im->setCompressionQuality($this->getQuality());
         }
     }
     return $im;
 }
開發者ID:xingskycn,項目名稱:p2-php,代碼行數:52,代碼來源:Imagick.php

示例10: renderImagePerspective

 function renderImagePerspective()
 {
     //Example Imagick::distortImage Perspective
     //$imagick = new \Imagick(realpath($this->rsiControl->getImagePath()));
     $imagick = new \Imagick();
     /* Create new checkerboard pattern */
     $imagick->newPseudoImage(100, 100, "pattern:checkerboard");
     /* Set the image format to png */
     $imagick->setImageFormat('png');
     /* Fill new visible areas with transparent */
     $imagick->setImageVirtualPixelMethod(\Imagick::VIRTUALPIXELMETHOD_TRANSPARENT);
     /* Activate matte */
     $imagick->setImageMatte(true);
     /* Control points for the distortion */
     $controlPoints = array(10, 10, 10, 5, 10, $imagick->getImageHeight() - 20, 10, $imagick->getImageHeight() - 5, $imagick->getImageWidth() - 10, 10, $imagick->getImageWidth() - 10, 20, $imagick->getImageWidth() - 10, $imagick->getImageHeight() - 10, $imagick->getImageWidth() - 10, $imagick->getImageHeight() - 30);
     /* Perform the distortion */
     $imagick->distortImage(\Imagick::DISTORTION_PERSPECTIVE, $controlPoints, true);
     header("Content-Type: image/jpg");
     echo $imagick->getImageBlob();
     //Example end
 }
開發者ID:sdmmember,項目名稱:Imagick-demos,代碼行數:21,代碼來源:distortImage.php

示例11: kingBar

function kingBar($a)
{
    $line_1 = $a['line_1'];
    $line_2 = $a['line_2'];
    $line_3 = $a['line_3'];
    $line_4 = $a['line_4'];
    $line_1_font = $a['line_1_font'];
    $line_2_font = $a['line_2_font'];
    $line_3_font = $a['line_3_font'];
    $line_4_font = $a['line_4_font'];
    $line_1_size = $a['line_1_size'];
    $line_2_size = $a['line_2_size'];
    $line_3_size = $a['line_3_size'];
    $line_4_size = $a['line_4_size'];
    $line_1_x = $a['line_1_x'];
    $line_2_x = $a['line_2_x'];
    $line_3_x = $a['line_3_x'];
    $line_4_x = $a['line_4_x'];
    $line_1_y = $a['line_1_y'];
    $line_2_y = $a['line_2_y'];
    $line_3_y = $a['line_3_y'];
    $line_4_y = $a['line_4_y'];
    $base = new \Imagick('/var/www/mch' . $a['base']);
    $draw = new \ImagickDraw();
    $fillColor = $base->getImagePixelColor(0, 0);
    $textColor = "rgb(126, 64, 17)";
    if (isset($a['layer_top']) && $a['layer_top'] != "") {
        $layout = new \Imagick();
        $layout_x = $a['layer_top_x'];
        $layout_y = $a['layer_top_y'];
        if ($a['image_uploaded'] != true) {
            $img = '/var/www/mch/' . $a['layer_top'];
            $blob = base64_decode(convert($img));
            $layout->readImageBlob($blob);
            $layout->setImageFormat('png');
        } else {
            $layout->readImage($img);
        }
    }
    if ($line_1 != "" || $line_2 != "" || $line_3 != "" || $line_4 != "") {
        // $line_1_x = $line_1_x + 25; $line_2_x = $line_2_x + 25; $line_3_x = $line_3_x + 25; $line_4_x = $line_4_x + 25;
        $line_1_x = $line_1_x < 70 ? 70 : $line_1_x;
        $line_1_x = $line_1_x > 196 ? 197 + 20 : $line_1_x;
        $line_2_x = $line_2_x < 70 ? 70 : $line_2_x;
        $line_2_x = $line_2_x > 196 ? 197 + 20 : $line_2_x;
        $line_3_x = $line_3_x < 70 ? 70 : $line_3_x;
        $line_3_x = $line_3_x > 196 ? 197 + 20 : $line_3_x;
        $line_4_x = $line_4_x < 70 ? 70 : $line_4_x;
        $line_4_x = $line_4_x > 196 ? 197 + 20 : $line_4_x;
        $size = getimagesize('/var/www/mch' . $a['base']);
        $w = $size[0];
        $h = $size[1];
        $tras = new Imagick();
        $mask = new Imagick();
        $tras->newImage($w, $h, new ImagickPixel('grey30'));
        $mask->newImage($w, $h, new ImagickPixel('black'));
        // $tras->paintTransparentImage(new ImagickPixel('black'), 0.4, 0);
        $draw->setFont($line_1_font);
        $draw->setFontSize($line_1_size);
        $draw->setFontWeight(700);
        $draw->setFillColor($textColor);
        $tras->annotateImage($draw, $line_1_x - 1, $line_1_y - 1, 0, $line_1);
        $draw->setFillColor('white');
        $mask->annotateImage($draw, $line_1_x, $line_1_y, 0, $line_1);
        $mask->annotateImage($draw, $line_1_x - 1, $line_1_y - 1, 0, $line_1);
        $draw->setFillColor('black');
        $mask->annotateImage($draw, $line_1_x - 2, $line_1_y - 2, 0, $line_1);
        $draw->setFont($line_2_font);
        $draw->setFontSize($line_2_size);
        $draw->setFontWeight(700);
        $draw->setFillColor($textColor);
        $tras->annotateImage($draw, $line_2_x - 1, $line_2_y - 1, 0, $line_2);
        $draw->setFillColor('white');
        $mask->annotateImage($draw, $line_2_x, $line_2_y, 0, $line_2);
        $mask->annotateImage($draw, $line_2_x - 1, $line_2_y - 1, 0, $line_2);
        $draw->setFillColor('black');
        $mask->annotateImage($draw, $line_2_x - 2, $line_2_y - 2, 0, $line_2);
        $draw->setFont($line_3_font);
        $draw->setFontSize($line_3_size);
        $draw->setFontWeight(700);
        $draw->setFillColor($textColor);
        $tras->annotateImage($draw, $line_3_x - 1, $line_3_y - 1, 0, $line_3);
        $draw->setFillColor('white');
        $mask->annotateImage($draw, $line_3_x, $line_3_y, 0, $line_3);
        $mask->annotateImage($draw, $line_3_x - 1, $line_3_y - 1, 0, $line_3);
        $draw->setFillColor('black');
        $mask->annotateImage($draw, $line_3_x - 2, $line_3_y - 2, 0, $line_3);
        $draw->setFont($line_4_font);
        $draw->setFontSize($line_4_size);
        $draw->setFontWeight(700);
        $draw->setFillColor($textColor);
        $tras->annotateImage($draw, $line_4_x - 1, $line_4_y - 1, 0, $line_4);
        $draw->setFillColor('white');
        $mask->annotateImage($draw, $line_4_x, $line_4_y, 0, $line_4);
        $mask->annotateImage($draw, $line_4_x - 1, $line_4_y - 1, 0, $line_4);
        $draw->setFillColor('black');
        $mask->annotateImage($draw, $line_4_x - 2, $line_4_y - 2, 0, $line_4);
        $mask->setImageMatte(false);
        $tras->compositeImage($mask, Imagick::COMPOSITE_COPYOPACITY, 0, 0);
        $base->compositeImage($tras, Imagick::COMPOSITE_DISSOLVE, 0, 0);
//.........這裏部分代碼省略.........
開發者ID:VinceOmega,項目名稱:mcb-nov-build,代碼行數:101,代碼來源:bar_preview.php

示例12: Imagick

if (array_key_exists("img", $_REQUEST)) {
    $image = $_REQUEST['img'];
    try {
        $img = new Imagick($image);
        if ($img->valid()) {
            if ($img->getImageWidth() > $img->getImageHeight()) {
                $img->rotateImage(new ImagickPixel('none'), 90);
            }
            $img->thumbnailImage(0, 160);
            if ($img->getImageWidth() > 128) {
                $img->thumbnailImage(128, 0);
            }
            $img->setImageFormat('bmp');
            $img->setCompression(imagick::COMPRESSION_NO);
            $img->setImageDepth(24);
            $img->setImageMatte(false);
            $img->flopImage();
            //$img->setImageAlphaChannel(imagick::ALPHACHANNEL_DEACTIVATE);
            $imgData = (string) $img;
            header("Content-Type: image/bmp");
            header("Content-Length: " . strlen($imgData));
            echo $img;
        } else {
            throw new Exception("image not valid");
        }
    } catch (Exception $e) {
        //http_response_code(403);
        echo $e;
    }
}
開發者ID:rmd6502,項目名稱:PicClient,代碼行數:30,代碼來源:image.php


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