ProblemHelpPlease Posted August 29, 2009 Share Posted August 29, 2009 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}{ Link to comment Share on other sites More sharing options...
ProblemHelpPlease Posted August 30, 2009 Author Share Posted August 30, 2009 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? Link to comment Share on other sites More sharing options...
justsomeguy Posted August 31, 2009 Share Posted August 31, 2009 That's sort of hard to say without seeing the code. Print the string you're passing to imagecreatefromstring and see what it looks like when it doesn't work. Link to comment Share on other sites More sharing options...
ProblemHelpPlease Posted August 31, 2009 Author Share Posted August 31, 2009 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 More sharing options...
justsomeguy Posted August 31, 2009 Share Posted August 31, 2009 If it returned that string, then it is an image, that's a GIF image. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.