ImageCreateFromjpeg - php function

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Sometimes php hung during ImageCreateFromjpeg when it convert wrong
picture (jpg file with errors). I found the function which check jpg
file. But I don't know how to use that function. I just want to have
the information that file is ok or file is corrupt (for example $jpg =
ok - I've got good file, $jpg = wrong - I've got file with errors). I
include that function below. Really thaks for help!

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) ){
return true;
if ( $fix && fwrite($fd,chr(255).chr(217)) ){return true;}
return false;
}else{fclose($fd); return false;}
return false;

Re: ImageCreateFromjpeg - php function

Please help me with that function (hubi_p) wrote in message
Quoted text here. Click to load it

Site Timeline