Jump to content

GD library


Woodburn2006

Recommended Posts

i am creating a php based site to blog my travelling experiences and wanted to use the GD Library to create thumbnails of the images i upload whilst i am away. i have downloaded gd but cannot find an instruction manual on how to install it or use it with php.

 

i was wondering if anybody could help me with this?

 

thanks alot

Link to comment
https://forums.phpfreaks.com/topic/123749-gd-library/
Share on other sites

if it's already installed, there is nothing to set up. that's why you need to know whether it is already installed or not. you can probably figure that out real quick by trying to use this thumbnail creation function that someone posted here a while back:

 

// CREATE THUMBNAILS OF ALL JPEG IMAGES IN A DIRECTORY
function createThumbs($pathToImages,$pathToThumbs,$thumbWidth) {
//open the directory
$dir=opendir($pathToImages);

//loop through it,looking for any/all JPG files:
while(false!==($fname=readdir($dir))){
	//parse path for the extension
	$info=pathinfo($pathToImages.$fname);
	//continue only if this is a JPEG image
	if(strtolower($info['extension'])=='jpg') {
		//load image and get image size
		$img=imagecreatefromjpeg("{$pathToImages}{$fname}");
		$width=imagesx($img);
		$height=imagesy($img);

		//calculate thumbnail size
		$new_width=$thumbWidth;
		$new_height=floor($height*($thumbWidth/$width));

		//create a new temporary image
		$tmp_img=imagecreatetruecolor($new_width,$new_height);

		//copy and resize old image into new image
		imagecopyresized($tmp_img,$img,0,0,0,0,$new_width,$new_height,$width,$height);

		//save thumbnail into a file
		imagejpeg($tmp_img,"{$pathToThumbs}{$fname}");
	}	
}
//close the directory
closedir($dir);
}

Link to comment
https://forums.phpfreaks.com/topic/123749-gd-library/#findComment-638996
Share on other sites

cool thanks that last post helped.

 

i found this in the phpinfo:

 

gd

GD Support  enabled 

GD Version  bundled (2.0.34 compatible) 

FreeType Support  enabled 

FreeType Linkage  with freetype 

FreeType Version  2.1.4 

GIF Read Support  enabled 

GIF Create Support  enabled 

JPG Support  enabled 

PNG Support  enabled 

WBMP Support  enabled 

XPM Support  enabled 

XBM Support  enabled 

 

does this mean it is on my server?

 

http://travelling.dw20.co.uk/phpinfo.php

Link to comment
https://forums.phpfreaks.com/topic/123749-gd-library/#findComment-639110
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.