本文整理汇总了PHP中ImagickDraw::setGravity方法的典型用法代码示例。如果您正苦于以下问题:PHP ImagickDraw::setGravity方法的具体用法?PHP ImagickDraw::setGravity怎么用?PHP ImagickDraw::setGravity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImagickDraw
的用法示例。
在下文中一共展示了ImagickDraw::setGravity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createEmailPic
function createEmailPic($jid, $email)
{
$cachefile = DOCUMENT_ROOT . '/cache/' . $jid . '_email.png';
if (file_exists(DOCUMENT_ROOT . '/cache/' . $jid . '_email.png')) {
unlink(DOCUMENT_ROOT . '/cache/' . $jid . '_email.png');
}
$draw = new ImagickDraw();
$draw->setFontSize(13);
$draw->setGravity(Imagick::GRAVITY_CENTER);
$canvas = new Imagick();
$metrics = $canvas->queryFontMetrics($draw, $email);
$canvas->newImage($metrics['textWidth'], $metrics['textHeight'], "transparent", "png");
$canvas->annotateImage($draw, 0, 0, 0, $email);
$canvas->setImageFormat('PNG');
$canvas->writeImage($cachefile);
}
示例2: a0nCRQ
function a0nCRQ($msg, $padx, $pady, $bc, $fc, $tc)
{
$im = new Imagick();
$idraw = new ImagickDraw();
$idraw->setFontSize(30);
$idraw->setFont('MyriadPro-Regular.otf');
$idraw->setGravity(Imagick::GRAVITY_CENTER);
$metrics = $im->queryFontMetrics($idraw, $msg);
$im->newPseudoImage($metrics["textWidth"] + $padx * 2, $metrics["textHeight"] + $pady * 2, "xc:none");
$idraw->setFillColor($fc);
$idraw->setStrokeColor($bc);
$idraw->roundrectangle(0, 0, $metrics["textWidth"] + $padx * 2 - 1, $metrics["textHeight"] + $pady * 2 - 1, 10, 10);
$idraw->setFillColor($tc);
$idraw->setStrokeColor($tc);
$idraw->annotation(0, 0, $msg);
$im->drawImage($idraw);
return $im;
}
示例3: fl_text_render
function fl_text_render($_file, $id, $text, $fontname, $fontsize, $color = "#000000", $out_image_file_type = "png")
{
$font = locate_font($fontname);
if ($font === false) {
fllog('fl_text_render: font `' . $fontname . '` not found at `' . flvault . $fontname . '`');
return false;
}
$render = false;
$out_image_file_type = strtolower($out_image_file_type);
$cachefile = flcache . $id . '.' . $out_image_file_type;
if ($_file !== false) {
if (file1_is_older($cachefile, $_file)) {
$render = true;
}
} else {
$render = true;
}
if ($render === true) {
try {
$draw = new ImagickDraw();
$draw->setFont($font);
$draw->setFontSize(intval($fontsize));
$draw->setGravity(Imagick::GRAVITY_CENTER);
$draw->setFillColor($color);
$canvas = new Imagick();
$m = $canvas->queryFontMetrics($draw, htmlspecialchars_decode($text));
$canvas->newImage($m['textWidth'], $m['textHeight'], "transparent", $out_image_file_type);
$canvas->annotateImage($draw, 0, 0, 0, $text);
$canvas->setImageFormat(strtoupper($out_image_file_type));
$canvas->writeImage($cachefile);
fllog('Writing to: ' . $cachefile);
$canvas->clear();
$canvas->destroy();
$draw->clear();
$draw->destroy();
} catch (Exception $e) {
fllog('fl_text_render() Error: ', $e->getMessage());
return false;
}
}
return $cachefile;
}
示例4: drawText
function drawText(\Imagick $imagick, $shadow = false)
{
$draw = new \ImagickDraw();
if ($shadow == true) {
$draw->setStrokeColor('black');
$draw->setStrokeWidth(8);
$draw->setFillColor('black');
} else {
$draw->setStrokeColor('none');
$draw->setStrokeWidth(1);
$draw->setFillColor('lightblue');
}
$draw->setFontSize(96);
$text = "Imagick\nExample";
$draw->setFont("../fonts/CANDY.TTF");
$draw->setGravity(\Imagick::GRAVITY_SOUTHWEST);
$imagick->annotateimage($draw, 40, 40, 0, $text);
if ($shadow == true) {
$imagick->blurImage(10, 5);
}
return $imagick;
}
示例5: text
/**
* Draws a text string on the image in a specified location, with
* the specified style information.
*
* @TODO: Need to differentiate between the stroke (border) and the fill color,
* but this is a BC break, since we were just not providing a border.
*
* @param string $text The text to draw.
* @param integer $x The left x coordinate of the start of the text string.
* @param integer $y The top y coordinate of the start of the text string.
* @param string $font The font identifier you want to use for the text.
* @param string $color The color that you want the text displayed in.
* @param integer $direction An integer that specifies the orientation of the text.
* @param string $fontsize Size of the font (small, medium, large, giant)
*/
public function text($string, $x, $y, $font = '', $color = 'black', $direction = 0, $fontsize = 'small')
{
$fontsize = Horde_Image::getFontSize($fontsize);
$pixel = new ImagickPixel($color);
$draw = new ImagickDraw();
$draw->setFillColor($pixel);
if (!empty($font)) {
$draw->setFont($font);
}
$draw->setFontSize($fontsize);
$draw->setGravity(Imagick::GRAVITY_NORTHWEST);
try {
$res = $this->_imagick->annotateImage($draw, $x, $y, $direction, $string);
} catch (ImagickException $e) {
throw new Horde_Image_Exception($e);
}
$draw->destroy();
}
示例6: scale_image
}
$img_path = "images" . DIRECTORY_SEPARATOR;
$img_fullname = $img_path . $img_name;
$image = new Imagick($img_fullname);
scale_image($img_p, $height, $width, $image);
if (array_key_exists('text', $_GET)) {
$text = $_GET['text'];
$text = preg_replace('/\\|/i', "\n", $text);
$pointsize = max(min($width / strlen($text) * 1.2, $height * 0.2), 5);
$font = "mplus-1c-medium.ttf";
$draw = new ImagickDraw();
$draw->setFillColor(new ImagickPixel("#" . $foreground->get_hex()));
$draw->setFont($font);
$draw->setFontSize($pointsize);
$draw->setTextUnderColor(new ImagickPixel("#" . $background->get_hex()));
$draw->setGravity(imagick::GRAVITY_SOUTH);
$image->annotateImage($draw, 0, 0, 0, $text);
}
$image->setFilename("puppy");
$output = $image->getimageblob();
$outputtype = $image->getFormat();
header("Content-type: {$outputtype}");
echo $output;
function scale_image($img_p, $height, $width, $image)
{
if ($img_p > 1) {
$tmp_w = $height * $img_p;
$tmp_h = $height;
} else {
$tmp_w = $width;
$tmp_h = $width / $img_p;
示例7: waterMark
/**
* 加给图片加水印
*
* @param strimg $groundImage 要加水印地址
* @param int $waterPos 水印位置
* @param string $waterImage 水印图片地址
* @param string $waterText 文本文字
* @param int $textFont 文字大小
* @param string $textColor 文字颜色
* @param int $minWidth 小于此值不加水印
* @param int $minHeight 小于此值不加水印
* @param float $alpha 透明度
* @return FALSE
*/
public static function waterMark($groundImage, $waterPos = 0, $waterImage = "", $waterText = "", $textFont = 15, $textColor = "#FF0000", $minWidth = '100', $minHeight = '100', $alpha = 0.9)
{
$isWaterImg = FALSE;
$bg_h = $bg_w = $water_h = $water_w = 0;
//获取背景图的高,宽
if (is_file($groundImage) && !empty($groundImage)) {
$bg = new Imagick();
$bg->readImage($groundImage);
$bg_h = $bg->getImageHeight();
$bg_w = $bg->getImageWidth();
}
//获取水印图的高,宽
if (is_file($waterImage) && !empty($waterImage)) {
$water = new Imagick($waterImage);
$water_h = $water->getImageHeight();
$water_w = $water->getImageWidth();
}
//如果背景图的高宽小于水印图的高宽或指定的高和宽则不加水印
if ($bg_h < $minHeight || $bg_w < $minWidth || $bg_h < $water_h || $bg_w < $water_w) {
return;
} else {
$isWaterImg = TRUE;
}
//加水印
if ($isWaterImg) {
$dw = new ImagickDraw();
//加图片水印
if (is_file($waterImage)) {
$water->setImageOpacity($alpha);
$dw->setGravity($waterPos);
$dw->composite($water->getImageCompose(), 0, 0, 50, 0, $water);
$bg->drawImage($dw);
if (!$bg->writeImage($groundImage)) {
return FALSE;
}
} else {
//加文字水印
$dw->setFontSize($textFont);
$dw->setFillColor($textColor);
$dw->setGravity($waterPos);
$dw->setFillAlpha($alpha);
$dw->annotation(0, 0, $waterText);
$bg->drawImage($dw);
if (!$bg->writeImage($groundImage)) {
return FALSE;
}
}
}
}
示例8: mkLegendUrl
$runningHt = 15;
for ($i = count($legends) - 1; $i >= 0; $i--) {
$p = explode("\n", $titles[$i]);
$draw = new ImagickDraw();
$draw->setFont('Helvetica');
$draw->setFontSize(12);
$draw->annotation(5, $runningHt, $titles[$i]);
$canvas->drawImage($draw);
$canvas->compositeImage($legends[$i], imagick::COMPOSITE_OVER, 0, $runningHt + 12 * (count($p) - 1));
$runningHt += $legends[$i]->getImageHeight() + 20 + 12 * (count($p) - 1);
}
$canvas->writeImage($tmp_dir . $id . '.legend.png');
// title
$canvas = new Imagick();
$canvas->newImage($w, 30, new ImagickPixel('white'));
$canvas->setImageFormat('png');
$draw = new ImagickDraw();
$draw->setFont('Helvetica');
$draw->setFontSize(18);
$draw->setGravity(imagick::GRAVITY_CENTER);
$draw->annotation(0, 0, $_REQUEST['title']);
$canvas->drawImage($draw);
$canvas->writeImage($tmp_dir . $id . '.title.png');
function mkLegendUrl($u)
{
return preg_replace('/&(STYLES|SRS)[^&]+/', '', $u);
}
$handle = fopen($tmp_dir . $id . '.html', 'w');
fwrite($handle, "<html><head><title>" . $_REQUEST['title'] . "</title><style>td {vertical-align : top} img {border : 1px solid gray}</style></head><body><table><tr><td><img src='{$tmp_url}{$id}.title.png'></td></tr><tr><td><img src='{$tmp_url}{$id}.png'></td><td><img src='{$tmp_url}{$id}.legend.png'></td></tr></table></body></html>");
fclose($handle);
echo json_encode(array('html' => "{$tmp_url}{$id}.html", 'map' => "{$tmp_url}{$id}.png", 'legend' => "{$tmp_url}{$id}.legend.png"));
示例9: fl_regenerate_sprite_cache
function fl_regenerate_sprite_cache($sheet_id, $sprites, $out_image_file_type = "png")
{
if (defined('fl_test_environment')) {
fllog('! fl_regenerate_sprite_cache: ' . flcache . $sheet_id . '.' . $out_image_file_type);
}
$biggest_w = 0;
$biggest_h = 0;
$rects = array();
$i = 0;
foreach ($sprites as &$sprite) {
$i++;
//var_dump( $sprite );
if (!isset($sprite['size'])) {
$sprite['size'] = 14;
}
if (!isset($sprite['color'])) {
$sprite['color'] = '#000000';
}
if (!isset($sprite['font'])) {
fllog('Font not set for sprite id `' . $sheet_id . '` sprite #' . $i);
continue;
}
//var_dump($sprite);
$sprite['dimension'] = fl_query_font_render_size(flres(flvault . $sprite['font']), intval($sprite['size']), $sprite['color'], $sprite['text']);
$sprite['w'] = $sprite['dimension']['w'];
$sprite['h'] = $sprite['dimension']['h'];
$w = intval($sprite['w']);
$h = intval($sprite['h']);
if ($w > $biggest_w) {
$biggest_w = $w;
}
if ($h > $biggest_h) {
$biggest_h = $h;
}
$rects[$i - 1] = $sprite;
}
// echo 'Packing rects..';
$packed = PackRect($rects, fl_biggest_w, fl_biggest_h, $w, $h, fl_pack_precision, fl_pack_precision);
$i = 0;
try {
$total = count($rects);
$c = new Imagick();
//var_dump($packed);
$c->newImage(intval($packed['width']), intval($packed['height']), "transparent", $out_image_file_type);
$css = '';
$d = array();
foreach ($packed as $k => $sprite) {
if (!is_numeric($k)) {
continue;
} else {
$d = new ImagickDraw();
$d->setFont(fl_get_fontfile($sprite['font']));
$d->setFontSize(floatval($sprite['size']));
$d->setGravity(Imagick::GRAVITY_NORTHWEST);
$d->setFillColor($sprite['color']);
$result = $c->annotateImage($d, floatval($sprite['x']), floatval($sprite['y']), 0, $sprite['text']);
$d->clear();
$d->destroy();
}
}
$c->setImageFormat(strtoupper($out_image_file_type));
$c->writeImage(flres(flcache . $sheet_id . '.' . $out_image_file_type));
$c->clear();
$c->destroy();
} catch (Exception $e) {
echo $e->getMessage();
}
fl_make_sheet($sheet_id, $packed, $out_image_file_type);
//die;
}
示例10: Imagick
<?php
// Create objects
$image = new Imagick('../files/images/userbar_old.png');
// Watermark text
// Create a new drawing palette
$draw = new ImagickDraw();
// Set font properties
$draw->setFont('../files/fonts/visitor.ttf');
$draw->setFontSize(10);
$draw->setFillColor('white');
$text = "";
if (isset($_GET['user'])) {
$text = $_GET['user'];
}
// Position text at the bottom-right of the image
$draw->setGravity(Imagick::GRAVITY_EAST);
$image->annotateImage($draw, 8, 0, 0, $text);
// Set output image format
$image->setImageFormat('png');
// Output the new image
header('Content-type: image/png');
echo $image;
示例11: diyAction
public function diyAction()
{
Yaf_Dispatcher::getInstance()->autoRender(FALSE);
$id = $this->_req->getQuery('id', 1);
if ($this->_req->isPost()) {
$this->diy = new DiyModel();
$pre_svg = '<?xml version="1.0" standalone="no" ?>' . trim($_POST['svg_val']);
$rdate = APPLICATION_PATH . '/public/Uploads/' . date("Ymd", time());
//文件名
if (!file_exists($rdate)) {
chmod(APPLICATION_PATH . '/public/Uploads/', 0777);
mkdir($rdate);
//创建目录
}
$savename = $this->create_unique();
$path = $rdate . '/' . $savename;
if (!($file_svg = fopen($path . '.svg', 'w+'))) {
echo "不能打开文件 {$path}.'.svg'";
exit;
}
if (fwrite($file_svg, $pre_svg) === FALSE) {
echo "不能写入到文件 {$path}.'.svg'";
exit;
}
echo "已成功写入";
fclose($file_svg);
//$path= APPLICATION_PATH . '/public/Uploads/' . date("Ymd", time()) .'/m-1';
//添加图片转化
$im = new Imagick();
$im->setBackgroundColor(new ImagickPixel('transparent'));
$svg = file_get_contents($path . '.svg');
$im->readImageBlob($svg);
$im->setImageFormat("png");
$am = $im->writeImage($path . '.png');
$im->thumbnailImage(579, 660, true);
/* 改变大小 */
$ams = $im->writeImage($path . '-t.png');
$im->clear();
$im->destroy();
//图片加水印
$waterpath = APPLICATION_PATH . '/public/source/source.png';
$im1 = new Imagick($waterpath);
$im2 = new Imagick($path . '.png');
$im2->thumbnailImage(600, 600, true);
$dw = new ImagickDraw();
$dw->setGravity(5);
$dw->setFillOpacity(0.1);
$dw->composite($im2->getImageCompose(), 0, 0, 50, 0, $im2);
$im1->drawImage($dw);
if (!$im1->writeImage($path . '-s.png')) {
echo '加水印失败';
exit;
}
$im1->clear();
$im2->clear();
$im1->destroy();
$im2->destroy();
//exit;
//删除相应的文件
//unlink($path.'.svg');
//unlink($path.'.png');
$filepath = '/Uploads/' . date("Ymd", time()) . '/' . $savename . '.png';
$data['origin_img'] = $filepath;
$data['diy_synthetic_img'] = '/Uploads/' . date("Ymd", time()) . '/' . $savename . '-s.png';
$data['diy_preview_img'] = '/Uploads/' . date("Ymd", time()) . '/' . $savename . '-s.png';
$data['user_id'] = 0;
$data['source'] = 3;
$data['created'] = date("Y-m-d H:i:s", time());
$datas['image'] = $data['diy_synthetic_img'];
$datas['user_id'] = 0;
$datas['source'] = 2;
$datas['state'] = 1;
$datas['createtime'] = date("Y-m-d H:i:s", time());
$datas['updatetime'] = date("Y-m-d H:i:s", time());
$diy_picture_id = $this->diy->adddiy($data);
//$datas['use'] = $tool;
//$datas['author'] = $userinfo['mobile'];
$this->userpicture = new UserpictureModel();
$datas['diy_picture_id'] = $diy_picture_id;
$this->userpicture->adduserpicture($datas);
$response_data['origin_img'] = '/Uploads/' . date("Ymd", time()) . '/' . $savename . '.png';
$response_data['diy_preview_img'] = '/Uploads/' . date("Ymd", time()) . '/' . $savename . '-s.png';
$response_data['diy_thumb_img'] = '/Uploads/' . date("Ymd", time()) . '/' . $savename . '-t.png';
$response_data['diy_picture_id'] = $diy_picture_id;
//$this->getView()->display("/index/buy.html",$response_data);
$this->_session->set('diypicture', $response_data);
$this->_redis = new phpredis();
$this->_redis->set($diy_picture_id, json_encode($response_data));
header("Location:/index/share?diy=" . $diy_picture_id);
} else {
switch ($id) {
case 1:
$this->getView()->display("index/diy_1.html");
break;
case 2:
$this->getView()->display("index/diy_2.html");
break;
case 3:
$this->getView()->display("index/diy_3.html");
break;
//.........这里部分代码省略.........
示例12: tp_imagick_watermark
/**
* imagick watermarking
*
* @param string $filename
* @return bool
*/
function tp_imagick_watermark($filename)
{
$watermark_text = elgg_get_plugin_setting('watermark_text', 'tidypics');
if (!$watermark_text) {
return false;
}
// plugins can do their own watermark and return false to prevent this function from running
if (elgg_trigger_plugin_hook('tp_watermark', 'imagick', $filename, true) === false) {
return true;
}
$owner = elgg_get_logged_in_user_entity();
$watermark_text = tp_process_watermark_text($watermark_text, $owner);
$img = new Imagick($filename);
$img->readImage($image);
$draw = new ImagickDraw();
//$draw->setFont("");
$draw->setFontSize(28);
$draw->setFillOpacity(0.5);
$draw->setGravity(Imagick::GRAVITY_SOUTH);
$img->annotateImage($draw, 0, 0, 0, $watermark_text);
if ($img->writeImage($filename) != true) {
$img->destroy();
return false;
}
$img->destroy();
return true;
}
示例13: watermarkText
/**
* {@inheritDoc}
*/
public function watermarkText($wm_txt_text, $wm_txt_font_path, $wm_txt_start_x = 0, $wm_txt_start_y = 0, $wm_txt_font_size = 10, $wm_txt_font_color = 'transwhitetext', $wm_txt_font_alpha = 60)
{
if (false === $this->isClassSetup()) {
return false;
}
// setup source image object
if (false === $this->setupSourceImageObject()) {
return false;
}
// check previous step contain errors?
if ($this->isPreviousError() === true) {
return false;
}
if (!is_file($wm_txt_font_path)) {
$this->status = false;
$this->status_msg = 'Unable to load font file.';
return false;
}
$wm_txt_font_path = realpath($wm_txt_font_path);
// find text width and height
// +10 will be -5 padding on watermark text area.
$ImagickDraw = new \ImagickDraw();
$ImagickDraw->setFont($wm_txt_font_path);
$ImagickDraw->setFontSize($wm_txt_font_size);
$ImagickDraw->setGravity(\Imagick::GRAVITY_NORTHWEST);
// set new resolution for font due to it is smaller than GD if it was not set.
$ImagickDraw->setresolution(96, 96);
$type_space = $this->Imagick->queryFontMetrics($ImagickDraw, $wm_txt_text, false);
if (is_array($type_space) && array_key_exists('textWidth', $type_space) && array_key_exists('textHeight', $type_space)) {
$wm_txt_height = $type_space['textHeight'];
$wm_txt_width = $type_space['textWidth'];
}
unset($type_space);
// if start x or y is number, convert to integer value
if (is_numeric($wm_txt_start_x)) {
$wm_txt_start_x = intval($wm_txt_start_x);
}
if (is_numeric($wm_txt_start_y)) {
$wm_txt_start_y = intval($wm_txt_start_y);
}
// 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';
//.........这里部分代码省略.........
示例14: setGravity
function setGravity($fillColor, $strokeColor, $backgroundColor)
{
$draw = new \ImagickDraw();
$draw->setStrokeColor($strokeColor);
$draw->setFillColor($fillColor);
$draw->setStrokeWidth(1);
$draw->setFontSize(24);
$gravitySettings = array(\Imagick::GRAVITY_NORTHWEST => 'NorthWest', \Imagick::GRAVITY_NORTH => 'North', \Imagick::GRAVITY_NORTHEAST => 'NorthEast', \Imagick::GRAVITY_WEST => 'West', \Imagick::GRAVITY_CENTER => 'Centre', \Imagick::GRAVITY_SOUTHWEST => 'SouthWest', \Imagick::GRAVITY_SOUTH => 'South', \Imagick::GRAVITY_SOUTHEAST => 'SouthEast', \Imagick::GRAVITY_EAST => 'East');
$draw->setFont("../fonts/Arial.ttf");
foreach ($gravitySettings as $type => $description) {
$draw->setGravity($type);
$draw->annotation(50, 50, '"' . $description . '"');
}
$imagick = new \Imagick();
$imagick->newImage(500, 500, $backgroundColor);
$imagick->setImageFormat("png");
$imagick->drawImage($draw);
header("Content-Type: image/png");
echo $imagick->getImageBlob();
}
示例15: fl_query_font_render_size
function fl_query_font_render_size($font, $size, $color, $text)
{
// echo 'Querying for '.$text;
$d = new ImagickDraw();
$d->setFont($font);
$d->setFontSize(intval($size));
$d->setGravity(Imagick::GRAVITY_CENTER);
$d->setFillColor($color);
$c = new Imagick();
$m = $c->queryFontMetrics($d, $text);
$c->clear();
$c->destroy();
$d->clear();
$d->destroy();
$dim = array('w' => $m['textWidth'], 'h' => $m['textHeight']);
return $dim;
}