I have a GD library on my server installed and 'enabled' but under the Configure Command in php.info it says


Is there a way to enable it through root or do I have to recompile?

EDIT: This is what it shows below under "GD"

GD Support            enabled
GD Version            bundled (2.0.34 compatible)
FreeType Support    enabled
FreeType Linkage    with freetype
FreeType Version    2.2.1
GIF Read Support    enabled
GIF Create Support    enabled
JPG Support            enabled
PNG Support            enabled
WBMP Support            enabled
XBM Support            enabled 

Here is my testing script:

//begin php
header('content-type: image/jpg');  

$watermark = imagecreatefrompng('ninja.jpg');  
$watermark_width = imagesx($watermark);  
$watermark_height = imagesy($watermark);  
$image = imagecreatetruecolor($watermark_width, $watermark_height);  
$image = imagecreatefromjpeg($_GET['src']);  
$size = getimagesize($_GET['src']);  
$dest_x = $size[0] - $watermark_width - 5;  
$dest_y = $size[1] - $watermark_height - 5;  
imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 100);  


//end php


The command line shown under Configure Command reflects the options that the binary was built with, not what modules are currently available. Look below the main Configuration header to see if the gd module is loaded. If not then install the php-gd package and restart/reload httpd.

  • I've updated my question with some more information. What doesn't make sense is when I try to run a GD script, nothing happens.. – Matt Nathanson Apr 15 '10 at 18:53
  • So what does your script do? Nothing, or not much - subtle difference :) If I recall correctly, all of the GD functions result in PHP errors if the module isn't loaded. – Ben Pilbrow Apr 15 '10 at 18:57
  • Well I had a simple watermark script...really strange though, it output the url... when I tried to do a variable isset, nothing happened, and when i just tried to echo out plain text, nothing happend at all... So i commented out the header (declaring it was a jpeg) and was able to get my echo out, but nothing happened with the images – Matt Nathanson Apr 15 '10 at 18:59
  • Is it possible to post the watermarking code? It might be worth trying some simple GD tests to verify functionality. I have several already: pastebin.com/fKJZ4tx0, pastebin.com/VHukNERM, pastebin.com/2h0eUGSA, pastebin.com/Cj0R1x4Y – Ben Pilbrow Apr 15 '10 at 19:07
  • Ben, I just updated with the script. – Matt Nathanson Apr 15 '10 at 19:31

Try turning on error_reporting(E_ALL); and point your browser to the image URL. Comment the type header to see any error messages that may be hidden if your browser only displays a broken pict message. And fix that missing semi-colon Ben mentioned.

Edit: And sanitize $_GET['src'] you may be opening a big security hole there.


Is the imagecreatefrompng('ninja.jpg') a typo? (i.e loading a JPEG into imagecreatefrompng which expects a PNG).

When I load a JPEG into imagecreatefrompng, it shows only the URL of the image like you describe. When I load a PNG watermark image, it works just fine.

Note: I'm on Windows, it looks like you're on Linux. Your mileage may vary™, but I don't think by much.

  • I noticed that as well and when i switched it, I'm still getting nothing. Thanks for your help though ::shrug:: – Matt Nathanson Apr 15 '10 at 20:25
  • 2
    Then one last thing before I suggest you request to be migrated over to Stack Overflow (since I believe it's a code issue and I haven't used GD for some time, so it's not fresh in my mind) - the imagejpeg($image) is missing a semi colon on the end. – Ben Pilbrow Apr 15 '10 at 20:34

My php copy came with --without-gd according to phpinfo() - I've just uncommented ;extension=php_gd2.dll in php.ini and GD works fine.

Ubuntu 10, Zend server

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.