gd

Problems with imagesetpixel and displaying the image with php5 and gd 2.0 (or higher, apparently)

I'm trying, for reasons best known to my unconscious mind, to generate a snow-crash-like picture. Using PHP5 and GD v2.0 (or higher), I'm using the following php/html: <?php $x = $y = 100; $gd = imagecreatetruecolor($x,$y); $w = imagecolorallocate($gd, 255, 255, 255); $b = imagecolorallocate($gd, 0, 0, 0); ...

How do I set partial transparancy in GD with PHP?

I am attempting to make a dynamic image with PHP, and I can't find out how to set partial transparency. It is very easy to make things either solid or fully transparent, but I have been unable to do this. ...

PHP-GD imagejpeg unable to open

When trying to save a thumbnail made with GD imagejpeg($tnImage, "../../img/thumbs/".$maxWidth."x".$maxHeight."_".$filename); I am getting the following error: Warning: imagejpeg() [function.imagejpeg]: Unable to open '../../img/thumbs/80x80_55865-drops.jpg' for writing: No such file or directory in /home/user/workspace/stewart/serve...

How can I upload/resize images taken with a digital camera?

I am working on a building a gallery and the goal is a low barrier of entry. My user is someone who takes pictures using their digital camera so file size would be between 200 - 400 KB per image. The problem I am running into using the GD library is that each image when resized and uploaded use about 90MB of memory+ when the server h...

When I try to make php with --with-gd, I get an error that "configure: error: libpng.(a|so) not found." What's wrong?

So far, I've made sure I've installed libpng and libjpeg with DarwinPorts (I'm running on OS X Leopard), but that doesn't seem to do the trick. I've read in a number of places that you need the development files (i.e. libpng-devel, etc.) as well to make this work. I'm a little lost. Can someone help me understand what I'm supposed to ...

Php Gd rotate image

HEllo, I am trying to rotate a circular image around the center and then cut off the sides. I see the imagerotate function, but it does not seem to rotate about centre. Anyone have any suggestions? Thank you. Update: Since it is a circle, I want to cut off the edges and keep my circle in the same dimensions. ...

Overlaying colour on a JPEG with PHP/GD?

Hi all, I have a collection of black and white JPEG's stored on my server. These images are symbol based, where the symbol is a collection of black lines on a white background. I am trying to use GD to replace the black colour with another colour on the fly based on a variable passed. Currently, I am: Getting the JPEG as: $image = ima...

AJAX load of a rendered PNG not working

I am rendering a custom image based on some defaults and parameters in POST with a custom php script and the GD library. I am trying to build a custom form to allow users to select these parameters and then send an AJAX request to render the image and send it back and load a preview in the page. The problem is that the first preview ...

Why do all my auto-generated thumbnails with GD in PHP have black backgrounds?

Well I am using the following code to take any old image into a 160x120 thumbnail, the problem is if there is overflow the background is always black. I've been snooping around the PHP docs but none of these functions seem to have any kind of color parameters. Any ideas or pointers would be great! $original = 'original_image.jpg'; $th...

Problem with PHPs getimagesize function

I am using PHPs GD extension for jpg image manipulation. The problem is that at one point I am using the getimagesize function to get image width and height. It works fine locally as well as one one of my remote servers but not on another of my remote servers. The problem seems to arise when using getimagesize for relatively large images...

Convert GD-Sharp stream to Bitmap

im currently trying out GD-Sharp and wanted to convert the graphic into bitmap without saving it to image file. GD-Sharp method to save to stream is bool GB.Save(Stream outStream); for saving using stream is using(FileStream fs = File.OpenWrite(@"stream1.jpg")) { image.Save((System.IO.Stream)fs); fs.Close(); } since bitmap ...

What are the odds of GD or ImageMagick already being part of a client's PHP install?

I'm working on a package which includes rescaling of images in PHP. For image rescaling, PHP has the GD and ImageMagick libraries. Are those likely to be part of a given client's PHP install already? Is there a "default" install of PHP, for that matter? By default, are either GD or ImageMagick included? If neither is installed, should ...

How can I tint transparent PNG files in PHP?

I have a transparent PNG image. The transparent areas need to remain completely transparent, but the other areas need tinting with a particular hue. What's the best way to do this using GD? Cheers, James ...

PHP/GD - Cropping and Resizing Images

I've coded a function that crops an image to a given aspect ratio and finally then resizes it and outputs it as JPG: <?php function Image($image, $crop = null, $size = null) { $image = ImageCreateFromString(file_get_contents($image)); if (is_resource($image) === true) { $x = 0; $y = 0; $width = imagesx($imag...

Crop or mask an image into a circle

What is the best way to crop or mask an image into a circular shape, using either ImageMagick or GD libraries? (Note, solution exists on "other" Q&A sites, but not StackOverflow) ...

GD image generating bug

I'm using GD to generate images on the fly for title images on the page. There are over 100 images generated at the moment, the vast majority of which work great. Recently we found certain titles were breaking the image creation where a large horizontal space was inserted between 2 characters. The font being used for image generation i...

Outputting image using php GD library via function call

I know that I can output an image using GD by using <img src='draw.php'> Where draw.php is a file containing the code to create an image. How can I instead output the image via a function call (I am using the Zend Framework so will be using a View Helper) rather than simply pointing to a .php file in an img tag as above? Any help g...

PHP/GD ImageSaveAlpha and ImageAlphaBlending

I'm using GD to resize and convert images, however during my tests I found a weird behavior when converting transparent PNG's to JPEG's. According to the manual ImageAlphaBlending() is on by default but in order to preserve the transparency I must set ImageSaveAlpha() to true (which in turn requires that I set ImageAlphaBlending() to fal...

PHP: GD Library:Increase font size in ImageString function

I have the following block of code which will output a captcha image $im = @imagecreatefromjpeg("captcha.jpg"); $rand = _generateRandom(3); $_SESSION['captcha'] = $rand; ImageString($im, 5, 2, 2, $rand[0]." ".$rand[1]." ".$rand[2]." ", ImageColorAllocate ($im, 23, 85, 160)); Now i want to increaese the font size.I have used the ...

How to pick a color to make transparent in images?

First question, please be gentle ;-) I've written an image class that makes simple things (rectangles, text) a bit easier, basically a bunch of wrapper methods for PHP's image functions. What I'm trying to do now is to allow the user to define a selection, and have the following image operations only affect the selected area. I figured ...