本文整理匯總了PHP中ImagickDraw::annotation方法的典型用法代碼示例。如果您正苦於以下問題:PHP ImagickDraw::annotation方法的具體用法?PHP ImagickDraw::annotation怎麽用?PHP ImagickDraw::annotation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ImagickDraw
的用法示例。
在下文中一共展示了ImagickDraw::annotation方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: renderImage
public function renderImage()
{
//Create a ImagickDraw object to draw into.
$draw = new \ImagickDraw();
$darkColor = new \ImagickPixel('brown');
//http://www.imagemagick.org/Usage/compose/#compose_terms
$draw->setStrokeColor($darkColor);
$draw->setFillColor('white');
$draw->setStrokeWidth(2);
$draw->setFontSize(72);
$draw->setStrokeOpacity(1);
$draw->setStrokeColor($darkColor);
$draw->setStrokeWidth(2);
$draw->setFont("../fonts/CANDY.TTF");
$draw->setFontSize(140);
$draw->setFillColor('none');
$draw->rectangle(0, 0, 1000, 300);
$draw->setFillColor('white');
$draw->annotation(50, 180, "Lorem Ipsum!");
$imagick = new \Imagick(realpath("images/TestImage.jpg"));
$draw->composite(\Imagick::COMPOSITE_MULTIPLY, -500, -200, 2000, 600, $imagick);
//Create an image object which the draw commands can be rendered into
$imagick = new \Imagick();
$imagick->newImage(1000, 300, "SteelBlue2");
$imagick->setImageFormat("png");
//Render the draw commands in the ImagickDraw object
//into the image.
$imagick->drawImage($draw);
//Send the image to the browser
header("Content-Type: image/png");
echo $imagick->getImageBlob();
}
示例2: createAvatarAutomatically
/**
* アバター自動生成処理
*
* @param Model $model ビヘイビア呼び出し元モデル
* @param array $user ユーザデータ配列
* @return mixed On success Model::$data, false on failure
* @throws InternalErrorException
*/
public function createAvatarAutomatically(Model $model, $user)
{
//imagickdraw オブジェクトを作成します
$draw = new ImagickDraw();
//文字色のセット
$draw->setfillcolor('white');
//フォントサイズを 160 に設定します
$draw->setFontSize(140);
//テキストを追加します
$draw->setFont(CakePlugin::path($model->plugin) . 'webroot' . DS . 'fonts' . DS . 'ipaexg.ttf');
$draw->annotation(19, 143, mb_substr(mb_convert_kana($user['User']['handlename'], 'KVA'), 0, 1));
//新しいキャンバスオブジェクトを作成する
$canvas = new Imagick();
//ランダムで背景色を指定する
$red1 = strtolower(dechex(mt_rand(3, 12)));
$red2 = strtolower(dechex(mt_rand(0, 15)));
$green1 = strtolower(dechex(mt_rand(3, 12)));
$green2 = strtolower(dechex(mt_rand(0, 15)));
$blue1 = strtolower(dechex(mt_rand(3, 12)));
$blue2 = strtolower(dechex(mt_rand(0, 15)));
$canvas->newImage(179, 179, '#' . $red1 . $red2 . $green1 . $green2 . $blue1 . $blue2);
//ImagickDraw をキャンバス上に描畫します
$canvas->drawImage($draw);
//フォーマットを PNG に設定します
$canvas->setImageFormat('png');
App::uses('TemporaryFolder', 'Files.Utility');
$folder = new TemporaryFolder();
$filePath = $folder->path . DS . Security::hash($user['User']['handlename'], 'md5') . '.png';
$canvas->writeImages($filePath, true);
return $filePath;
}
示例3: test_annotation
function test_annotation(&$canvas)
{
$draw = new ImagickDraw();
$font = __DIR__ . '/php_imagick_tests/anonymous_pro_minus.ttf';
$draw->setFont($font);
$draw->setFontSize(40);
$draw->annotation(50, 440, 'Yukkuri shiteitte ne!!!');
$canvas->drawImage($draw);
}
示例4: build
public function build()
{
// Prepage image
$this->_canvas = new Imagick();
$this->_canvas->newImage(self::WIDTH, self::HEIGHT, new ImagickPixel("white"));
$color['line'] = new ImagickPixel("rgb(216, 76, 64)");
$color['text'] = new ImagickPixel("rgb(16, 35, 132)");
$color['karma'] = new ImagickPixel("rgb(116, 194, 98)");
$color['force'] = new ImagickPixel("rgb(37, 168, 255)");
$color['bottom_bg'] = new ImagickPixel("rgb(255, 244, 224)");
$color['bg'] = new ImagickPixel("white");
$color['neutral'] = new ImagickPixel("rgb(200, 200, 200)");
$color['habr'] = new ImagickPixel("rgb(83, 121, 139)");
$color['transparent'] = new ImagickPixel("transparent");
// Prepare canvas for drawing main graph
$draw = new ImagickDraw();
$draw->setStrokeAntialias(true);
$draw->setStrokeWidth(2);
// Draw bottom bg
define('TOP_SPACER', 10);
$draw = new ImagickDraw();
$draw->setFillColor($color['bg']);
$draw->setStrokeColor($color['habr']);
$draw->polyline(array(array('x' => 0, 'y' => 0), array('x' => self::WIDTH - 1, 'y' => 0), array('x' => self::WIDTH - 1, 'y' => self::HEIGHT - 1), array('x' => 0, 'y' => self::HEIGHT - 1), array('x' => 0, 'y' => 0)));
$this->_canvas->drawImage($draw);
$draw->destroy();
// Draw texts
$draw = new ImagickDraw();
$draw->setTextAlignment(Imagick::ALIGN_CENTER);
$draw->setTextAntialias(true);
$draw->setTextUnderColor($color['karma']);
$draw->setFillColor($color['bg']);
$draw->setFontSize(9 - 1 * ($this->_karma > 99 || $this->_habraforce > 99));
$draw->setFont(realpath('stuff/consolab.ttf'));
$draw->annotation(self::WIDTH / 2, 10, sprintf('%01.2f', $this->_karma));
$draw->setTextUnderColor($color['force']);
$draw->setFillColor($color['bg']);
$draw->annotation(self::WIDTH / 2, 23, sprintf('%01.2f', $this->_habraforce));
$this->_canvas->drawImage($draw);
$draw->destroy();
return true;
}
示例5: perform
/**
* Draws some text on the handle
*
* @param Zend_Image_Adapter_ImageMagick $adapter Adapter
* @param Zend_Image_Action_DrawText $textObject The object that with all info
*/
public function perform($adapter, Zend_Image_Action_DrawText $textObject)
{
// As of ZF2.0 / PHP5.3, this can be made static.
$handle = $adapter->getHandle();
$color = new ImagickPixel('#000000');
// . $textObject->getColor());
$draw = new ImagickDraw();
$draw->annotation($textObject->getOffsetX(), $textObject->getOffsetY(), $textObject->getText());
$handle->drawImage($draw);
return $handle;
}
示例6: render
public function render($pDatas)
{
$im = new Imagick();
$im->newImage(300, 300, "white", "png");
$draw = new ImagickDraw();
foreach ($pDatas as $key => $data) {
if ($data->value == 0) {
continue;
}
$draw->setFillColor('red');
$draw->setstrokecolor('black');
$draw->polygon($data->polygons);
$draw->setFillColor('black');
$draw->setFontSize(18);
$draw->annotation($data->center['x'], $data->center['y'] + 9, $data->value);
}
$im->drawimage($draw);
return $im;
}
示例7: renderImage
public function renderImage()
{
$imagick = new \Imagick(realpath("images/TestImage.jpg"));
$draw = new \ImagickDraw();
$darkColor = new \ImagickPixel('brown');
$lightColor = new \ImagickPixel('LightCoral');
$draw->setStrokeColor($darkColor);
$draw->setFillColor($lightColor);
$draw->setStrokeWidth(2);
$draw->setFontSize(36);
$draw->setFont("../fonts/Arial.ttf");
$draw->annotation(50, 50, "Lorem Ipsum!");
$msg = "Danack";
$xpos = 0;
$ypos = 0;
list($lines, $lineHeight) = wordWrapAnnotation($imagick, $draw, $msg, 140);
for ($i = 0; $i < count($lines); $i++) {
$imagick->annotateImage($draw, $xpos, $ypos + $i * $lineHeight, 0, $lines[$i]);
}
header("Content-Type: image/jpg");
echo $imagick->getImageBlob();
}
示例8: renderImage
function renderImage()
{
//Create a ImagickDraw object to draw into.
$draw = new \ImagickDraw();
$darkColor = new \ImagickPixel('brown');
//http://www.imagemagick.org/Usage/compose/#compose_terms
$draw->setStrokeColor($darkColor);
$draw->setFillColor('white');
$draw->setStrokeWidth(2);
$draw->setFontSize(72);
$draw->setStrokeOpacity(1);
$draw->setStrokeColor($darkColor);
$draw->setStrokeWidth(2);
$draw->setFont("../fonts/CANDY.TTF");
$draw->setFontSize(140);
$draw->setFillColor('none');
$draw->rectangle(0, 0, 1000, 300);
$draw->setFillColor('white');
$draw->annotation(50, 180, "Lorem Ipsum!");
$imagick = new \Imagick(realpath("images/TestImage.jpg"));
// $compositeModes = [
//
// \Imagick::COMPOSITE_NO, \Imagick::COMPOSITE_ADD, \Imagick::COMPOSITE_ATOP, \Imagick::COMPOSITE_BLEND, \Imagick::COMPOSITE_BUMPMAP, \Imagick::COMPOSITE_CLEAR, \Imagick::COMPOSITE_COLORBURN, \Imagick::COMPOSITE_COLORDODGE, \Imagick::COMPOSITE_COLORIZE, \Imagick::COMPOSITE_COPYBLACK, \Imagick::COMPOSITE_COPYBLUE, \Imagick::COMPOSITE_COPY, \Imagick::COMPOSITE_COPYCYAN, \Imagick::COMPOSITE_COPYGREEN, \Imagick::COMPOSITE_COPYMAGENTA, \Imagick::COMPOSITE_COPYOPACITY, \Imagick::COMPOSITE_COPYRED, \Imagick::COMPOSITE_COPYYELLOW, \Imagick::COMPOSITE_DARKEN, \Imagick::COMPOSITE_DSTATOP, \Imagick::COMPOSITE_DST, \Imagick::COMPOSITE_DSTIN, \Imagick::COMPOSITE_DSTOUT, \Imagick::COMPOSITE_DSTOVER, \Imagick::COMPOSITE_DIFFERENCE, \Imagick::COMPOSITE_DISPLACE, \Imagick::COMPOSITE_DISSOLVE, \Imagick::COMPOSITE_EXCLUSION, \Imagick::COMPOSITE_HARDLIGHT, \Imagick::COMPOSITE_HUE, \Imagick::COMPOSITE_IN, \Imagick::COMPOSITE_LIGHTEN, \Imagick::COMPOSITE_LUMINIZE, \Imagick::COMPOSITE_MINUS, \Imagick::COMPOSITE_MODULATE, \Imagick::COMPOSITE_MULTIPLY, \Imagick::COMPOSITE_OUT, \Imagick::COMPOSITE_OVER, \Imagick::COMPOSITE_OVERLAY, \Imagick::COMPOSITE_PLUS, \Imagick::COMPOSITE_REPLACE, \Imagick::COMPOSITE_SATURATE, \Imagick::COMPOSITE_SCREEN, \Imagick::COMPOSITE_SOFTLIGHT, \Imagick::COMPOSITE_SRCATOP, \Imagick::COMPOSITE_SRC, \Imagick::COMPOSITE_SRCIN, \Imagick::COMPOSITE_SRCOUT, \Imagick::COMPOSITE_SRCOVER, \Imagick::COMPOSITE_SUBTRACT, \Imagick::COMPOSITE_THRESHOLD, \Imagick::COMPOSITE_XOR,
//
// ];
$draw->composite(\Imagick::COMPOSITE_MULTIPLY, -500, -200, 2000, 600, $imagick);
//Create an image object which the draw commands can be rendered into
$imagick = new \Imagick();
$imagick->newImage(1000, 300, "SteelBlue2");
$imagick->setImageFormat("png");
//Render the draw commands in the ImagickDraw object
//into the image.
$imagick->drawImage($draw);
//Send the image to the browser
header("Content-Type: image/png");
echo $imagick->getImageBlob();
}
示例9: filter_render_type
/**
* function filter_render_type
* Returns HTML markup containing an image with a data: URI
* @param string $content The text to be rendered
* @param string $font_file The path to a font file in a format ImageMagick can handle
* @param integer $font_size The font size, in pixels (defaults to 28)
* @param string $font_color The font color (defaults to 'black')
* @param string $background_color The background color (defaults to 'transparent')
* @param string $output_format The image format to use (defaults to 'png')
* @return string HTML markup containing the rendered image
**/
public function filter_render_type($content, $font_file, $font_size, $font_color, $background_color, $output_format, $width)
{
// Preprocessing $content
// 1. Strip HTML tags. It would be better to support them, but we just strip them for now.
// 2. Decode HTML entities to UTF-8 charaaters.
$content = html_entity_decode(strip_tags($content), ENT_QUOTES, 'UTF-8');
// 3. Do word wrap when $width is specified. Not work for double-width characters.
if (is_int($width)) {
$content = wordwrap($content, floor($width / (0.3 * $font_size)));
}
$cache_group = strtolower(get_class($this));
$cache_key = $font_file . $font_size . $font_color . $background_color . $output_format . $content . $width;
if (!Cache::has(array($cache_group, md5($cache_key)))) {
$font_color = new ImagickPixel($font_color);
$background_color = new ImagickPixel($background_color);
$draw = new ImagickDraw();
$draw->setFont($font_file);
$draw->setFontSize($font_size);
$draw->setFillColor($font_color);
$draw->setTextEncoding('UTF-8');
$draw->annotation(0, $font_size * 2, $content);
$canvas = new Imagick();
$canvas->newImage(1000, $font_size * 5, $background_color);
$canvas->setImageFormat($output_format);
$canvas->drawImage($draw);
// The following line ensures that the background color is set in the PNG
// metadata, when using that format. This allows you, by specifying an RGBa
// background color (e.g. #ffffff00) to create PNGs with a transparent background
// for browsers that support it but with a "fallback" background color (the RGB
// part of the RGBa color) for IE6, which does not support alpha in PNGs.
$canvas->setImageBackgroundColor($background_color);
$canvas->trimImage(0);
Cache::set(array($cache_group, md5($cache_key)), $canvas->getImageBlob());
}
return '<img class="rendered-type" src="' . URL::get('display_rendertype', array('hash' => md5($cache_key), 'format' => $output_format)) . '" title="' . $content . '" alt="' . $content . '">';
}
示例10: addWaterText
/**
*
* 文字水印
* @param unknown_type $data
*/
public function addWaterText($data)
{
$draw = new ImagickDraw();
$this->ImagickPixel = new ImagickPixel();
$draw->clear();
$draw->setfont($data['font']);
$draw->setfontsize($data['size']);
$this->ImagickPixel->setcolor($data['color']);
$draw->setfillcolor($data['color']);
$draw->setfillalpha($data['alpha']);
$draw->settextalignment(imagick::GRAVITY_NORTHWEST);
//左對齊
$draw->annotation($data['pos_x'], $data['pos_y'], $data['literal']);
$this->srcImg_source->drawimage($draw);
$draw->destroy();
return $this->srcImg_source;
}
示例11: drawImage
function drawImage()
{
$strokeColor = 'black';
$fillColor = 'plum1';
$draw = new \ImagickDraw();
$draw->setStrokeOpacity(1);
$draw->setStrokeColor($strokeColor);
$draw->setStrokeWidth(1.2);
$draw->setFont("../fonts/Arial.ttf");
$draw->setFontSize(64);
$draw->setFillColor($fillColor);
$draw->rotate(-12);
$draw->annotation(140, 380, "c'est ne pas \nune Lorikeet!");
$imagick = new \Imagick(realpath("../imagick/images/lories/IMG_1599_480.jpg"));
$imagick->setImageFormat("png");
$imagick->drawImage($draw);
header("Content-Type: image/png");
echo $imagick->getImageBlob();
}
示例12: build
public function build()
{
// Prepage image
$this->_canvas = new Imagick();
$this->_canvas->newImage(self::WIDTH, self::HEIGHT, new ImagickPixel("white"));
$color['line'] = new ImagickPixel("rgb(216, 76, 64)");
$color['text'] = new ImagickPixel("rgb(16, 35, 132)");
$color['karma'] = new ImagickPixel("rgb(116, 194, 98)");
$color['force'] = new ImagickPixel("rgb(37, 168, 255)");
$color['bottom_bg'] = new ImagickPixel("rgb(255, 244, 224)");
$color['bg'] = new ImagickPixel("white");
$color['neutral'] = new ImagickPixel("rgb(200, 200, 200)");
$color['habr'] = new ImagickPixel("rgb(83, 121, 139)");
// Prepare canvas for drawing main graph
$draw = new ImagickDraw();
$draw->setStrokeAntialias(true);
$draw->setStrokeWidth(2);
// Prepare values for drawing main graph
define('PADDING', 10);
// Draw bottom bg
define('TOP_SPACER', 10);
$draw = new ImagickDraw();
$draw->setFillColor($color['bg']);
$draw->setStrokeColor($color['habr']);
$draw->polyline(array(array('x' => 0, 'y' => 0), array('x' => self::WIDTH - 1, 'y' => 0), array('x' => self::WIDTH - 1, 'y' => self::HEIGHT - 1), array('x' => 0, 'y' => self::HEIGHT - 1), array('x' => 0, 'y' => 0)));
$this->_canvas->drawImage($draw);
$draw->destroy();
// Draw texts
$draw = new ImagickDraw();
$draw->setTextUnderColor($color['bg']);
$draw->setTextAntialias(true);
$draw->setFillColor($color['text']);
$draw->setFont(realpath('stuff/arialbd.ttf'));
$code = $this->_user;
$draw->setFontSize(strlen($code) > 8 ? 10 : 11);
if (strlen($code) > 10) {
$code = substr($code, 0, 9) . '...';
}
$draw->annotation(80, 13, $code);
$textInfo = $this->_canvas->queryFontMetrics($draw, $code, null);
$nextX = 80 + 9 + $textInfo['textWidth'];
$draw->setFont(realpath('stuff/consola.ttf'));
$draw->setFontSize(11);
$draw->setFillColor($color['neutral']);
$draw->annotation(5, 13, "хаброметр");
$draw->setTextUnderColor($color['karma']);
$draw->setFillColor($color['bg']);
$draw->setFontSize(12);
$draw->setFont(realpath('stuff/consolab.ttf'));
$draw->annotation($nextX, 13, $text = sprintf('%01.2f', $this->_karma));
$textInfo = $this->_canvas->queryFontMetrics($draw, $text, null);
$nextX += $textInfo['textWidth'] + 4;
$draw->setTextUnderColor($color['bg']);
$draw->setFont(realpath('stuff/arialbd.ttf'));
$text = sprintf('%01.2f', $this->_extremums['karma_min']) . '/' . sprintf('%01.2f', $this->_extremums['karma_max']);
$draw->setFontSize(8);
$draw->setFillColor($color['karma']);
$draw->annotation($nextX, 13, $text);
$textInfo = $this->_canvas->queryFontMetrics($draw, $text, null);
$nextX += $textInfo['textWidth'] + 9;
$draw->setFontSize(12);
$draw->setFont(realpath('stuff/consolab.ttf'));
$draw->setTextUnderColor($color['force']);
$draw->setFillColor($color['bg']);
$draw->annotation($nextX, 13, $text = sprintf('%01.2f', $this->_habraforce));
$textInfo = $this->_canvas->queryFontMetrics($draw, $text, null);
$nextX += $textInfo['textWidth'] + 4;
$draw->setTextUnderColor($color['bg']);
$draw->setFont(realpath('stuff/arialbd.ttf'));
$text = sprintf('%01.2f', $this->_extremums['habraforce_min']) . '/' . sprintf('%01.2f', $this->_extremums['habraforce_max']);
$draw->setFontSize(8);
$draw->setFillColor($color['force']);
$draw->annotation($nextX, 13, $text);
$image = new Imagick('stuff/bg-user2.gif');
$this->_canvas->compositeImage($image, Imagick::COMPOSITE_COPY, 64, 3, Imagick::CHANNEL_ALL);
$image->clear();
$image->destroy();
$this->_canvas->drawImage($draw);
$draw->destroy();
return true;
}
示例13: text
/**
* Set and apply the text on the image
*
* @param string $string
* @throws Exception
* @return Imagick
*/
public function text($string)
{
$draw = new \ImagickDraw();
// Set the font if passed
if (null !== $this->font) {
if (!$draw->setFont($this->font)) {
throw new Exception('Error: That font is not recognized by the Imagick extension.');
}
// Else, attempt to set a basic, default system font
} else {
$fonts = $this->image->resource()->queryFonts();
if (in_array('Arial', $fonts)) {
$this->font = 'Arial';
} else {
if (in_array('Helvetica', $fonts)) {
$this->font = 'Helvetica';
} else {
if (in_array('Tahoma', $fonts)) {
$this->font = 'Tahoma';
} else {
if (in_array('Verdana', $fonts)) {
$this->font = 'Verdana';
} else {
if (in_array('System', $fonts)) {
$this->font = 'System';
} else {
if (in_array('Fixed', $fonts)) {
$this->font = 'Fixed';
} else {
if (in_array('system', $fonts)) {
$this->font = 'system';
} else {
if (in_array('fixed', $fonts)) {
$this->font = 'fixed';
} else {
if (isset($fonts[0])) {
$this->font = $fonts[0];
} else {
throw new Exception('Error: No default font could be found by the Imagick extension.');
}
}
}
}
}
}
}
}
}
}
$draw->setFont($this->font);
$draw->setFontSize($this->size);
$draw->setFillColor($this->image->getColor($this->fillColor, $this->opacity));
if (null !== $this->rotation) {
$draw->rotate($this->rotation);
}
if (null !== $this->strokeColor) {
$draw->setStrokeColor($this->image->getColor($this->strokeColor, $this->opacity));
$draw->setStrokeWidth((int) $this->strokeWidth);
}
$draw->annotation($this->x, $this->y, $string);
$this->image->resource()->drawImage($draw);
return $this;
}
示例14: define
$filename = "temp/{$caveID}.png";
if (!file_exists($filename)) {
define("NAME_LENGTH", 21);
$config = new Config();
$db = DbConnect();
$cave = getCaveByID($caveID);
if ($cave === 0) {
exit(1);
}
$name = unhtmlentities($cave['name']);
if (strlen($cave['name']) > NAME_LENGTH) {
$cave['name'] = substr($cave['name'], 0, NAME_LENGTH - 2) . "..";
}
/* Create imagickdraw object */
$draw = new ImagickDraw();
/* Annotate some text */
$draw->setFontSize(13);
$draw->annotation(5, 20, "{$cave['name']}");
$draw->setFontSize(10);
$draw->annotation(5, 33, "({$cave['xCoord']}|{$cave['yCoord']})");
/* Create a new imagick object */
$im = new Imagick();
/* Create new image. This will be used as fill pattern */
$im->newImage(120, 40, new ImagickPixel('none'));
$im->setImageFormat('png');
/* Draw the ImagickDraw on to the canvas */
$im->drawImage($draw);
$im->rotateImage(new ImagickPixel('none'), -90);
$im->writeImage($filename);
}
header("Location: {$filename}");
示例15:
function __construct($chemin)
{
if (filter_var($chemin, FILTER_VALIDATE_URL)) {
//URL
$headers = @get_headers($chemin);
if (strpos($headers[0], '404') != false) {
//NOT FOUND
//throw new \Exception("Not Found Image");
$this->image = new \Imagick();
$this->image->newImage(600, 600, new \ImagickPixel('white'));
/* Création d'un nouvel objet imagick */
$im = new \Imagick();
/* Création d'une nouvelle image. Elle sera utilisée comme masque de remplissage */
$im->newPseudoImage(50, 100, "gradient:gray-black");
/* Création d'un nouvel objet imagickdraw */
$draw = new \ImagickDraw();
/* On commence un nouveau masque nommé "gradient" */
$draw->pushPattern('gradient', 0, 0, 50, 110);
/* Ajout du dégradé sur le masque */
$draw->composite(\Imagick::COMPOSITE_OVER, 0, 0, 50, 110, $im);
/* Fermeture du masque */
$draw->popPattern();
/* Utilisation du masque nommé "gradient" comme remplissage */
$draw->setFillPatternURL('#gradient');
/* Définition de la taille du texte à 52 */
$draw->setFontSize(92);
$draw->setFont(ROOT . DS . 'font/comic.ttf');
/* Ajout d'un texte */
$draw->annotation(20, 100, "Not Found !");
$this->image->drawImage($draw);
}
} else {
if (!file_exists($chemin)) {
//throw new \Exception("Not Found Image");
$this->image = new \Imagick();
$this->image->newImage(600, 600, new \ImagickPixel('white'));
/* Création d'un nouvel objet imagick */
$im = new \Imagick();
/* Création d'une nouvelle image. Elle sera utilisée comme masque de remplissage */
$im->newPseudoImage(50, 100, "gradient:gray-black");
/* Création d'un nouvel objet imagickdraw */
$draw = new \ImagickDraw();
/* On commence un nouveau masque nommé "gradient" */
$draw->pushPattern('gradient', 0, 0, 50, 110);
/* Ajout du dégradé sur le masque */
$draw->composite(\Imagick::COMPOSITE_OVER, 0, 0, 50, 110, $im);
/* Fermeture du masque */
$draw->popPattern();
/* Utilisation du masque nommé "gradient" comme remplissage */
$draw->setFillPatternURL('#gradient');
/* Définition de la taille du texte à 52 */
$draw->setFontSize(92);
$draw->setFont(ROOT . DS . 'font/comic.ttf');
/* Ajout d'un texte */
$draw->annotation(20, 100, "Not Found !");
$this->image->drawImage($draw);
}
}
$this->image = new \Imagick($chemin);
$imageprops = $this->image->getImageGeometry();
$this->width = $imageprops['width'];
$this->height = $imageprops['height'];
$this->image->setImageFormat("jpeg");
}