0

Possible Duplicate:
php get all the images from url which width and height >=200 more quicker

I am writing a PHP script to fetch images from URL. But I only want to display images if they are above a certain size/ or [length/width]. I tried getimagesize(), but it is very slow, especially with multiple images.

I read about using cURL. But not sure, how to get the file size or dimensions of images, when the input is a url string. I read these and more.

http://forums.phpfreaks.com/topic/232507-faster-solution-to-check-image/

Output external image with cURL, but how do you change the width of the image?

Get image dimensions with Curl

Would appreciate help, to get image size/ dimensions.

Community
  • 1
  • 1
aVC
  • 2,254
  • 2
  • 24
  • 46
  • @Baba thanks, let me try it out. – aVC Oct 27 '12 at 23:35
  • @Baba Do you know, why the script crash on some url such as http://www1.macys.com/shop/mens-clothing/mens-athletic-wear?id=59165&edge=hybrid&cm_sp=us_men%27s-men%27s-apparel-activewear-_-t-shirts#!fn=APPAREL_TYPE%3DT-Shirts%26sortBy%3DORIGINAL%26productsPerPage%3D40&!qvp=iqvp – aVC Oct 28 '12 at 03:03

1 Answers1

0

Are you serving these images yourself ? on your server/app ?

If so, you could put the width / height information in some custom HTTP Headers in your images (you'll need to handle the access to your image by whatever PHP solution that modify headers before outputing image.. with good cache settings).

This headers can be based on width/height calculated at upload for example and stored in database.. so it will need one and only getimagesize for ever..

After that, in curl just check the headers (without downloading the file). If the width / height match your requirement, you can then really download it.

Jscti
  • 14,096
  • 4
  • 62
  • 87
  • No I am not serving these images. i am fetching them from any given url. I tried get_headers() but still seems slow. – aVC Oct 27 '12 at 23:34
  • then, you're dead. Try indexing it periodically maybe – Jscti Oct 27 '12 at 23:36