Forum Moderators: coopster

Message Too Old, No Replies

Check to see if IMG exist at Amazon

Check to see if image exist at Amazon

         

captlonestar

8:01 pm on May 2, 2005 (gmt 0)

10+ Year Member



Im trying to check if a textbook image exist at Amazon.com. I use the link below to display the textbook img by the particular isbn #.

<img src="http://images.amazon.com/images/P/<?php echo "$isbn";?>.01.MZZZZZZZ.jpg">

I have tried using the code below but it does not work because Amazon's image server returns a 807 byte image (looks empty) when it is accessed. Unfortunately I think this code requires a 404 response. Any ideas?
Thank for your help

<?php
//check if image exists
if($img = @GetImageSize("http://images.amazon.com/images/P/echo '$isbn';.01.MZZZZZZZ.jpg"))
{
echo "image exists";
}
else
{
echo "image does not exist";
}
?>

jusdrum

8:08 pm on May 2, 2005 (gmt 0)

10+ Year Member



Your code may be the culprit. I can make your URL scheme work. If you go to [images.amazon.com...] you will see an image for the PHP Cookbook. Try changing your code to:

$isbn = 1565926811;
if (@getimagesize("http://images.amazon.com/images/P/" . $isbn . ".01.MZZZZZZZ.jpg"))
{
echo "Image exists";
}
else
{
echo "No image found";
}

captlonestar

8:19 pm on May 2, 2005 (gmt 0)

10+ Year Member



$isbn = 1565926812;
if (@getimagesize("http://images.amazon.com/images/P/" . $isbn . ".01.MZZZZZZZ.jpg"))
{
echo "Image exists";
}
else
{
echo "No image found";
}

Ya, I see what you mean.. but if you change the ISBN # to a ISBN that does not have a picture.. It still replys that the image exists which makes it useless. I changed the isbn in the code above to a book with no picture..

Is there anyway to check for an 807 byte image? If I could do that I may be able to get this to work.

jusdrum

8:54 pm on May 2, 2005 (gmt 0)

10+ Year Member



When I retrieved the isbn you gave above, it returned a 1x1 pixel image. How about making it check the width of the image, and if it returns greater than 1, it's considered valid?

$isbn = 1565926812;
list($Width) = @getimagesize("http://images.amazon.com/images/P/" . $isbn . ".01.MZZZZZZZ.jpg");
if ($Width > 1)
{
echo "Image Exists";
}
else
{
echo "No Image Found";
}

captlonestar

9:44 pm on May 2, 2005 (gmt 0)

10+ Year Member



Your the man... That was a great Idea.. Thanks for the Help!