imagick

Convert PDF (with transparency *and* CMYK) to jpg

倾然丶 夕夏残阳落幕 提交于 2019-12-06 05:57:41
问题 I need to generate jpg images from PDF files (first page only). The PDF files are user generated, so they can contain anything. I'm currently using the following code: // Load PDF. $i = new Imagick; // Create thumbnail of first page of PDF. $i->setResolution(150, 150); $i->loadImage("test.pdf[0]"); $i->thumbnailImage(640, 480, true); // Remove transparency, fill transparent areas with white rather than black. $i->setImageBackgroundColor("white"); $i->setImageAlphaChannel(11); // Imagick:

PHP Imagick how to best fit text annotation

偶尔善良 提交于 2019-12-06 04:50:57
问题 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-

ImageMagick and imagick_type_gen don't recognize added fonts

若如初见. 提交于 2019-12-06 00:51:19
Ok, I'm running a CentOS server, PHP 5.4.440 and ImageMagick 6.5.4 and I'm trying to add additional fonts, as an example let's say Lobster. Here's what I've done so far: Uploaded Lobster.ttf to /home/myusername/fonts/ From SSH, ran "perl imagick_type_gen > fonts.xml". This resulted in a large font file, but contained NO references to either Lobster.otf or Lobster.ttf Instead, I generated my own type.xml and saved it to /home/myusername/.magick/. Here's the markup: <?xml version="1.0"?> <typemap> <type format="otf" name="Lobster" fullname="Lobster" family="Lobster" glyphs="/home/myusername

PHP extensions not loading in phpinfo

只谈情不闲聊 提交于 2019-12-06 00:43:50
问题 So I'm running MAMP on Mountain Lion and I've installed gmagick and imagick using pecl, both are relase candidates (mainly because gmagick doesn't have a stable release and imagick 3.0.0 doesn't install, it gives a make error). The modules appear when I run php -i in the terminal but not in phpinfo(), I have checked the php.ini it is the same for both so that is not the issue.However I have installed bitset(which is a stable release) and it appears in phpinfo() and php -i. So my question is

ImageMagick missing decode delegates

社会主义新天地 提交于 2019-12-05 23:25:18
I recently moved to MediaTemple and installed ImageMagick and IMagick following their KB article here . No error and phpinfo() show module correctly installed. When I try to use IM on a JPG image via PHP I get this error Uncaught exception 'ImagickException' with message 'no decode delegate for this image format /home/149263/domains/wer.com/html/images/pictures/post/tmp/original/' @ error/constitute.c/ReadImage/544' in /nfs/c10/h04/mnt/149263/domains/wer.com/html/application/controllers/post.php:301 Stack trace: #0 /nfs/c10/h04/mnt/149263/domains/wer.com/html/application/controllers/post.php

How to read an SVG with a given size using PHP Imagick?

ぃ、小莉子 提交于 2019-12-05 23:21:23
I have the following code: $image = new Imagick(); $image->setBackgroundColor(new ImagickPixel('green')); $image->setSize(20,20); $image->readImageBlob(file_get_contents('./some/path/image.svg')); It loads the SVG just fine but the setSize just gets completely ignored. It renders at 550x100, as per it's definition: <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="550px" height="100px" viewBox="0 0 550 100" enable-background="new 0 0 550 100" xml:space="preserve"> Has anyone got experience in getting SVG files

How to read SVG string in Imagick?

人盡茶涼 提交于 2019-12-05 20:05:58
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); $image->setImageFormat("png"); header("Content-Type:

imagick crash with PHP 5.3

岁酱吖の 提交于 2019-12-05 17:57:01
问题 I'm getting this error: The connection to the server was reset while the page was loading. This only occurs when I try to load an image using ImageMagick. <?php header('Content-type: text/html'); $image = 'some_image.jpg'; /*** a new imagick object ***/ $im = new Imagick(); /*** ping the image ***/ $im->pingImage($image); /*** read the image into the object ***/ $im->readImage( $image ); /**** convert to png ***/ $im->setImageFormat( "png" ); /*** write image to disk ***/ $im->writeImage( '

Pass GD image object to Imagick?

霸气de小男生 提交于 2019-12-05 17:50:20
I'm generating a barcode with PEAR::Image_Barcode which uses GD, but I need to write that barcode onto a section of a PDF and PHP/Imagick seems to be the easiest way to do that, is there any way to convert a GD image object into something Imagick can work with? here we go: ob_start(); Image_Barcode::draw($barcode, 'upca', 'gif'); $couponBarcode = ob_get_contents(); ob_end_clean(); $second = new Imagick(); $second->readImageBlob($couponBarcode) it's writing the image to an output buffer with GD then reading that variable into an Imagick object ImageMagick has internal image creation functions.

Generate SVG Image using svg raw data in imagick php

拥有回忆 提交于 2019-12-05 10:48:40
I am trying to create svg image using svg raw data which i am getting from fabric js. I have used below code to generate the svg using svg raw data but its not working properly. public function generate_svg($raw_svg='',$prefix='',$folder_name='card_image') { $file_name = ''; if($raw_svg!='') { try{ $file_name = uniqid($prefix).".svg"; $image = new \Imagick(); $image->readImageBlob($raw_svg); $image->setImageFormat("svg"); $image->writeImage($folder_name.$file_name); } catch (ImagickException $ex) { echo $ex->getMessage(); } } return $file_name; } Now the issue is background image is kind of