thyscorpion Posted September 26, 2007 Share Posted September 26, 2007 Hi , I got this code from a tutorial.. and it is not working on my php 5 server. according to me it stops working after this line. ( nothing i echo after it comes on teh screen.).. $img = imagecreatefromjpeg( $pathToImages.$philename ); echo "done so far... "; i am confused as to what could be the problem. am i using the imagecreatefromjpeg( ); wrongly? Please Advise... Thanks //////////////////////////////////////////////////////////////////////////////////////////////// // ------------------------------------------------------------------------------------------------------------------------------ function createThumbs( $pathToImages, $pathToThumbs, $thumbWidth, $philename ) { // 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' ) // { echo "Creating thumbnail for ".$philename." <br />"; echo "pathToImages:".$pathToImages."\n<br>"; echo "path = "."".$pathToImages.$philename.""."\n <br>"; // load image and get image size $img = imagecreatefromjpeg( $pathToImages.$philename ); echo "done so far... "; $width = imagesx( $img ); $height = imagesy( $img ); echo "width:".$width." height:".$height."\n <br>"; // calculate thumbnail size $new_width = $thumbWidth; $new_height = floor( $height * ( $thumbWidth / $width ) ); echo "new width:".$new_width." new height:".$new_height."\n <br>"; // 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.$philename."" ); // } // } // close the directory // closedir( $dir ); } $phath = "images/gallery_pics/".$album_id ."/"; $phathT= "images/gallery_pics/".$album_id ."/t/"; // call createThumb function and pass to it as parameters the path // to the directory that contains images, the path to the directory // in which thumbnails will be placed and the thumbnail's width. // We are assuming that the path will be a relative path working // both in the filesystem, and through the web for links createThumbs($phath,$phathT,100,$filename); // ------------------------------------------------------------------------------------------------------------------------------ /////////////////////////////////////////////////////////////////////////////////////// Quote Link to comment https://forums.phpfreaks.com/topic/70808-solved-help-needed-making-this-thumbnail-creating-code-work/ Share on other sites More sharing options...
BlueSkyIS Posted September 26, 2007 Share Posted September 26, 2007 is GD support compiled into your PHP installation? check phpinfo() to find out. also, if GD support is not compiled in, PHP should complain about an undefined function. If that's the error and you're not seeing it, you should be. Your errors may be turned completely off in php.ini. Quote Link to comment https://forums.phpfreaks.com/topic/70808-solved-help-needed-making-this-thumbnail-creating-code-work/#findComment-356027 Share on other sites More sharing options...
thyscorpion Posted September 26, 2007 Author Share Posted September 26, 2007 is GD support compiled into your PHP installation? check phpinfo() to find out. also, if GD support is not compiled in, PHP should complain about an undefined function. If that's the error and you're not seeing it, you should be. Your errors may be turned completely off in php.ini. YEs you were right. i switched on the errors and i got this: "Fatal error: Call to undefined function imagecreatefromjpeg() in D:\www\ankur\upload2existingalbum.php on line 47" how do i install GD support to my PHP installation? Quote Link to comment https://forums.phpfreaks.com/topic/70808-solved-help-needed-making-this-thumbnail-creating-code-work/#findComment-356049 Share on other sites More sharing options...
BlueSkyIS Posted September 26, 2007 Share Posted September 26, 2007 you must compile GD into a new PHP installation. are you on windows or non-windows? Quote Link to comment https://forums.phpfreaks.com/topic/70808-solved-help-needed-making-this-thumbnail-creating-code-work/#findComment-356051 Share on other sites More sharing options...
thyscorpion Posted September 26, 2007 Author Share Posted September 26, 2007 I have my php on both fedora and on windows xp pro... but i am using windows currently. Quote Link to comment https://forums.phpfreaks.com/topic/70808-solved-help-needed-making-this-thumbnail-creating-code-work/#findComment-356052 Share on other sites More sharing options...
thyscorpion Posted September 26, 2007 Author Share Posted September 26, 2007 oh am using PHP 5 with Apache 2_2 :-) Quote Link to comment https://forums.phpfreaks.com/topic/70808-solved-help-needed-making-this-thumbnail-creating-code-work/#findComment-356054 Share on other sites More sharing options...
BlueSkyIS Posted September 26, 2007 Share Posted September 26, 2007 Sorry, I don't know anything about compiling PHP on Windows. Linux is pretty straightforward via command line or especially easy via WHM/CPanel. For OS X there's MAMP where everything is precompiled and almost too simple, if that's possible... Quote Link to comment https://forums.phpfreaks.com/topic/70808-solved-help-needed-making-this-thumbnail-creating-code-work/#findComment-356055 Share on other sites More sharing options...
thyscorpion Posted September 27, 2007 Author Share Posted September 27, 2007 No problem.. will google it! :-) Quote Link to comment https://forums.phpfreaks.com/topic/70808-solved-help-needed-making-this-thumbnail-creating-code-work/#findComment-356058 Share on other sites More sharing options...
corbin Posted September 27, 2007 Share Posted September 27, 2007 Assuming you have the entire (well... standard) php stuff, you should just have to uncomment a line in php.ini. ;extension=php_gd2.dll extension=php_gd2.dll You have to have php_gd2.dll in your extensions directory though ;p (or your path setting). Quote Link to comment https://forums.phpfreaks.com/topic/70808-solved-help-needed-making-this-thumbnail-creating-code-work/#findComment-356059 Share on other sites More sharing options...
thyscorpion Posted September 27, 2007 Author Share Posted September 27, 2007 Thanks! :-) i had just figured it out and after testing it was coming back to the forum to write what u wrote . :-) thanks.. it works now! sweeeet... Quote Link to comment https://forums.phpfreaks.com/topic/70808-solved-help-needed-making-this-thumbnail-creating-code-work/#findComment-356061 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.