Solved

help needed to install and use the GD library

Posted on 2006-11-25
11
147 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Suggested Solutions

If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

751 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