Well, you kind of stopped just when things were getting interesting with your code, there 🙂, but if you're saying that
$output = shell_exec("identify -format %m $image");
if ($output != "JPEG")
{ echo "AARGH!";
exit();
}
will output "AARGH!" and stop running (try it as a wee test), then the only answer can be that $output does not equal JPEG.
So change the above test code slightly:
$output = shell_exec("identify -format %m $image");
if ($output != "JPEG")
{ echo "<pre>------\n[$output]\n------</pre>";
exit();
}
and see just what $output is (the [] and ------ bits are there so that you can see if there are any leading or trailing spaces or newlines or whatnot). What you want to see (i.e., if $output really does equal JPEG) is
[code]
[JPEG]
[/code]