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


PHP ImagickPixel::destroy方法代碼示例

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


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

示例1: watermarkText


//.........這裏部分代碼省略.........
     }
     // if start x or y is NOT number, find the real position of start x or y from word left, center, right, top, middle, bottom
     if (!is_numeric($wm_txt_start_x) || !is_numeric($wm_txt_start_y)) {
         if (!is_numeric($wm_txt_start_x)) {
             switch (strtolower($wm_txt_start_x)) {
                 case 'center':
                     $image_width = $this->Imagick->getImageWidth();
                     $watermark_width = $wm_txt_width;
                     $wm_txt_start_x = $this->calculateStartXOfCenter($watermark_width, $image_width);
                     unset($image_width, $watermark_width);
                     break;
                 case 'right':
                     $image_width = $this->Imagick->getImageWidth();
                     $wm_txt_start_x = intval($image_width - $wm_txt_width) - 5;
                     // minus 5 because Imagick is different from GD.
                     unset($image_width);
                     break;
                 case 'left':
                 default:
                     $wm_txt_start_x = 10;
                     // Imagick is different from GD, so increase it.
                     break;
             }
         }
         if (!is_numeric($wm_txt_start_y)) {
             switch (strtolower($wm_txt_start_y)) {
                 case 'middle':
                     $image_height = $this->Imagick->getImageHeight();
                     $watermark_height = $wm_txt_height;
                     $wm_txt_start_y = $this->calculateStartXOfCenter($watermark_height, $image_height);
                     unset($image_height, $watermark_height);
                     break;
                 case 'bottom':
                     $image_height = $this->Imagick->getImageHeight();
                     if ($image_height - ($wm_txt_height + 5) > '0') {
                         $wm_txt_start_y = intval($image_height - ($wm_txt_height + 5));
                     } else {
                         $wm_txt_start_y = intval($image_height - $wm_txt_height);
                     }
                     unset($image_height);
                     break;
                 case 'top':
                 default:
                     $wm_txt_start_y = 10;
                     // Imagick is different from GD, so increase it.
                     break;
             }
         }
     }
     // begins watermark text --------------------------------------------------------------------------------------------
     // set color
     $black = new \ImagickPixel('black');
     $white = new \ImagickPixel('white');
     $transwhite = new \ImagickPixel('rgba(255, 255, 255, 0)');
     // set color transparent white
     $transwhitetext = new \ImagickPixel('rgba(255, 255, 255, ' . $this->convertAlpha127ToRgba($wm_txt_font_alpha) . ')');
     if (!isset(${$wm_txt_font_color})) {
         $wm_txt_font_color = 'transwhitetext';
     }
     // fill font color
     $ImagickDraw->setFillColor(${$wm_txt_font_color});
     // write text on image
     if ($this->source_image_frames > 1) {
         // if source image is animated gif
         $this->Imagick = $this->Imagick->coalesceImages();
         if (is_object($this->Imagick)) {
             $i = 1;
             foreach ($this->Imagick as $Frame) {
                 $Frame->annotateImage($ImagickDraw, $wm_txt_start_x, $wm_txt_start_y, 0, $wm_txt_text);
                 $Frame->setImagePage(0, 0, 0, 0);
                 if ($i == 1) {
                     $this->ImagickFirstFrame = $Frame->getImage();
                 }
                 $i++;
             }
             unset($Frame, $i);
         }
     } else {
         $this->Imagick->annotateImage($ImagickDraw, $wm_txt_start_x, $wm_txt_start_y, 0, $wm_txt_text);
         if ($this->source_image_type == '1') {
             // if source image is gif, set image page to prevent sizing error.
             $this->Imagick->setImagePage(0, 0, 0, 0);
         }
         $this->ImagickFirstFrame = null;
     }
     // end watermark text -----------------------------------------------------------------------------------------------
     $ImagickDraw->clear();
     $black->destroy();
     $transwhite->destroy();
     $transwhitetext->destroy();
     $white->destroy();
     unset($black, $ImagickDraw, $transwhite, $transwhitetext, $white, $wm_txt_height, $wm_txt_width);
     $this->destination_image_height = $this->Imagick->getImageHeight();
     $this->destination_image_width = $this->Imagick->getImageWidth();
     $this->source_image_height = $this->destination_image_height;
     $this->source_image_width = $this->destination_image_width;
     $this->status = true;
     $this->status_msg = null;
     return true;
 }
開發者ID:rundiz,項目名稱:image,代碼行數:101,代碼來源:Imagick.php

示例2: Imagick

<?php

$im = new Imagick();
$im->clear();
$im->destroy();
$im = new ImagickDraw();
$im->clear();
$im->destroy();
$im = new ImagickPixel();
$im->clear();
$im->destroy();
$magick = new Imagick('magick:rose');
$im = new ImagickPixelIterator($magick);
$im->clear();
$im->destroy();
echo 'success';
開發者ID:badlamer,項目名稱:hhvm,代碼行數:16,代碼來源:017_clear_destroy.php


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