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
Switch to threaded view of this topic Create a new topic Submit Reply
imagecreatefromstring - errort test never fails??? [message #182473] Tue, 06 August 2013 21:02 Go to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
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.
Re: imagecreatefromstring - errort test never fails??? [message #182475 is a reply to message #182473] Tue, 06 August 2013 21:16 Go to previous message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
On 06/08/13 22:02, The Natural Philosopher wrote:
> 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?
>
scrub that. the error is in the else clause, which IS being executed

--
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.
  Switch to threaded view of this topic Create a new topic Submit Reply
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 23:34:40 GMT 2024

Total time taken to generate the page: 0.02226 seconds