imagick

How to color text and background separatly for Imagick caption?

纵然是瞬间 提交于 2020-01-14 22:59:22
问题 I only want to color the caption text, and not the entire caption box (or background). Before Imagemagick 6.3.7 I could use this code to have a red colored text : $im->newPseudoImage(300, 300, "caption:" . "Put your text" ); $im->colorizeImage('#ff0000',1.0); I have upgraded because I need to set a font and a font size with the following code : $im->setFont("somefont.ttf"); $im->setpointsize(72); Now colorizeImage does not work the same way, as it doesnt' color only the caption TEXT but the

Detect if image is grayscale or color using Imagick

a 夏天 提交于 2020-01-13 02:46:09
问题 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

PHP imagick with PDF issue

我的未来我决定 提交于 2020-01-07 05:29:10
问题 I am trying to convert the first page of a PDF to an image file. I have the following code: $im = new imagick('/images/test.pdf[0]'); $im->setImageFormat("jpg"); $page=$im->queryFormats(); echo "<pre>"; print_r ($page); echo "</pre>"; However, I get an error message saying: Uncaught exception 'ImagickException' with message 'unable to open image If I change: $im = new imagick('/images/test.pdf[0]'); to: $im = new imagick('/images/test.pdf'); I get the following error: Uncaught exception

Imagick not reflects the gravity once it is set

喜你入骨 提交于 2020-01-06 07:16:06
问题 I am trying to translate the following piece of Imagemagick command line code convert tmpI.mpc -gravity center -crop ${ww}x${hc}+0+0 +repage as follows $tmpIC->setGravity(imagick::GRAVITY_CENTER); $tmpIC->cropImage($ww, $hc, 0, 0); $tmpIC->setImagePage($tmpIC->getImageWidth(), $tmpIC->getImageHeight(), 0, 0); but setting or not setting the gravity makes no difference. Please tell me what is wrong with the piece of code I have Width and Height of the image before cropping are tmpIC-

Creating array populated by images from a PDF using PHP and ImageMagick

北城余情 提交于 2020-01-05 09:03:44
问题 I'm trying to write a routine that will take a PDF submitted by a user, and extract each page as an image and then populate an array with those images. I've found several examples that append all pages to one image, but none that do what I need. This is what I have, but it returns an empty array: function PdfToImg($pdf_in) { $img_array = array(); $im = new imagick(); $im->readimageblob($pdf_in); // reading image from binary string $num_pages = $im->getnumberimages(); $im->setimageformat("png"

Apply displacement map via Imagick after version update

☆樱花仙子☆ 提交于 2020-01-05 05:37:10
问题 I had the code running to create a "cylinder" effect via ImageMagick v6.7.9 and PHP (Imagick extension v3.2.0), it's like described in the accepted answer of my previous question: https://stackoverflow.com/a/54807019/1800172 It's inspired by Fred's cylinderize script: http://www.fmwconcepts.com/imagemagick/cylinderize/ After creating the X/Y-displacements ( $a3 / $a4 ) it's combined like this: // merge x-displacement and y-displacement into one displacement-map $displaceMask = new Imagick();

How to set color of a pixel using imagick for php (imagemagick)?

99封情书 提交于 2020-01-04 15:33:25
问题 I have get the image pixel of an image at the particular point using getImagePixelColor. $pixel = $image -> getImagePixelColor($x,$y); Now I have modified that pixel's color using some method and now I want to set the new color of that pixel. How can I do ? There is a setColor function. But I got the pixel from the Imagick class. But the setColor function is in the ImagickPixel class. So how can I do it ? 回答1: ->getImagePixelColor() returns an ImagickPixel object anyways, so $pixel->setColor(

PHP script to convert multiple images into a video with imagick

纵饮孤独 提交于 2020-01-03 05:45:08
问题 I found this command line that uses ImageMagick to convert images into a video: ImageMagick convert -delay 100 -quality 75 1.jpg 2.jpg movie.mpg Is there a way to do this in php with imagick? I am trying to find a way to do this on a website. My google-fu has failed me and I appreciate any help :) 回答1: Considering that convert is the executable program you're using from the command-line, the simplest solution would be to use it from your PHP scripts ;-) About that, you'll want to read through

How can I create a specific number of thumbnails from a PDF using Imagick, ImageMagick, and PHP?

落爺英雄遲暮 提交于 2020-01-03 04:51:06
问题 I'd like to use PHP, ImageMagick, and Imagick ( PHP Class ) to create thumbnails of a PDF. Some PDFs will only have one page, and some will have many. I'd like to specify a number ( N ) of thumbnails to create, one for each of the first N pages in the PDF. The code below works, but produces errors when the PDF doesn't have enough pages ( because I'm trying to instantiate Imagick on a PDF page that doesn't exist ). I also know that ImageMagick can create thumbnails for all the pages in a PDF

php imagick gif resize all frame

六月ゝ 毕业季﹏ 提交于 2020-01-03 04:40:34
问题 i have a problem to resize all frame using php imagick. it's take from official php doc example http://ir.php.net/manual/en/imagick.examples-1.php /* Create a new imagick object and read in GIF */ $im = new Imagick("/tmp/bbb.gif"); /* Resize all frames */ foreach ($im as $frame) { /* 50x50 frames */ $frame->thumbnailImage(50, 50); /* Set the virtual canvas to correct size */ $frame->setImagePage(50, 50, 0, 0); } /* Notice writeImages instead of writeImage */ $im->writeImages("/tmp/zb.gif",