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


PHP Imagick::setImageType方法代碼示例

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


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

示例1: grayscale

 /**
  * @return self
  */
 public function grayscale()
 {
     $this->preModify();
     $this->resource->setImageType(\Imagick::IMGTYPE_GRAYSCALEMATTE);
     $this->postModify();
     return $this;
 }
開發者ID:Gerhard13,項目名稱:pimcore,代碼行數:10,代碼來源:Imagick.php

示例2: mkbilder

 function mkbilder($typ)
 {
     $this->err->write('mkbilder', $typ);
     $org = new Imagick();
     if (!$org->readImage("/tmp/tmp.file_org")) {
         return false;
     }
     $big = new Imagick();
     $big->newImage($this->bigwidth, $this->bigheight, new ImagickPixel('white'));
     $big->setImageFormat($typ);
     //$big->setImageColorspace($org->getImageColorspace() );
     $big->setImageType(imagick::IMGTYPE_TRUECOLOR);
     $org->scaleImage($this->bigwidth, $this->bigheight, true);
     $d = $org->getImageGeometry();
     $xoff = ($this->bigwidth - $d['width']) / 2;
     $big->compositeImage($org, imagick::COMPOSITE_DEFAULT, $xoff, 0);
     $rc = $big->writeImage("/tmp/tmp.file_org");
     $big->clear();
     $big->destroy();
     $small = new Imagick();
     $small->newImage($this->smallwidth, $this->smallheight, new ImagickPixel('white'));
     $small->setImageFormat($typ);
     //$small->setImageColorspace($org->getImageColorspace() );
     $small->setImageType(imagick::IMGTYPE_TRUECOLOR);
     $org->scaleImage($this->smallwidth, $this->smallheight, true);
     $d = $org->getImageGeometry();
     $xoff = ($this->smallwidth - $d['width']) / 2;
     $small->compositeImage($org, imagick::ALIGN_CENTER, $xoff, 0);
     $rc = $small->writeImage("/tmp/tmp.file_small");
     $small->clear();
     $small->destroy();
     $org->clear();
     $org->destroy();
     return true;
 }
開發者ID:vanloswang,項目名稱:kivitendo-crm,代碼行數:35,代碼來源:Picture.php

示例3: grayscale

 /**
  * Convert the current image to grayscale.
  */
 public function grayscale()
 {
     try {
         $this->_imagick->setImageType(Imagick::IMGTYPE_GRAYSCALE);
     } catch (ImageException $e) {
         throw new Horde_Image_Exception($e);
     }
 }
開發者ID:jubinpatel,項目名稱:horde,代碼行數:11,代碼來源:Imagick.php

示例4: greyscale

 /**
  * Converts the image to greyscale
  *
  * @return bool|PEAR_Error TRUE or a PEAR_Error object on error
  * @access public
  */
 function greyscale()
 {
     $this->imagick->setImageType(Imagick::IMGTYPE_GRAYSCALE);
     /*$this->imagick->setImageColorSpace(Imagick::COLORSPACE_GRAY);
       $this->imagick->setImageDepth(8);
       $this->imagick->separateImageChannel(Imagick::CHANNEL_GRAY);
       $this->imagick->setImageChannelDepth(Imagick::CHANNEL_GRAY, 8);*/
     return true;
 }
開發者ID:rivetweb,項目名稱:old-book-with-active-areas,代碼行數:15,代碼來源:Imagick3.php

示例5: newImage

 /**
  * Creates new image instance
  *
  * @param  integer $width
  * @param  integer $height
  * @param  string  $background
  * @return \Intervention\Image\Image
  */
 public function newImage($width, $height, $background = null)
 {
     $background = new Color($background);
     // create empty core
     $core = new \Imagick();
     $core->newImage($width, $height, $background->getPixel(), 'png');
     $core->setType(\Imagick::IMGTYPE_UNDEFINED);
     $core->setImageType(\Imagick::IMGTYPE_UNDEFINED);
     $core->setColorspace(\Imagick::COLORSPACE_UNDEFINED);
     // build image
     $image = new \Intervention\Image\Image(new static(), $core);
     return $image;
 }
開發者ID:Roc4rdho,項目名稱:app,代碼行數:21,代碼來源:Driver.php

示例6: initFromPath

 /**
  * Initiates new image from path in filesystem
  *
  * @param  string $path
  * @return \Intervention\Image\Image
  */
 public function initFromPath($path)
 {
     $core = new \Imagick();
     try {
         $core->readImage($path);
         $core->setImageType(\Imagick::IMGTYPE_TRUECOLORMATTE);
     } catch (\ImagickException $e) {
         throw new \Intervention\Image\Exception\NotReadableException("Unable to read image from path ({$path}).", 0, $e);
     }
     // build image
     $image = $this->initFromImagick($core);
     $image->setFileInfoFromPath($path);
     return $image;
 }
開發者ID:drickferreira,項目名稱:rastreador,代碼行數:20,代碼來源:Decoder.php

示例7: background

 private function background()
 {
     if ($this->config['method'] === 'image' && is_file($this->config['image'])) {
         $image = new \Imagick();
         try {
             $image->readImage($this->config['image']);
             $image->setImageType(\Imagick::IMGTYPE_TRUECOLORMATTE);
         } catch (\ImagickException $e) {
             throw new Exception\NotSupportedException("Ivatar - ({$this->config['image']}) unable to open image.");
         }
         $image->cropThumbnailImage($this->options['size'], $this->options['size']);
         $this->ivatar->compositeImage($image, \Imagick::COMPOSITE_DEFAULT, 0, 0);
     }
 }
開發者ID:cloudratha,項目名稱:ivatar,代碼行數:14,代碼來源:Driver.php

示例8: Imagick

 /**
  * Creates a true color image
  *
  * @param int $w the width of the image
  * @param int $h the height of the image
  * @return Imagick
  */
 function zp_createImage($w, $h)
 {
     $im = new Imagick();
     $im->newImage($w, $h, 'none');
     $im->setImageType(Imagick::IMGTYPE_TRUECOLORMATTE);
     return $im;
 }
開發者ID:ariep,項目名稱:ZenPhoto20-DEV,代碼行數:14,代碼來源:lib-Imagick.php

示例9: grayscale

 /**
  * @return Pimcore_Image_Adapter_Imagick
  */
 public function grayscale()
 {
     $this->resource->setImageType(imagick::IMGTYPE_GRAYSCALEMATTE);
     $this->reinitializeImage();
     return $this;
 }
開發者ID:shanky0110,項目名稱:pimcore-custom,代碼行數:9,代碼來源:Imagick.php

示例10: Imagick

 function encode_imagick($ps_filepath, $ps_output_path, $pa_options)
 {
     if (!($magick = $this->mimetype2magick[$pa_options["output_mimetype"]])) {
         $this->error = "Invalid output format";
         return false;
     }
     #
     # Open image
     #
     $h = new Imagick();
     if (!$h->readImage($ps_filepath)) {
         $this->error = "Couldn't open image {$ps_filepath}";
         return false;
     }
     if (function_exists('exif_read_data')) {
         if (is_array($va_exif = @exif_read_data($ps_filepath, 'EXIF', true, false))) {
             if (isset($va_exif['IFD0']['Orientation'])) {
                 $vn_orientation = $va_exif['IFD0']['Orientation'];
                 switch ($vn_orientation) {
                     case 3:
                         $h->rotateImage("#FFFFFF", 180);
                         break;
                     case 6:
                         $h->rotateImage("#FFFFFF", 90);
                         break;
                     case 8:
                         $h->rotateImage("#FFFFFF", -90);
                         break;
                 }
             }
         }
     }
     $h->setImageType(imagick::IMGTYPE_TRUECOLOR);
     if (!$h->setImageColorspace(imagick::COLORSPACE_RGB)) {
         $this->error = "Error during RGB colorspace transformation operation";
         return false;
     }
     $va_tmp = $h->getImageGeometry();
     $image_width = $va_tmp['width'];
     $image_height = $va_tmp['height'];
     if ($image_width < 10 || $image_height < 10) {
         $this->error = "Image is too small to be output as Tilepic; minimum dimensions are 10x10 pixels";
         return false;
     }
     if ($pa_options["scale_factor"] != 1) {
         $image_width *= $pa_options["scale_factor"];
         $image_height *= $pa_options["scale_factor"];
         if (!$h->resizeImage($image_width, $image_height, imagick::FILTER_CUBIC, $pa_options["antialiasing"])) {
             $this->error = "Couldn't scale image";
             return false;
         }
     }
     #
     # How many layers to make?
     #
     if (!$pa_options["layers"]) {
         $sw = $image_width * $pa_options["layer_ratio"];
         $sh = $image_height * $pa_options["layer_ratio"];
         $pa_options["layers"] = 1;
         while ($sw >= $pa_options["tile_width"] || $sh >= $pa_options["tile_height"]) {
             $sw = ceil($sw / $pa_options["layer_ratio"]);
             $sh = ceil($sh / $pa_options["layer_ratio"]);
             $pa_options["layers"]++;
         }
     }
     #
     # Cut image into tiles
     #
     $tiles = 0;
     $layer_list = array();
     $base_width = $image_width;
     $base_height = $image_height;
     if ($this->debug) {
         print "BASE {$base_width} x {$base_height} \n";
     }
     for ($l = $pa_options["layers"]; $l >= 1; $l--) {
         $x = $y = 0;
         $wx = $pa_options["tile_width"];
         $wy = $pa_options["tile_height"];
         if ($this->debug) {
             print "LAYER={$l}\n";
         }
         if ($l < $pa_options["layers"]) {
             $image_width = ceil($image_width / $pa_options["layer_ratio"]);
             $image_height = ceil($image_height / $pa_options["layer_ratio"]);
             if ($this->debug) {
                 print "RESIZE layer {$l} TO {$image_width} x {$image_height} \n";
             }
             if (!$h->resizeImage($image_width, $image_height, imagick::FILTER_CUBIC, $pa_options["antialiasing"])) {
                 $this->error = "Couldn't scale image";
                 return false;
             }
         }
         $i = 0;
         $layer_list[] = array();
         while ($y < $image_height) {
             if (!($slice = $h->getImageRegion($wx, $wy, $x, $y))) {
                 $this->error = "Couldn't create tile";
                 return false;
             }
//.........這裏部分代碼省略.........
開發者ID:guaykuru,項目名稱:pawtucket,代碼行數:101,代碼來源:TilepicParser.php

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

示例12: _isLightImage

 private function _isLightImage($imageData)
 {
     $image = new Imagick();
     $image->readImageBlob($imageData['contents']);
     $max = $image->getQuantumRange();
     $max = $max["quantumRangeLong"];
     $image->setImageType(Imagick::IMGTYPE_GRAYSCALEMATTE);
     $float = 0.5;
     $image->thresholdImage($float * $max, 255);
     $image->setBackgroundColor('white');
     $black = 0;
     $white = 0;
     for ($x = 0; $x < $image->getImageWidth(); $x++) {
         for ($y = 0; $y < $image->getImageHeight(); $y++) {
             $pixel = $image->getImagePixelColor($x, $y);
             $value = $pixel->getColor();
             if ($value['r'] == 0 && $value['g'] == 0 && $value['b'] == 0) {
                 $black++;
             } else {
                 $white++;
             }
         }
     }
     return $white > $black;
 }
開發者ID:koala-framework,項目名稱:koala-framework,代碼行數:25,代碼來源:UploadController.php

示例13: setStrokeMiterLimit

function setStrokeMiterLimit($strokeColor, $fillColor, $backgroundColor)
{
    $draw = new \ImagickDraw();
    $draw->setStrokeColor($strokeColor);
    $draw->setStrokeOpacity(0.6);
    $draw->setFillColor($fillColor);
    $draw->setStrokeWidth(10);
    $yOffset = 100;
    $draw->setStrokeLineJoin(\Imagick::LINEJOIN_MITER);
    for ($y = 0; $y < 3; $y++) {
        $draw->setStrokeMiterLimit(40 * $y);
        $points = [['x' => 22 * 3, 'y' => 15 * 4 + $y * $yOffset], ['x' => 20 * 3, 'y' => 20 * 4 + $y * $yOffset], ['x' => 70 * 5, 'y' => 45 * 4 + $y * $yOffset]];
        $draw->polygon($points);
    }
    $image = new \Imagick();
    $image->newImage(500, 500, $backgroundColor);
    $image->setImageFormat("png");
    $image->drawImage($draw);
    $image->setImageType(\Imagick::IMGTYPE_PALETTE);
    //TODO - this should either be everywhere or nowhere
    $image->setImageCompressionQuality(100);
    $image->stripImage();
    header("Content-Type: image/png");
    echo $image->getImageBlob();
}
開發者ID:sdmmember,項目名稱:Imagick-demos,代碼行數:25,代碼來源:functions.php

示例14: greyscale

 /**
  * {@inheritdoc}
  */
 public function greyscale()
 {
     $this->image->setImageType(Imagick::IMGTYPE_GRAYSCALE);
 }
開發者ID:muhammetardayildiz,項目名稱:framework,代碼行數:7,代碼來源:ImageMagick.php


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