FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » imagecreatefromstring - errort test never fails???
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
imagecreatefromstring - errort test never fails??? [message #182473] Tue, 06 August 2013 21:02 Go to previous message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma:
Senior Member
I have used this as follows

$im=imagecreatefromstring($code);
if($im != FALSE)
{
// resize what's in $code into a thumbnail for use in the database
}
else
// insert an arbitrary thumbnail that represents 'not actually an
image at all'

HOWEVER
If it is a recognisable image, really good thumbnails are created
BUT
if it is NOT an image. the code never executes the 'else' clause and I
just get errors like this

PHP Warning: imagecreatefromstring(): Data is not in a recognized format

in the logs. and three bytes of rubbish ( the string INF) in the
thumbnail!! (INvalid Format? ??)


The manual clearly seems to state that imagecreatefromstring() will
return FALSE if it fails to ID a valid image. NOT spit out an error.

"Return Values

An image resource will be returned on success. *|FALSE|* is returned if
the image type is unsupported, the data is not in a recognised format,
or the image is corrupt and cannot be loaded."

I have tried !=FALSE and !== FALSE with no effect.

Is this a bug, or just me being dumb?

I cant believe it has gone unnoticed if its a bug surely?

--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to lead are elected by the least capable of producing, and where the members of society least likely to sustain themselves or succeed, are rewarded with goods and services paid for by the confiscated wealth of a diminishing number of producers.
[Message index]
 
Read Message
Read Message
Previous Topic: OPcache in php5.5.1 on Windows
Next Topic: GD Function help
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Sep 19 20:07:57 GMT 2024

Total time taken to generate the page: 0.04370 seconds