imagick

Imagick don't open pdf files with “Failed to read the file” exception

守給你的承諾、 提交于 2019-12-01 00:52:04
问题 Trying to open PDF file from php script drop into fault with error: Uncaught ImagickException: Failed to read the file in ... I'm running OS X, Brew, PHP 7.0, php70-imagick --HEAD, ImageMagick --with-ghostscript, GhostScript Command line test works fine: convert 1.pdf 1.jpg File permission is ok. Try both, an URL and local file with realpath function, so filepath is ok too. Script works fine if open jpeg. phpinfo() -> ImageMagick supported formats: EPDF, PDF, PDFA, etc. UPDATE: Solved.

ghostscript 9.26 update breaks imagick readImage for multipage PDF

柔情痞子 提交于 2019-11-30 23:42:06
Since the ghostscript update 9.25 -> 9.26 (on debian) last morning we get this error: ErrorMessage: FailedToExecuteCommand `'gs' -sstdout=%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pngalpha' -dTextAlphaBits=4 -dGraphicsAlphaBits=4 '-r300x300' -dFirstPage=1 -dLastPage=1 '-sOutputFile=/tmp/magick-39903EapVvuyNQxL4%d' '-f/tmp/magick-39903VD0GMIpLPaIN' '-f/tmp/magick-399031owlSOb4aOEw'' (-1) @ error/delegate.c/ExternalDelegateCommand/462 When trying to read the first page of a multipage PDF: $this->resource = new \Imagick();

readimageblob: Fatal Error when converting SVG into PNG

倾然丶 夕夏残阳落幕 提交于 2019-11-30 23:29:36
问题 I'm trying to use Image-Magick with PHP to convert SVG text into a PNG image. This SVG is a chart generated with NVD3 and I'd like to allow my users to download it as an image. Basically, I'm sending the SVG data, encoded with JSON to the PHP handler which is supposed to output it as a PNG image. But, this throws up the following error: Fatal error: Uncaught exception 'ImagickException' with message 'no decode delegate for this image format `' @ blob.c/BlobToImage/347' in svg2png.php:4 Stack

How to set the trimming color in Imagick?

巧了我就是萌 提交于 2019-11-30 21:37:58
I am trying to remove transparent areas of an image with php using imagick. Image Magick provides the trim method: Imagick::trimImage Remove edges that are the background color from the image. This method is available if Imagick has been compiled against ImageMagick version 6.2.9 or newer. How do I set the color which Imagick may trim? The following script sets the background color to grey. However trim removes the blue background color as you can see below. $im = new Imagick( "1.png" ); // Set background color to grey $im->setImageBackgroundColor( new ImagickPixel( "rgb(213,213,213)" ) ); $im

set density parameter for imagick with php

浪尽此生 提交于 2019-11-30 21:23:18
I want to convert a pdf page to a png image with Imagick. I tried with PHP, but the image quality was very low. When I tried with command line, the result was perfect. PHP code $im = new imagick( __DIR__ . DIRECTORY_SEPARATOR.$PDFName.'['.$i.']' ); $params = $im->identifyImage(); $width = $params['geometry']['width']*1; $height = $params['geometry']['height']*1; $im->setResolution(400,400); $im->resizeImage($width ,$height, imagick::FILTER_SINC, 1, true); $im->writeImage(__DIR__ . DIRECTORY_SEPARATOR.'pdf_pages\\'.$i.'.png'); $im->clear(); $im->destroy(); Command line code convert -density 400

Set PHP ImageMagick tmp directory

安稳与你 提交于 2019-11-30 21:07:49
I am trying to set the temporary directory that ImageMagick uses to convert files. Currently, when converting large PDFs, the temp folder quickly gets to 2 or 3 terabytes. This is too much to hold on the servers disk, so I plan to use an AWS EFS to store everything. I have the EFS drive mounted at /efs and am trying to use it for the temp path. How can I set this in ImageMagick? I have tried the following: Setting PHP's temp upload folder in php.ini - this breaks file uploads and is no good Changing ImagickMagick's config.xml file, which doesn't work. Adding environment variable MAGICK_TMPDIR=

Trying to get imagick running on PHP 5.4.3 at Windows x64

爷,独闯天下 提交于 2019-11-30 20:26:27
I have Windows 7 64 bits, PHP 5.4.3 installed through WAMP 2.2 and imagick ( ImageMagick-6.8.3-9-Q16-x64-dll.exe ). I tried to use the php's dll of imagick from a lot of sources but all of them give this error in apache_error.log: PHP Warning: PHP Startup: Unable to load dynamic library 'c:/wamp/bin/php/php5.4.3/ext/php_imagick.dll' - %1 is not a valid Win32 application.\r\n in Unknown on line 0 Any thoughts on how to solve this? an_animal perhaps this can help you: step-by-step instructions for installing IMAGEMAGICK on WAMP? and http://www.elxsy.com/2009/07/installing-imagemagick-on-windows

Scale image according a maximum file size

核能气质少年 提交于 2019-11-30 09:51:45
问题 I'm using Imagick and like to scale an image to a maximum file size of 2.5MB I had a look to this SOF question: ImageMagick: scale JPEG image with a maximum file-size which is exactly what I want to do but the extent() method from Imagick does not have the size parameter: http://www.php.net/manual/en/imagick.extentimage.php Anyone knows how I could to it? At the moment I'm trying to calculate a coefficient between the original file size and the target file size to calculate a new resolution

Imagick: setting the gravity on a Imagick item

こ雲淡風輕ζ 提交于 2019-11-30 09:24:52
问题 I'm having some real difficulties setting the gravity of an image in Imagick. I've managed to set the gravity of an ImaickDraw object but I've not been successful setting it in a Imagick object. Below is the basic code I'm using that the moment. I've just used the same as for ImagickDraw but obviously it isn't working. $rating = new Imagick("ratings/" . $rating . ".png"); $rating->setGravity (Imagick::GRAVITY_SOUTH); $im->compositeImage($rating, imagick::COMPOSITE_OVER, 20, 20); Any ideas how

PHP+Imagick - PNG Compression

心不动则不痛 提交于 2019-11-30 09:00:29
问题 How do I efficiently compress a PNG? In my case, the images are small grayscale images with transparency. Currently I'm playing with this: // ... $im->setImageFormat('png'); $im->setImageColorspace(\Imagick::COLORSPACE_GRAY); $im->setImageCompression(\Imagick::COMPRESSION_LZW); $im->setImageCompressionQuality(9); $im->stripImage(); $im->writeImage($url_t); As Imagick doesn't offer COMPRESSION_PNG , I've tried LZW but there's almost no change in the filesize (usually it's even bigger than