5

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

"--without-gd"

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);  

 imagejpeg($image) 

imagedestroy($image);  
imagedestroy($watermark);  
//end php



4 Answers4

1

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.

1

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.

korkman
  • 1,677
  • 2
  • 13
  • 27
0

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.

Ben Pilbrow
  • 12,031
0

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

Kevin Sedgley
  • 414
  • 1
  • 3
  • 11