imagick

How to convert .PDF file to .PNG using Imagemagick PHP api

自闭症网瘾萝莉.ら 提交于 2020-06-25 04:18:48
问题 i want to convert .pdf file to .png file using Imagemagick php API. we can do this from shell using this: $convert sample.pdf sample_image.png we can issue this command using php exec() function but due to some reason(security) i disabled the execution of shell commands using php. so now tell me the solution that how can i convert my .pdf file to .png file without using the php exec() function? there is another discussion about this here but it's not very clear. -Thanks in advance Peeyush

Converting .HEIC to JPEG using imagick in C#

放肆的年华 提交于 2020-06-17 00:07:39
问题 I'm having trouble in converting heic file to jpeg I have already tried searching it online, i can find how to write to a folder but not how to get a byte[] of a converted file so that i can save it byte[] file = null; file = Convert.FromBase64String(dto.File); //Convert HEIC/HEIF to JPF if (extension == "HEIC" || extension == "HEIF") { try { using (MagickImageCollection images = new MagickImageCollection()) { images.Read(file); using (IMagickImage vertical = images.AppendVertically()) { var

ext-imagick * -> the requested PHP extension imagick is missing from your system

邮差的信 提交于 2020-06-14 04:10:30
问题 I have trouble installing devisephp for laravel. I am working on the latest version of homestead with php7. when i do composer update i get the following error. Problem 1 - Installation request for devisephp/cms 1.4.* -> satisfiable by devisephp/cms[1.4.0]. - devisephp/cms 1.4.0 requires ext-imagick * -> the requested PHP extension imagick is missing from your system. After having this message i installed imagick on my homestead environment added the extension to php.ini in cli and fpm and

Renaming a data:image/webp;base64, file in php (Imagick)

会有一股神秘感。 提交于 2020-05-17 08:47:18
问题 Is there any way to rename the data:image/webp;base64,base64_encode($thumbnail) to $IndPackProductImagesArray[0] so that when someone right clicks to open in a new tab, there's a name instead of encoded text Below is the code: <?php $image = new Imagick(); $image->readImage("images/industrial_packaging/".$IndPackProductImageDirName2."/".$IndPackProductImagesArray[0]); $watermark = new Imagick(); $watermark->readImage("images/default_products_image_fg.webp"); $image->compositeImage($watermark,

Install imagick on mac

我与影子孤独终老i 提交于 2020-05-14 18:21:12
问题 I need to install imagick extension for php. I have already installed Image Magick. Then I did "sudo pecl install imagick". After this I had such output in console: Installing '/usr/include/php/ext/imagick/php_imagick.h' Installing '/usr/include/php/ext/imagick/php_imagick_defs.h' Installing '/usr/include/php/ext/imagick/php_imagick_shared.h' Installing '/usr/lib/php/extensions/no-debug-non-zts-20090626/imagick.so' but as I'm using XAMPP, my extension dir( as I understand ) is /Applications

PHP imagick or any other tool, how to detect if there is visible transparency on gifs files

戏子无情 提交于 2020-05-13 14:37:05
问题 I am working on a service that can do conversions from gif to mp4 files (with ffmpeg ). My problem is some of the gifs have visible transparent areas which end up as white color when I convert them to mp4 video. To avoid that problem I am trying detect if a gif has visible transparent areas so I will avoid converting them to mp4. I tried to use getImageAlphaChannel() function from imagick. if ($imagick->getImageAlphaChannel()) { echo 'transparent image'; } else { echo 'not transparent image';

php中网页生成图片的方式

 ̄綄美尐妖づ 提交于 2020-03-10 20:33:09
在网上找了很多方法,发现与自己最初的思路也是大同小异,那就是 HTML——》PDF——》JPG 。从上午9点钟一直搞到下午6点钟,代码方面其实很简单,更多的还是环境和PHP拓展上面,忙了一天的成果有必要分享一下。 第一步:HTML——》PDF 1、利用html2fpdf将html转成pdf 1 require('html2fpdf/html2fpdf.php'); 2 $pdf=new HTML2FPDF(); 3 $pdf->AddPage(); 4 // yourfile.html 你要转化的HTML文件 5 $yourfile_html = "index.html"; 6 // yourfile.pdf 转化成功后的pdf文件名 7 $yourfile_pdf = "yourfile.pdf"; 8 $fp = fopen($yourfile_html,"r"); 9 $strContent = fread($fp, filesize($yourfile_html)); 10 fclose($fp); 11 $pdf->WriteHTML($strContent); 12 $pdf->Output($yourfile_pdf ); html2fpdf类库网上都可以下载到,这个方法的一个缺点就是会出现中文乱码,所以我后来又找到了下面这种方法: 2

Windows下PHP安装 Imagick扩展

為{幸葍}努か 提交于 2020-03-09 21:57:23
------------恢复内容开始------------ 根据环境下载合适的 imagick扩展 和 imagemagick程序 下载imagick扩展 下载地址一: http://windows.php.net/downloads/pecl/releases/imagick/ 下载地址二: https://pecl.php.net/package/imagick 找到符合自己PHP版本的扩展 安装扩展 解压上述文件后,将php_imagick.dll复制到php/ext目录,或者其他你的存放拓展的目录 修改php.ini 加上extension=php_imagick.dll,注意php可能有多个ini,以phpinfo为准 此时复制解压上述文件目录中其他dll到php目录,重启apache,此时phpinfo显示拓展安装成功,但是 ImageMagick number of supported formats为0,到这里成功安装了一半 安装imagemagick程序 下载的文件解压后,将程序整体复制到无空格 无中文字符的目录中 E:\Program Files (x86)\ 配置环境变量,在“此电脑”右键“属性”,以此点击“高级” “环境变量” ,在 “系统变量”中找到键为path的数据,双击path,选择“新建”,将刚刚放程序的目录“E:\Program Files

How to make specified area of an image transparent with Imagick?

坚强是说给别人听的谎言 提交于 2020-03-05 03:32:42
问题 I want to make a part of an image transparent, I tried the code below, even tried many constants as COMPOSITE_DSTOUT, but all didn't work, does anyone know how to? $fooImage->newImage(256, 256, new ImagickPixel('transparent')); $Image->compositeImage($fooImage, Imagick::COMPOSITE_DSTOUT, $offsetX, offsetY); I tested the code below, just got yellow with black, not transparent: $width = 256; $height = 256; $image = new Imagick(); $image->newImage($width, $height, new ImagickPixel('yellow')); $x

php获取图片RGB颜色值的例子

落爺英雄遲暮 提交于 2020-02-29 09:01:45
php获取图片RGB颜色值的例子 很多图片站点都会根据用户上传的图片检索出图片的主要颜色值,然后在通过颜色搜索相关的图片。 之前按照网上的方法将图片缩放(或者马赛克)然后遍历每个像素点,然后统计处RGB次数最多的值,这做法效率太低而且取到的RGB值不够精确。之后才发现使用Imagick的quantizeImage方法能够很方便的取到图片中平均的RGB值. $average = new Imagick("xiaocai.jpg");$average->quantizeImage( 10, Imagick::COLORSPACE_RGB, 0, false, false );$average->uniqueImageColors();function GetImagesColor( Imagick $im ){$colorarr = array();$it = $im->getPixelIterator();$it->resetIterator();while( $row = $it->getNextIteratorRow() ){foreach ( $row as $pixel ){ // www.jbxue.com$colorarr[] = $pixel->getColor(); } }return $colorarr; }$colorarr = GetImagesColor(