Jump to content

Archived

This topic is now archived and is closed to further replies.

miob

how to detect invalid jpeg format ?

Recommended Posts

i do resize on some external jpegs, but sometimes i get 404 error page instead of jpeg,
but script copied it , saved it and if i do resize i get black square from it.
i have no clue how to stop resizing , or do anything with no picture,
how to detect if it's case where is no pic.

getimagesize doesn't help for me...

thanx

Share this post


Link to post
Share on other sites

[code]
function is_jpeg($image)
{
    $image_mime_type = mime_content_type($image);

    if (("image/jpeg" == $image_mime_type) || ("image/jpg" == $image_mime_type))
         return true;
    else
        return false;
}
[/code]

Share this post


Link to post
Share on other sites
Fatal error: Call to undefined function: mime_content_type()

i have noticed that it happens when instead of jpeg they have 404 redirect to some html page, copy function copied it as binary file, and result is that it has nothing to do with jpeg format.

is there any chance to get it fixed without changing of php.ini ?

then i've found this

if ( ! function_exists ( 'mime_content_type ' ) )
{
function mime_content_type ( $f )
{
return system ( trim( 'file -bi ' . escapeshellarg ( $f ) ) ) ;
}
}

by adding this next function all sounds fine..

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.