miob Posted April 26, 2006 Share Posted April 26, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/8504-how-to-detect-invalid-jpeg-format/ Share on other sites More sharing options...
DepretioN Posted April 26, 2006 Share Posted April 26, 2006 [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] Quote Link to comment https://forums.phpfreaks.com/topic/8504-how-to-detect-invalid-jpeg-format/#findComment-31127 Share on other sites More sharing options...
koencalliauw Posted April 26, 2006 Share Posted April 26, 2006 Could you give us some code to get a better understanding of what you're doing?Koen. Quote Link to comment https://forums.phpfreaks.com/topic/8504-how-to-detect-invalid-jpeg-format/#findComment-31128 Share on other sites More sharing options...
koencalliauw Posted April 26, 2006 Share Posted April 26, 2006 to previous function: maybe add an if(file_exists($image)) too. Quote Link to comment https://forums.phpfreaks.com/topic/8504-how-to-detect-invalid-jpeg-format/#findComment-31129 Share on other sites More sharing options...
miob Posted April 27, 2006 Author Share Posted April 27, 2006 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 thisif ( ! 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.. Quote Link to comment https://forums.phpfreaks.com/topic/8504-how-to-detect-invalid-jpeg-format/#findComment-31175 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.