Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

help needed to install and use the GD library

Posted on 2006-11-25
11
Medium Priority
?
154 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
  • 7
  • 4
11 Comments
 
LVL 11

Accepted Solution

by:
ch2 earned 240 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
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
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

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.

Question has a verified solution.

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

If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month12 days, 14 hours left to enroll

972 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