Swarfega Posted December 31, 2012 Share Posted December 31, 2012 (edited) Hey. So I've loaded up, what I think, is a pretty neat Image Rezise script on my website, storing the image Path data md5 hashed in a MySQL database, and then loading it through a script on a page, but I have a problem. If the Image is very large or the pixels/quality of the image is very 'complex', the Image Resize script simply stops writing the new file and leaves it at 33kb. Does anyone have a clue why it would do this and if so any possible solution? Here's what happens: http://i45.tinypic.com/r2njw3.png Naturally since the Script stops writing the new image file, there's nothing for the Display Script to actually display, which is a huge issue with its purpose in consideration. EDIT: Forgot a code snippiet, sorry. $this->modifyImage($image, 50, $md5 ); $this->modifyImage($image, 70, $md5 ); $this->modifyImage($image, 255, $md5 ); $this->modifyImage($image, 400, $md5 ); $this->modifyImage($image, 800, $md5 ); function modifyImage( $image, $size, $md5 ) { switch( $this->extension ) { case '.jpg' : $imageX = imagecreatefromjpeg( $image ); break; case '.jpeg' : $imageX = imagecreatefromjpeg( $image ); break; case '.png' : $imageX = imagecreatefrompng( $image ); break; case '.gif' : $imageX = imagecreatefromgif( $image ); break; } $X = $size; $Y = $size; $IRes = getimagesize( $image ); $OX = $IRes[0]; $OY = $IRes[1]; $imagep = imagecreatetruecolor($X, $Y); imagecopyresampled( $imagep, $imageX, 0, 0, 0, 0, $X, $Y, $OX, $OY ); switch( $this->extension ) { case '.jpg' : imagejpeg($imagep, CWD2 . $size.'_'.$md5.$this->extension, 100 ); break; case '.jpeg' : imagejpeg($imagep, CWD2 . $size.'_'.$md5.$this->extension, 100 ); break; case '.png' : imagepng($imagep, CWD2 . $size.'_'.$md5.$this->extension, 100 ); break; case '.gif' : imagegif($imagep, CWD2 . $size.'_'.$md5.$this->extension, 100 ); break; } } Thanks! Edited December 31, 2012 by Swarfega Quote Link to comment https://forums.phpfreaks.com/topic/272535-gd-image-rezise-issue/ Share on other sites More sharing options...
BrettHartel Posted December 31, 2012 Share Posted December 31, 2012 Not entirely certain, but I believe there is a default max_file_size that you need to set higher. This is only a guess as I have never used the resize code. Quote Link to comment https://forums.phpfreaks.com/topic/272535-gd-image-rezise-issue/#findComment-1402283 Share on other sites More sharing options...
Swarfega Posted December 31, 2012 Author Share Posted December 31, 2012 Thank you, I fixed it by adding ini_set('post_max_size', '64M'); ini_set('upload_max_filesize', '64M'); As I don't have direct-access to my PHP.ini file. (If anyone else encounters this, just use this) However, it does still seem to have the tendency to randomly timeout and simply close the connection by the server. The image and the data is still loaded/inserted, but the timeout would ultimately cause a user to press the Back Button, which regardless of having used the Header[Location] function, would re-send the data. Pity. :/ I'll try work that out as well! Quote Link to comment https://forums.phpfreaks.com/topic/272535-gd-image-rezise-issue/#findComment-1402287 Share on other sites More sharing options...
Swarfega Posted December 31, 2012 Author Share Posted December 31, 2012 It seems the issue is not resolved. If the format is .PNG the issue still keeps happening.. Quote Link to comment https://forums.phpfreaks.com/topic/272535-gd-image-rezise-issue/#findComment-1402289 Share on other sites More sharing options...
Swarfega Posted December 31, 2012 Author Share Posted December 31, 2012 Issue Resolved It's simple. Don't be an idiot and try to use a Quality setting of '100' on an already high-quality format such as .PNG. No wonder the engine couldn't write the new image! Marked as Solved. Quote Link to comment https://forums.phpfreaks.com/topic/272535-gd-image-rezise-issue/#findComment-1402291 Share on other sites More sharing options...
PFMaBiSmAd Posted December 31, 2012 Share Posted December 31, 2012 The two ini_set() statements you added don't do anything because those two settings cannot be set inside of a script. They must be set in the master or local php.ini, because php uses them before it transfers control to the .php script. Also, they affect the size of the uploaded file and don't have anything to do with how your resize script runs. You need to set php's error_reporting to E_ALL and display_errors to ON, which you can set in your script, to see what kind of php detected errors are occurring. Quote Link to comment https://forums.phpfreaks.com/topic/272535-gd-image-rezise-issue/#findComment-1402292 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.