fife Posted April 18, 2012 Share Posted April 18, 2012 Ok I have seen many posts on this script and many people asking question on this site. The script can be found..... http://www.white-hat-web-design.co.uk/blog/resizing-images-with-php/ However I still can not make it work with what I have got. So here is the problem. First of all I upload the image and save the name to the database. I then pass its ID to the next page to retrieve the image and its path from the database. This is where the script comes in. I then run the image through the script and send you to the success page. Now the image is not being resized! The code is not erroring (even with error reporting on). It would seem the code it just get ignored completely. The image is still there and displays how it was uploaded but the size just hasnt changed. Im asuming Im using it in the correct way. Here is the code after the image has been uploaded. $Fetchq = mysql_query("SELECT * FROM images WHERE imageID ='".$_GET['image']."' ") or die('error stuff here'); $fetched = mysql_fetch_array($Fetchq); $path = "/members/images/members/merseyside/{$fetched['imagename']}"; include('SimpleImage.php'); $image = new SimpleImage(); $image->load('$path'); $image->resize(60,60); $image->save('$path'); $url = "/activity-photos.php?uploaded=true"; header("Location: $url"); Any help would be greatly appreciated as I've had enough of banging my head against this code wall Quote Link to comment https://forums.phpfreaks.com/topic/261165-another-image-re-sizer-question/ Share on other sites More sharing options...
requinix Posted April 18, 2012 Share Posted April 18, 2012 '$path' Variables don't work inside single-quoted strings. Not that you need them at all... include('SimpleImage.php'); $image = new SimpleImage(); $image->load($path); $image->resize(60,60); $image->save($path); Quote Link to comment https://forums.phpfreaks.com/topic/261165-another-image-re-sizer-question/#findComment-1338364 Share on other sites More sharing options...
fife Posted April 18, 2012 Author Share Posted April 18, 2012 thanks requinix for your reply however that did not solve it. Still the same issues. No errors even with reporting and file is still the same size. The image is also definitely loading into the page as I have checked that too. Here is the code as stands $path = '/members/images/merseyside/'.$fetched['imageName'].''; include('SimpleImage.php'); $image = new SimpleImage(); $image->load($path); $image->resize(60,60); $image->save($path); $url = "/activity-photos.php?uploaded=true"; header("Location: $url"); Quote Link to comment https://forums.phpfreaks.com/topic/261165-another-image-re-sizer-question/#findComment-1338370 Share on other sites More sharing options...
requinix Posted April 18, 2012 Share Posted April 18, 2012 Then I would bet there actually are errors. Did you also make sure that display_errors is on? Quote Link to comment https://forums.phpfreaks.com/topic/261165-another-image-re-sizer-question/#findComment-1338373 Share on other sites More sharing options...
fife Posted April 18, 2012 Author Share Posted April 18, 2012 yes at the top of the page i put error_reporting(E_ALL); ini_set("display_errors", 1); Quote Link to comment https://forums.phpfreaks.com/topic/261165-another-image-re-sizer-question/#findComment-1338375 Share on other sites More sharing options...
fife Posted April 18, 2012 Author Share Posted April 18, 2012 ok I managed to get myself some errors. Here is what I got Warning: getimagesize(/members/images/members/Merseyside/0b12dd48f09fafc2e2985743cca2029flazy-grass-2.jpg) [function.getimagesize]: failed to open stream: No such file or directory in/members/clubs/SimpleImage.php on line 30 Warning: imagesx(): supplied argument is not a valid Image resource in /members/clubs/SimpleImage.php on line 73 Warning: Division by zero in /members/clubs/SimpleImage.php on line 87 Warning: imagesy(): supplied argument is not a valid Image resource in /members/clubs/SimpleImage.php on line 77 Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /members/clubs/SimpleImage.php on line 99 Warning: imagesx(): supplied argument is not a valid Image resource in /members/clubs/SimpleImage.php on line 73 Warning: imagesy(): supplied argument is not a valid Image resource in /members/clubs/SimpleImage.php on line 77 Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /members/clubs/SimpleImage.php on line 100 Warning: imagejpeg(): supplied argument is not a valid Image resource in /members/clubs/SimpleImage.php on line 46 Quote Link to comment https://forums.phpfreaks.com/topic/261165-another-image-re-sizer-question/#findComment-1338383 Share on other sites More sharing options...
fife Posted April 18, 2012 Author Share Posted April 18, 2012 solved. it couldnt find the server root so adding {$_SERVER['DOCUMENT_ROOT']} at the start of the path solved the issue. Quote Link to comment https://forums.phpfreaks.com/topic/261165-another-image-re-sizer-question/#findComment-1338386 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.