note 35116 added to function.imagecreatefromjpeg
| From: | willertan1980 at yahoo dot com | Date: | Wed, 20 Aug 2003 09:14:35 +0000 |
| Subject: | note 35116 added to function.imagecreatefromjpeg | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-54736@lists.php.net to get a copy of this message | ||
did you found that sometimes it hang the php when imagecreatefromjpeg() run on bad JPEG. I found
that this is cause by the JPEG file U used dont have EOI (end of image)
the FF D9 at the end of your JPEG
JPEG image should start with 0xFFD8 and end with 0xFFD9
// this may help to fix the error
function check_jpeg($f, $fix=false ){
# [070203]
# check for jpeg file header and footer - also try to fix it
if ( false !== (@$fd = fopen($f, 'r+b' )) ){
if ( fread($fd,2)==chr(255).chr(216) ){
fseek ( $fd, -2, SEEK_END );
if ( fread($fd,2)==chr(255).chr(217) ){
fclose($fd);
return true;
}else{
if ( $fix && fwrite($fd,chr(255).chr(217)) ){return true;}
fclose($fd);
return false;
}
}else{fclose($fd); return false;}
}else{
return false;
}
}
----
Manual Page -- http://www.php.net/manual/en/function.imagecreatefromjpeg.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35116
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35116&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35116&report=yes