gd

PHP GD How to circular crop 3 square images and merge into 1 image maintaining transparency

巧了我就是萌 提交于 2019-12-01 11:06:01
I have 2 source images and I want to: Do a circular crop of each image, with the outside of the circle transparent Merge/copy all images back onto a destination transparent image. I have tried many examples , but can't seem to maintain transparency on the final image. I'm trying to achieve something like this: This is an example of the output I am getting: Here's my circle_crop function: function create_circle( $img_path ) { // Attribution: by NerdsOfTech // Step 1 - Start with image as layer 1 (canvas). if (! $img1 = $this->imageCreateFromAny( $img_path )) { return FALSE; } $x=imagesx($img1);

converting DURING upload before saving on server png/gif to jpg

北慕城南 提交于 2019-12-01 11:05:56
So I have an image upload script. It uploads the image and saves it to the space on the server. What I can't seem to get my head around is say, when the user uploads a .png, by the time it saves on my server i want it to be a jpg. Can anyone help with this, and please don't just direct me to another question as I havent had anything work yet. Here is an example of my code. $name = addslashes($_FILES['image']['name']); $ext = pathinfo($_FILES['image']['name'], PATHINFO_EXTENSION); $size = $_FILES['image']['size']; $temp = $_FILES ['image']['tmp_name']; $error = $_FILES ['image']['error']; if (

Outputting image with underlined text using php GD library

风流意气都作罢 提交于 2019-12-01 08:02:31
What is the best way to display underlined text and output the result as image with GD or any other library? You can try using the Unicode underline combining character U+0332 . <?php // Set the content-type header('Content-type: image/png'); // Create the image $im = imagecreatetruecolor(400, 30); // Create some colors $white = imagecolorallocate($im, 255, 255, 255); $black = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 399, 29, $white); // The text to draw $text = "̲U̲d̲e̲r̲l̲i̲n̲e"; // Replace path by your own font path $font = 'arial.ttf'; // Add the text imagettftext(

converting DURING upload before saving on server png/gif to jpg

烈酒焚心 提交于 2019-12-01 07:51:44
问题 So I have an image upload script. It uploads the image and saves it to the space on the server. What I can't seem to get my head around is say, when the user uploads a .png, by the time it saves on my server i want it to be a jpg. Can anyone help with this, and please don't just direct me to another question as I havent had anything work yet. Here is an example of my code. $name = addslashes($_FILES['image']['name']); $ext = pathinfo($_FILES['image']['name'], PATHINFO_EXTENSION); $size = $

codeigniter resize image and create thumbnail

江枫思渺然 提交于 2019-12-01 07:35:21
hi according to the ci document you can resize images with image_lib and there are options that suggest we can create additional thumbnail from that image create_thumb FALSE TRUE/FALSE (boolean) Tells the image processing function to create a thumb. R thumb_marker _thumb None Specifies the thumbnail indicator. It will be inserted just before the file extension, so mypic.jpg would become mypic_thumb.jpg R so here is my code $config_manip = array( 'image_library' => 'gd2', 'source_image' => "./uploads/avatar/tmp/{$this->input->post('new_val')}", 'new_image' => "./uploads/avatar/{$this->input-

Colorizing and swapping colors with PHP GD Image Library?

一个人想着一个人 提交于 2019-12-01 07:17:36
Hello I am in the process of trying to colorize and swap colors on an image using GD image library with PHP. I am using an original image located here: http://korlon.com/youknowbetter/test.jpg And wish to get it to a point where it is orange face with black clothes and hair much like you see here: http://youknowdifferent.org/ So far I've used the following code: <?php header('Content-type: image/jpeg'); $im = imagecreatefromjpeg('test.jpg'); imagefilter($im, IMG_FILTER_GRAYSCALE); imagefilter($im, IMG_FILTER_CONTRAST, 255); imagefilter($im, IMG_FILTER_NEGATE); imagefilter($im, IMG_FILTER

PHP + GD: imagetruecolortopalette not keeping transparency

无人久伴 提交于 2019-12-01 07:06:16
问题 I am using GD to output an image that is a truecolor+alpha channel PNG file using imagepng just fine. However, I would like to have the ability to also output an ie6-compatible 256-color PNG as well. According to the official documentation for imagetruecolortopalette: The code has been modified to preserve as much alpha channel information as possible in the resulting palette, in addition to preserving colors as well as possible. However, I am finding that the results of this function do not

PHP imagettftext partially bold

馋奶兔 提交于 2019-12-01 07:02:10
I'm training my PHP skills to generate images. I need only one thing which doesn't work. I don't think it's possible on the way I want, but there should be another way. The code I already have is this: <?php $textSize = 10; $text = addslashes("Wietse: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed malesuada aliquet dolor, vitae tristique lectus imperdiet nec. Pellentesque et."); $maxWidth = 448; //Create image $im = imagecreate(468, 60); // Black background and White text $bg = imagecolorallocate($im, 0, 0, 0); $textColor = imagecolorallocate($im, 255, 255, 255); // Split in

How to display an inline image generated on the fly using PHP GD

人盡茶涼 提交于 2019-12-01 06:35:53
I am trying the generate an image on the fly by merging images using PHP GD. I want to know if there is a way I can display the image inside my webpage without the need of storing it somewhere on server. Like for example I created the following code for merging the images... function create_image() { $main_image = imagecreatefrompng("images/main.png"); $other_image = imagecreatefrompng("images/other.png"); imagecopy($main_image, $other_image, 114, 53, 0, 0, 49, 34); imagepng($main_image); imagedestroy($other_image); } Now my html code till now was... <div class="sidebar-avatar"> <img src=

Making an Image Greyscale with GD Library

感情迁移 提交于 2019-12-01 06:11:26
My mission is to create a little app where you can upload a picture, and the app will turn it into ASCII art. I'm sure these exist already but I want to prove that I can do it myself. This would involve taking an image, making it greyscale and then matching each pixel with a character depending on how dark the picture is and how full the character is. So my question is, Using the GD Library (or i guess some other means if necessary) how do I make an image black and white? A common formula to convert RGB to greyscale is: Gray scale intensity = 0.30R + 0.59G + 0.11B Stefan Gehrig As pointed out