Solved

help needed to install and use the GD library

Posted on 2006-11-25
11
141 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 60 total points
Comment Utility
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
Comment Utility
flipping brill. ok let me play for a bit..
0
 

Author Comment

by:jimbona27
Comment Utility
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
 
LVL 11

Expert Comment

by:ch2
Comment Utility
<?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
Comment Utility
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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

Author Comment

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

Expert Comment

by:ch2
Comment Utility
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
Comment Utility
that works.... (?)
0
 
LVL 11

Expert Comment

by:ch2
Comment Utility
it works.
0
 

Author Comment

by:jimbona27
Comment Utility
can you explain why it works like that?
0
 

Author Comment

by:jimbona27
Comment Utility
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

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

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…
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now