imagick

PHP Imagick how to best fit text annotation

你。 提交于 2019-12-04 09:21:07
I'm adding annotation text to a newPseudoImage which works fine but I'd like to make the text scale to fit the image size. Any ideas how I might do this? $im = new Imagick(); $draw = new ImagickDraw(); $draw->setFillColor($color); $draw->setFont($font); $draw->setFontSize(($width, $height) / 100) * 15); $draw->setGravity(Imagick::GRAVITY_CENTER); $im->newPseudoImage($width, $height, "canvas:{$bg}"); $im->annotateImage($draw, 0, 0, 0, $text); $draw->clear(); $draw->destroy(); $im->setImageFormat('gif'); header("Content-Type: image/gif"); echo $im; I think you could use the imageftbbox function

thinkphp 图形处理

主宰稳场 提交于 2019-12-04 08:49:38
使用Think\Image类进行图像处理功能,支持Gd库和Imagick库,包括对GIf图像处理的支持。 实例化类库 $image = new \Think\Image (); 默认使用GD库进行图像操作,如果需要使用Imagick库操作的话,需要改成: $image = new \Think\Image ( \Think\Image :: IMAGE_IMAGICK ); // 或者采用 $image = new \Think\Image ( 'Imagick' ); 图像操作 下面来看下基础的图像操作功能的使用方法。 打开图像文件 假设当前入口文件目录下面有一个1.jpg文件,如图所示: 使用open方法打开图像文件进行相关操作: $image = new \Think\Image (); $image -> open ( './1.jpg' ); 也可以简化成下面的方式: $image = new \Think\Image ( \Think\Image :: IMAGE_GD , './1.jpg' ); // GD库 // 或者 $image = new \Think\Image ( \Think\Image :: IMAGE_IMAGICK , './1.jpg' ); // imagick库 获取图像信息 可以获取打开图片的信息,包括图像大小、类型等,例如:

Detect if image is grayscale or color using Imagick

天涯浪子 提交于 2019-12-04 07:31:36
I'm attempting to try and assign a value to an image based on its 'saturation level', to see if the image is black and white or color. I'm using Imagick, and have found what seems to be the perfect code for the command line and am trying to replicate it using the PHP library. I think I understand the concept: Convert image to HSL. Extract the 'g' channel (which is the S channel in HSL). Calculate the mean of this channel. Command line code convert '$image_path' -colorspace HSL -channel g -separate +channel -format '%[fx:mean]' info: My PHP code $imagick = new Imagick($image_path); $imagick-

ImageMagick No decode delegate for this image format

孤人 提交于 2019-12-04 05:41:14
I work under windows and wamp server. this is my PHP code with Imagick $imagick = new Imagick($_SERVER['DOCUMENT_ROOT'] . '/' . $this->_name); where $_SERVER['DOCUMENT_ROOT'].'/'.$this->_name displays : D:/Sources/my_project/public/media/2/9/1/05201502/55450e1b6543a05201502_9.PNG I checked that image and it does exist in the folder. But Imagick throws an exception : Uncaught exception 'ImagickException' with message 'no decode delegate for this image format `D:/Sources/my_project/public/media/2/9/1/05201502/55450b10d8ea705201502_9.PNG' @ error/constitute.c/ReadImage/555' in D:\Sources\my

linux安装php扩展imagick后用php -m命令没有在列表里显示

跟風遠走 提交于 2019-12-03 22:47:58
1.修改php.ini文件,加上extension=imagick.so; 2.重启php:service php-fpm restart; 3.重启时有的会出现报错:PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/imagick.so' - /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/imagick.so: cannot open shared object file: No such file or directory in Unknown on line 0 done,此时可以用find -name imagick.so来查找imagick.so的安装位置,找到此文件,并移到/usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/目录下,再次重启php,用php -m查看已安装模块,此时就能看到imagick出现在已安装列表里了。 来源: https://www.cnblogs.com/xiesx/p/11810140.html

PHP ImagickDraw with outlined text issues

天大地大妈咪最大 提交于 2019-12-03 20:32:53
I'm learning and practicing my Imagick skills. I have issues with outlined text using Imagick stroke. I would like to achieve an effect visible on this image: a popular Internet meme: Here's the code I have so far: $draw = new \ImagickDraw(); $outputImage = new \Imagick('meme.jpg'); $draw->setFillColor('#fff'); $draw->setFont('impact.ttf'); $draw->setFontSize(40); $draw->setGravity(\Imagick::GRAVITY_NORTH); $draw->setStrokeColor('#000'); $draw->setStrokeWidth(1); $draw->setStrokeAntialias(true); $draw->setTextAntialias(true); $outputImage->annotateImage($draw, 0, 5, 0, 'Sample text');

How to read SVG string in Imagick?

匿名 (未验证) 提交于 2019-12-03 09:58:14
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a string containing markup for an svg element. <svg id="someId" width="300" height="300"> <polygon id="another_id" fill="green" stroke="black" stroke-width="5" points="200,100 131,5 19,41 19,159 131,195 "></polygon> </svg> How can I read this string in Imagick and display it. $svg = '<svg id="someId" width="300" height="300"><polygon id="another_id" fill="green" stroke="black" stroke-width="5" points="200,100 131,5 19,41 19,159 131,195 "></polygon> </svg>'; $image = new Imagick(); // This is not working. $image->readImageBlob($svg);

Saving Each PDF Page to an Image Using Imagick

青春壹個敷衍的年華 提交于 2019-12-03 09:13:00
问题 I have the following php function below that's converting a local PDF file into images. In short, I want each PDF page to be converted to a separate image. The function converts the PDF to an image - but only the last page. I want every page of the PDF to be converted to a image and numbered. Not just the last page of the PDF. Currently, this function converts the last page of example.pdf to example-0.jpg . Issue I'm sure lies within the for method. What am I missing? $file_name = 'example

Imagick on Windows 8 xampp

匿名 (未验证) 提交于 2019-12-03 08:56:10
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to install imagick on windows 8 64bit, xampp. I have tried all methods in internet how to solve this problem, but none helped me ( have tried more than 10 methods ). In all results i get error while launching apache. Apache 2.2.21 PHP 5.3.8 Windows 8 64 Latest method i have tried: http://w3facility.info/question/how-to-install-imagemagick-for-php5-35-4-on-windows-8-x64/ In case i change to extension=php_imagick_nts.dll error looks like: The program can't start because php5.dll is missing... In case i change to The program can't start

Imagick: unable to open file

匿名 (未验证) 提交于 2019-12-03 08:54:24
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: When simply calling the Imagick class: $image = new Imagick('/images/magick/atmsk.png'); I get the error message: Fatal error: Uncaught exception 'ImagickException' with message 'unable to open file `/images/magick/atmsk.png' @ png.c/ReadPNGImage/2889' in .../imag.php:4 Stack trace: #0 .../imag.php(4): Imagick->__construct('/images/magick/...') #1 {main} thrown in .../imag.php I have checked memory available as per another posting here and that is ok! 回答1: Use the full path to the image, for example: $image = new Imagick($_SERVER['DOCUMENT