Jump to content

[Gd] Image Rezise Issue


Swarfega

Recommended Posts

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 by Swarfega
Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.