// check if image is corrupted
if (!$img = @imagecreatefromstring(file_get_contents("..."))) {
die(error_get_last()['message']);
}
// http://stackoverflow.com/questions/24214685/how-to-catch-invalid-image-when-using-php-imagecreatefromstring
// http://stackoverflow.com/questions/1401527/how-do-i-programmatically-check-whether-an-image-png-jpeg-or-gif-is-corrupte