Best way to identify valid image file
Posted: 2009-04-17T14:12:29-07:00
I need a solid way to identify if an image is a valid, uncorrupted image that is tested in the following formats:
.jpg, .png, .bmp, .tiff' .tif, .jpeg, .gif, .eps, .pdf, .ai, .psd
I have been using this in PHP
Is there a better, faster or easier way? Without taking a lot of system resources.
Thank you,
~Shawn
.jpg, .png, .bmp, .tiff' .tif, .jpeg, .gif, .eps, .pdf, .ai, .psd
I have been using this in PHP
Code: Select all
// Make sure image is actually an image
$limit = '-limit memory 16 -limit map 32 -limit area 64 -limit disk 128';
$call = "/usr/bin/identify $limit {$_FILES['Filedata']['tmp_name']}";
exec($call, $id_output, $id_status);
if($id_output[0]) { // Checks for identifying output string
doWhatever();
}
Thank you,
~Shawn