Please help me with that function
hubertp@plusnet.pl (hubi_p) wrote in message news:<31263529.0409161042.d288ceb@posting.google.c om>...[color=blue]
> 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) ){
> 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;
> }
> }[/color]