imagick

Setting an alpha channel when constructing an ImagickPixel

拈花ヽ惹草 提交于 2020-01-02 18:33:07
问题 I am new to using ImageMagick. I am using the latest imagick extension (3.1.0rc1) with PHP. However, the documentation for imagick seems to be somewhat sparse. I want to create an ImagickPixel object with an alpha channel. The documentation states that these are some valid color values to pass to the constructor: "blue", "#0000ff", "rgb(0,0,255)", "cmyk(100,100,100,10)", etc . I know that it is possible to retrive the alpha value of an ImagickPixel using getColorValue(imagick::COLOR_ALPHA); .

Imagick (Imagemagick on PHP): serve a file without saving to disk first?

空扰寡人 提交于 2020-01-02 09:20:08
问题 I'm trying to use Imagemagick (actually PHP's Imagick) to create and output (serve) an image without saving it to disk first. Currently I'm having to save the file and then use verot upload class to serve the image. (Apache 2 server, PHP5) 回答1: Sure. This should work for you: $image = new Imagick(); // Do your image creation stuff. Make sure to set $image->setImageFormat(); header('Content-Type: image/filetype'); // Change filetype echo $image; 回答2: I admit to never having used Imagick, but

Convert image from RGB to CMYK with Imagick

给你一囗甜甜゛ 提交于 2020-01-01 06:03:05
问题 I'm trying to convert RGB images to CMYK, because they need to be printed. I'm using this code: <?php $filePath = 'rgb.jpg'; // First save image as png $image = new Imagick($filePath); $image->setImageCompression(Imagick::COMPRESSION_UNDEFINED); $image->setImageCompressionQuality(0); $image->setImageFormat("png"); $filePath = 'rgb.png'; $image->writeImage($filePath); $image->clear(); $image->destroy(); $image = null; // Convert colors $image = new Imagick($filePath); $image->stripImage();

Remove white background from the image and make it transparent using PHP

南笙酒味 提交于 2019-12-31 05:15:33
问题 I got this code to do that: $im = new Imagick("test.jpg"); $im->paintTransparentImage($im->getImageBackgroundColor(), 0, 500); $im->setImageFormat('png'); $im->writeImage('finish.png'); And this is the result (I added manually pink background to see the problems better): When I increase the fuzz then more white pixels disappear next to the object but then more white pixels also disappear inside the object. I tried the same image on a website and the result there is: Which is pretty perfect.

I cant save some facebook images to my server as it does not understand the file

一世执手 提交于 2019-12-30 14:09:22
问题 I am using the facebook graph api and it was working well until I realised that some of the jpg files have a query string at the end that is making them unusable. e.g. https://scontent.xx.fbcdn.net/hphotos-xaf1/v/t1.0-9/487872_451835128174833_1613257199_n.jpg?oh=621bed79f5436e81c3e219c86db8f0d9&oe=560F3D0D I have tried stripping off everything after .jpg in the hope that it would still load the image but unfortunately it doesnt. In the following code take the $facebook_image_url to be the one

Replace a color with another color in an image with PHP

那年仲夏 提交于 2019-12-30 13:41:15
问题 Yes I know there are related questions available on stackoverflow but they are not perfectly work as per my need. I am trying to replace a color of an image with another color. In below code I am replacing (255,0,255) with (0,192,239). Below code works but not perfectly replacing new color over pink(255,0,255) color some minor dots or border of pink color is still remaining as you can see in output image. How can i get its perfect solution ? <?php $filename = 'img/Mascots_Aviators_General

Write EXIF into JPG with PHP

放肆的年华 提交于 2019-12-30 07:01:14
问题 For a couple of days I'm trying to write (or update) EXIF information (geotag, latitude and longitude) in a JPG image using PHP. After consulting many sites without success I think the best option is to use Imagick but although it seems I can set the latitude and longitude with setImageProperty(), but when I write the picture the EXIF is not saved. Here I give a code fragment: //Loading existing image $edited = new Imagick(dirname(__FILE__)."/mini.jpg"); //Stripping the curren EXIF info. I

Generate images with ImageMagick without saving to file but still display them on website

送分小仙女□ 提交于 2019-12-30 06:56:51
问题 This is my ImageMagick code which works fine on my webserver by creating new image with the file name 'coloured_font.png' in a default directory ... <?php $cmd = " -background none -pointsize 60 -font Times-Roman -fill red ". " -strokewidth 1 -stroke black label:\"google\" "; exec("convert $cmd coloured_font.png"); ?> But now I am running ImageMagick on Windows which will not create any image files in a default folder but ImageMagick applications runs fine(i have tested by creating thumbnail)

how can i change the dpi of an image with the imagick extension

混江龙づ霸主 提交于 2019-12-29 07:04:38
问题 I need to change all uploaded files to 72 dpi. I'm using the php imagick extension. heres what i've tried (the image i'm using is 300dpi): $image = new Imagick(); $image->setResolution(72,72) ; $image->readImage($img); $image->resampleImage (72,72,imagick::FILTER_UNDEFINED,1); $image->writeImage($target) this doesn't seem to anything. the image is uploading, but stays at 300dpi 回答1: MatTheCat's answer is spot on. You might also try setImageUnits() to ensure it's working with inches and not

Imagick on heroku - is it possible?

梦想的初衷 提交于 2019-12-28 23:58:53
问题 I need to do some actions on jpeg images - Heroku's PHP GD does not allow that. I've read that it is possible with Imagick, so i rewritten the code, pushed it to heroku and... PHP Fatal error: Class 'Imagick' not found in [...] So am I doing something wrong(code works locally)? $tlo = new Imagick(); $tlo->newImage(640, 480, new ImagickPixel('white')); $tlo->setImageFormat('jpg'); Is there any way of working with jpg on heroku? 回答1: ImageMagick, a command-line utility and programming library,