bluebyyou Posted January 10, 2008 Share Posted January 10, 2008 I am trying to rotate multiple images at a time using this in my script. One image will be rotated fine, but then I will get the error messages below. if ($picturerotate > 0) { //270 = Rotate Right //90 = Rotate Left if ($picturerotate == 1){ $degrees = 90; } else if ($picturerotate == 2){ $degrees = 270; } $img_quality = 300; $thumb_quality = 75; $image = imagecreatefromjpeg("uploads/$picturefile"); $bg_color = imagecolorallocate($image, 255,255,255); $rotated_image = imagerotate($image, $degrees, $bg_color); imagejpeg($rotated_image, "uploads/$picturefile", $img_quality); imagedestroy($image); imagedestroy($rotated_image);\ } Warning: imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable error: in /home/content/w/i/u/wiuartinny/html/photo_info_action.php on line 57 Warning: imagecreatefromjpeg(): 'uploads/' is not a valid JPEG file in /home/content/w/i/u/wiuartinny/html/photo_info_action.php on line 57 Warning: imagecolorallocate(): supplied argument is not a valid Image resource in /home/content/w/i/u/wiuartinny/html/photo_info_action.php on line 58 Warning: imagerotate(): supplied argument is not a valid Image resource in /home/content/w/i/u/wiuartinny/html/photo_info_action.php on line 59 Warning: imagejpeg(): supplied argument is not a valid Image resource in /home/content/w/i/u/wiuartinny/html/photo_info_action.php on line 60 Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/content/w/i/u/wiuartinny/html/photo_info_action.php on line 61 Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/content/w/i/u/wiuartinny/html/photo_info_action.php on line 62 Warning: Cannot modify header information - headers already sent by (output started at /home/content/w/i/u/wiuartinny/html/photo_info_action.php:57) in /home/content/w/i/u/wiuartinny/html/photo_info_action.php on line 68 Is this some sort of memory issue? I cant figure out why it dies after rotating only one. Quote Link to comment Share on other sites More sharing options...
Lumio Posted January 10, 2008 Share Posted January 10, 2008 I don't really know, but two things I saw... Are you sure $picturefile is not empty or invalid? And $img_quality = 300;??? I think that's a little too much... 100 is perfect ... 300 means, you want a picture quality of 300%? Put it lower Quote Link to comment Share on other sites More sharing options...
bluebyyou Posted January 11, 2008 Author Share Posted January 11, 2008 $picturefile is set in an earlier part of the script, I can post the whole thing If that would help it make more sense. About the quality I thought it was resolution not percentage, so i will try it at 100. Here is the whole thing(sorry no comments on it yet): <?php session_start(); include("db_connect.php"); if (isset($_SESSION['photo_array'])) { foreach($_SESSION['photo_array'] as $id) { $pictureid = $_POST[$id]['pictureid']; $pictureyear = $_POST[$id]['year']; $picturetitle = $_POST[$id]['title']; $picturefile = $_POST[$id]['picturefile']; $picturethumb = $_POST[$id]['picturethumb']; $picturerotate = $_POST[$id]['rotate']; $event = explode(",",$_POST[$id]['event']); //Separate Day and Event $picturelocation = $event[0]; $pictureday = $event[1]; //Get Event Date $query = "SELECT trip_days FROM `trip` WHERE trip_year = 2007"; query_db($query); $row = mysql_fetch_array($result); extract($row); $trip_day = explode(",",$trip_days); //Separate trip_days $picturedate = $trip_day['$pictureday']; if (isset($_POST[$id]['tag'])) { $picturetag = implode(",",$_POST[$id]['tag']); } $query = "UPDATE pic SET `pictureyear` = '$pictureyear', `pictureday` = '$pictureday', `picturedate` = '$picturedate', `picturelocation` = '$picturelocation', `picturetitle` = '$picturetitle', `picturetag` = '$picturetag' WHERE pictureid = '$pictureid'"; query_db($query); if ($picturerotate > 0) { //270 = Rotate Right //90 = Rotate Left if ($picturerotate == 1){ $degrees = 90; } else if ($picturerotate == 2){ $degrees = 270; } $img_quality = 300; $thumb_quality = 75; $image = imagecreatefromjpeg("uploads/$picturefile"); $bg_color = imagecolorallocate($image, 255,255,255); $rotated_image = imagerotate($image, $degrees, $bg_color); imagejpeg($rotated_image, "uploads/$picturefile", $img_quality); imagedestroy($image); imagedestroy($rotated_image);\ } } } unset($_SESSION['photo_array']); header("location:account.php"); ?> Quote Link to comment Share on other sites More sharing options...
bluebyyou Posted January 11, 2008 Author Share Posted January 11, 2008 Any ideas? I still haven't been able to find the problem and think it is some sort of memory thing. Quote Link to comment Share on other sites More sharing options...
bluebyyou Posted January 12, 2008 Author Share Posted January 12, 2008 I had a problem with the info from the page before, nevermind, solved. Quote Link to comment 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.