Solved

help needed to install and use the GD library

Posted on 2006-11-25
11
149 Views
Last Modified: 2012-05-05
hi EE,
can someone please tell me how I can install the GD library for my windows xp machine? Im using easyphp.  I want to be able to dynamically resize images within my website.  many thanks,
0
Comment
Question by:jimbona27
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
11 Comments
 
LVL 11

Accepted Solution

by:
ch2 earned 60 total points
ID: 18013462
Search in windows for php_gd2.dll (make sure you have it)

Search in windows for php.ini file and open it with notepad.

Search for this extension_dir and make sure is set to the location where php_gd2.dll was found.

Ex: extension_dir = "C:\Servers\php\ext"

And uncomment the next line.

;extension=php_gd2.dll



0
 

Author Comment

by:jimbona27
ID: 18013955
flipping brill. ok let me play for a bit..
0
 

Author Comment

by:jimbona27
ID: 18014008
ok thanks that seems great but I have a separate file for the function to resize the actual image.

in this file I have:

function resizeImage($image)
{

// example URL:


//$img_name = $_GET["file"];
$img_name = $image;

$size=GetImageSize($img_name);

$new_width    = $size[0]/2;
$new_height   = $size[1]/2;
Header("Content-Type: image/jpeg");

$src_img = ImageCreateFromJPEG($img_name);
$thumb = ImageCreateTrueColor($new_width,$new_height);

ImageCopyResampled($thumb, $src_img,0,0,0,0,($new_width-1),($new_height-1),$size[0],$size[1]);
ImageJPEG($thumb);
ImageDestroy($src_img);
ImageDestroy($thumb);

}

........

then my calling page simply goes resizeImage('1.test.jpg') although this fails.   can you highlight why please?
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
LVL 11

Expert Comment

by:ch2
ID: 18014033
<?php
function resizeimage($image)
{
      header('Content-type: image/jpeg');
      
      $size=getimagesize($image);

      $new_width    = $size[0]/2;
      $new_height   = $size[1]/2;
      
      $thumb = imagecreatetruecolor($new_width, $new_height);
      $src_img = imagecreatefromjpeg($image);

      imagecopyresampled($thumb, $src_img, 0, 0, 0, 0, ($new_width-1), ($new_height-1), $size[0], $size[1]);
      imagejpeg($thumb, null, 100);
}

resizeimage('logo.jpg');
?>

Try the above.



http://www.php.net/gd
0
 

Author Comment

by:jimbona27
ID: 18014052
i have a test file, with the following:

<?php
require("includes/functions.php");
;?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
</head>
<body>
<?php echo resizeImage('photos/1/1.jpg'); ;?>
</body>
</html>


--------------

in the functions.php file I have:


function resizeimage($image)
{
     header('Content-type: image/jpeg');
     
     $size=getimagesize($image);

     $new_width    = $size[0]/2;
     $new_height   = $size[1]/2;
     
     $thumb = imagecreatetruecolor($new_width, $new_height);
     $src_img = imagecreatefromjpeg($image);

     imagecopyresampled($thumb, $src_img, 0, 0, 0, 0, ($new_width-1), ($new_height-1), $size[0], $size[1]);
     imagejpeg($thumb, null, 100);
}


i get the data of the image on the screen rather than the image..
0
 

Author Comment

by:jimbona27
ID: 18014360
still getting the same problem, any suggestions? many thanks.
0
 
LVL 11

Expert Comment

by:ch2
ID: 18014390
Create a new php file copy/paste the code i posted above save the file as img.php upload to your server and test like this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
</head>
<body>
<img src="img.php" alt="Noimage"/>
</body>
</html>
0
 

Author Comment

by:jimbona27
ID: 18014397
that works.... (?)
0
 
LVL 11

Expert Comment

by:ch2
ID: 18014443
it works.
0
 

Author Comment

by:jimbona27
ID: 18014726
can you explain why it works like that?
0
 

Author Comment

by:jimbona27
ID: 18019056
I need to run the script, i.e. dynamically resize multiple images on a page. i will be able to test it before tomorrow and then conclude.
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question