Woodburn2006 Posted September 11, 2008 Share Posted September 11, 2008 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 More sharing options...
BlueSkyIS Posted September 11, 2008 Share Posted September 11, 2008 first: are you sure GD is not already installed? if not, do you have the ability to re-compile PHP with GD enabled? http://us.php.net/manual/en/image.installation.php Link to comment https://forums.phpfreaks.com/topic/123749-gd-library/#findComment-638982 Share on other sites More sharing options...
Woodburn2006 Posted September 11, 2008 Author Share Posted September 11, 2008 well from looking at that it all looks jibberish, im not amazing at php i can do some things with it but nothing too complicated which this looks? is it a hard process setting up gd and using it? Link to comment https://forums.phpfreaks.com/topic/123749-gd-library/#findComment-638992 Share on other sites More sharing options...
BlueSkyIS Posted September 11, 2008 Share Posted September 11, 2008 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 More sharing options...
toyfruit Posted September 11, 2008 Share Posted September 11, 2008 You probably know this, but if you create a phpinfo() file it will tell you if GD Library is on the server. Just put this code in a php page (myfile.php) and upload it to your server, then run it. <?php phpinfo(); ?> Link to comment https://forums.phpfreaks.com/topic/123749-gd-library/#findComment-639008 Share on other sites More sharing options...
Woodburn2006 Posted September 11, 2008 Author Share Posted September 11, 2008 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 More sharing options...
BlueSkyIS Posted September 11, 2008 Share Posted September 11, 2008 i'd say yes, you have GD installed. Link to comment https://forums.phpfreaks.com/topic/123749-gd-library/#findComment-639117 Share on other sites More sharing options...
Woodburn2006 Posted September 11, 2008 Author Share Posted September 11, 2008 cool so thats one problem sorted, the next being is it hard to use to create simple thumbnails of images or can it get quite complicated and gritty? also are there any good tutorials out there to guide me along the way? Link to comment https://forums.phpfreaks.com/topic/123749-gd-library/#findComment-639121 Share on other sites More sharing options...
BlueSkyIS Posted September 11, 2008 Share Posted September 11, 2008 the code i posted before will make thumbs of all images in a directory. you can alter it to make thumbs however you like. Link to comment https://forums.phpfreaks.com/topic/123749-gd-library/#findComment-639122 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.