Jump to content

Imagecreatefromstring Problem With False Result


ProblemHelpPlease
 Share

Recommended Posts

When using imagecreatefromstring I am getting the following error messages from My scipt with a particular image.Warning: imagecreatefromstring() [function.imagecreatefromstring]: gd-jpeg: JPEG library reports unrecoverable error:Warning: imagecreatefromstring() [function.imagecreatefromstring]: Passed data is not in 'JPEG' format Warning: imagecreatefromstring() [function.imagecreatefromstring]: Couldn't create GD Image Stream out of Data The files is a jpg so should work but the point is the code should return a false result and perform a diferent action that doesnt use imagecreatefromstring. It does this ok but I still get the error message. How do I prevent the error message from appearing.Code is below

$image = imagecreatefromstring($file_contents);if ($image != false){## IF NOT FALSE CODE}else{## IF IS FLASE CODE}{

Edited by ProblemHelpPlease
Link to comment
Share on other sites

I added @ to the $image = imagecreatefromstring($file_contents); lineso$image = @imagecreatefromstring($file_contents);The code still returns FALSE so I can handle the error and @ stops the error message being displayed.I now have another error with the error handling, when using an address to a image but excluding the .jpg(http://www.domain.com/image) the code doesn't return false. Anyone know why this is happening?

Edited by ProblemHelpPlease
Link to comment
Share on other sites

I'm getting "GIF89a€ÿÿÿ!ù,D;" when printing the string passed to the function and "Resource id #6" from the imagecreatefromstring function. I patched the problem by checking for a valid file extension before doing anything with images but it would be helpful to know why false wasn't returned when the address isn't even an image.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...