gd

Cut any shape from image ( Imagik/Gd)

こ雲淡風輕ζ 提交于 2019-12-22 09:55:37
问题 Is there any way to cut any shape from square image in PHP ? Example, I have image with heart shape: Another image in same size like heart. Final image: So my question is there way in PHP to make such effect from two images, or one image ? 回答1: You basically just want to copy the opacity of the heart template into the car picture. So, at the command-line, you would do: convert motor.jpg heart.png -compose copyopacity -composite result.png And in PHP: #!/usr/local/bin/php -f <?php $template

Two unusual PHP operators used together to get image pixel color, please explain

纵然是瞬间 提交于 2019-12-22 09:31:42
问题 The PHP imagecolorat() function can be used to get the RGB values of an image pixel, as demonstrated in the documentation: $im = imagecreatefrompng("php.png"); $rgb = imagecolorat($im, 10, 15); $r = ($rgb >> 16) & 0xFF; $g = ($rgb >> 8) & 0xFF; $b = $rgb & 0xFF; I don't understand the last three lines at all; I know that they return the correct values, but I cannot figure out how the >> and & operators work together to do so. Could someone please explain? For reference, when $rgb = 9750526 ,

GD imagejpeg() compression?

孤人 提交于 2019-12-22 08:06:04
问题 I'm working on a project where I edit the pixels of a jpg in PHP using the GD library. Its very crucial and key to my project that the output from PHP retains the pixel values I set (cough-steganography-cough). This is the first time I've attempted image manipulation in PHP. I've had no problems before in my Java implementations, so I was foolish not to investigate GD's jpeg compression quality before pursuing further. It turns out that after all my effort, my code does not function the way

Pass GD image object to Imagick?

倖福魔咒の 提交于 2019-12-22 08:04:23
问题 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? 回答1: 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

How to avoid black background when rotating an image 45 degree using PHP?

☆樱花仙子☆ 提交于 2019-12-22 07:56:06
问题 Hi I have to flip a thumpnail image before merge it with another jpeg file. but when I rotate 45 degree using php. It shows a black background. how can I avoid that. any body can help me. 回答1: <? $image = "130.jpg"; $degrees = 25; for($i=0;$i<count($data);$i++){ $ext = ""; $extarr = ""; $extarr = explode(".", $data[$i]['name']); $ext = array_pop($extarr); if($ext == "png"){ $rotate = imagecreatefrompng("images/".$data[$i]['name']); $transColor = imagecolorallocatealpha($rotate, 255, 255, 255,

gd-png cannot allocate image data

自作多情 提交于 2019-12-22 07:03:34
问题 I have an old code base that makes extensive use of GD (no, switching to imagemagick is not an option). It's been running for several years, through several versions. However, when I run it in my current development environment, I'm running into a mysterious gd-png error: cannot allocate image data errors when calling imagecreatefrompng() . The PNG file I'm using is the same as I've been using, so I know it works. Current setup: Ansible-provisioned vagrant box Ubuntu 14.04 PHP 5.5.9 GD 2.1.1

CPAN GD module install failure using Cygwin

依然范特西╮ 提交于 2019-12-22 06:37:57
问题 I have been trying to troubleshoot why CPAN GD module fails to install using Cygwin for 2 days now. Any help is much appreciated. Thanks! cpan install GD Going to read '/home/xxxxxxxxxx/.cpan/Metadata' Database was generated on Sat, 27 Dec 2014 12:17:02 GMT Running install for module 'GD' Running make for L/LD/LDS/GD-2.56.tar.gz Checksum for /home/xxxxxxxxxx/.cpan/sources/authors/id/L/LD/LDS/GD-2.56.tar.gz ok CPAN.pm: Going to build L/LD/LDS/GD-2.56.tar.gz Configuring for libgd version 2.1.0.

Laravel 5.6: Create image thumbnails

谁说我不能喝 提交于 2019-12-22 05:12:27
问题 In my old PHP apps i used to run a function like the one bellow to create jpeg image thumbnails. function imageThumbanail() { $image_src = imagecreatefromjpeg('http://examplesite.com/images/sample-image.jpg'); $thumbnail_width = 180; //Desirable thumbnail width size 180px $image_width = imagesx($image_src); //Original image width size -> 1080px $image_height = imagesy($image_src); //Original image height size -> 1080px $thumbnail_height = floor( $image_height * ( $thumb_width / $image_width )

Write text on the image in proportion

给你一囗甜甜゛ 提交于 2019-12-22 04:24:22
问题 So I have the image: and I want to add text under the image (make demotivational image). So I extend it height and add additional height to the bottom. What I need is write the text: Top text bottom longer text also I need these words to be centered on the image. So the ouput should be: everything is on PHP GD library. The problem is - I don't know how to calculate proportion of font size and center it. My function which is not working, calculate font size wrong and align text wrong.. private

Add whitespace to image and save file to server

人走茶凉 提交于 2019-12-22 00:24:26
问题 I have a script that generates some HTML for newsletters. I'm floating an image using "align=left" and wrapping text around it. I use an inline CSS style, in this case margin-right, to give the image some breathing room. Outlook ignores this. Outlook also ignores padding - I even tried a 10px border-right, it ignored that, too. I can't change the layout and put the image in a table. I am thinking of using GD to manipulate the image, adding 8px of whitespace to the right side of it. The catch