在aws S3上检查文件是图像还是xml

I need a away to see if an image exist on the S3 cloud, I'm build an APP to sort of merge data from local to the web, it is actually simple and I almost done, from the local app I'm getting a json post... so on that json I'm getting an image name "prety_image.jpg" which then is save to the DB, but before i save it I need to check if that image exist in the S3 cloud, I have the S3 url ... //foo.cloudfront.net/ and to display the image all I do is add the name of the image... for what I have seen is that if the image do exist it display the image.. but if the image doesn't exist I'm getting an xml file

<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>13A57760</RequestId>
<HostId>3/uj7Ro77bGnjzGZVABUXvVVg4=</HostId>
</Error>

so what I want is that if i'm getting this error then save a blank image if not then just save the image... but I don;t know how to do it... I haven't use aws sdk, i downloaded but I don't know what to do with it... I have use other SDK's but AWS SDK is just way to much for my brain..

I find a solution without the use of AWS SDK, is actually very simple...
This function is inside my class but I'm just gonna put it here...

function httperr($url)
    {
        $headers = get_headers($url);
        return substr($headers[0], 9, 3);
    }

The I just call it like this

if (intval(httperr(S3AWS . $img)) === 200) {
    $image = '<img src="'.S3AWS . $img.'" > <br>- Exist';
} else {
    $image = 'No image here...';
}

the S3AWS is the url and the $img is just the name of the image... so if the header is ok 200 then the image do exist if not then there is no image, and is working just fine...