Solved

help needed to install and use the GD library

Posted on 2006-11-25
11
143 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
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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Stop people from trying to get into my server 8 122
Read Config:: values from another file 2 91
.htaccess rewrite url with querystring problem 13 94
ports for sccm 2012 1 80
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). #…
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 …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

778 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