ImageCreateFromjpeg - php function

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • hubi_p

    ImageCreateFromjpeg - php function

    Sometimes php hung during ImageCreateFrom jpeg 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)==c hr(255).chr(216 ) ){
    fseek ( $fd, -2, SEEK_END );
    if ( fread($fd,2)==c hr(255).chr(217 ) ){
    fclose($fd);
    return true;
    }else{
    if ( $fix && fwrite($fd,chr( 255).chr(217)) ){return true;}
    fclose($fd);
    return false;
    }
    }else{fclose($f d); return false;}
    }else{
    return false;
    }
    }
  • hubi_p

    #2
    Re: ImageCreateFrom jpeg - php function

    Please help me with that function

    hubertp@plusnet .pl (hubi_p) wrote in message news:<31263529. 0409161042.d288 ceb@posting.goo gle.com>...[color=blue]
    > Sometimes php hung during ImageCreateFrom jpeg 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)==c hr(255).chr(216 ) ){
    > fseek ( $fd, -2, SEEK_END );
    > if ( fread($fd,2)==c hr(255).chr(217 ) ){
    > fclose($fd);
    > return true;
    > }else{
    > if ( $fix && fwrite($fd,chr( 255).chr(217)) ){return true;}
    > fclose($fd);
    > return false;
    > }
    > }else{fclose($f d); return false;}
    > }else{
    > return false;
    > }
    > }[/color]

    Comment

    Working...