+ Reply to Thread
Results 1 to 3 of 3

Thread: Get filesize of external/ remote image

  1. #1
    learning_brain is offline x10 Sophmore learning_brain is an unknown quantity at this point
    Join Date
    Apr 2010
    Location
    UK, Midlands
    Posts
    170

    Get filesize of external/ remote image

    This is an interesting one.

    I have an image crawler (external sites) that gets image size no problem, but filesize is proving tricky.

    I'm getting errors with both filesize() and stat() - presumably because I'm not reading from a local directory.

    I have two crawl systems - one for images directly (simple) and one for images embedded within html based pages (CURL/DOM method)

    My crawl bot is now a bit slow due to calls for getimagesize() and the CURL isn't too fast either, so I don't really want to slow it down further.

    Any ideas?

  2. #2
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Get filesize of external/ remote image

    Unless you're already GETting the images with HTTP, issue a HEAD request. The Content-length header in the response is the size of the image data. If you're GETting the images for other purposes, just use the Content-length from the existing query.
    Last edited by misson; 01-22-2011 at 05:52 PM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  3. #3
    learning_brain is offline x10 Sophmore learning_brain is an unknown quantity at this point
    Join Date
    Apr 2010
    Location
    UK, Midlands
    Posts
    170

    Re: Get filesize of external/ remote image

    Fantastic! - Thnaks Misson.

    Due to the number of images already obtained, I've written a separate page on cron that does just this.

    As my crawler also harvests embedded images, it was tricky to do this as the cURL is for the main page, not each image, but the new page resolves all these issues.

    WOW it's fast!!!!

    Thanks again.

+ Reply to Thread

Similar Threads

  1. Which External HDD Should i Buy?
    By focus in forum Computers & Technology
    Replies: 12
    Last Post: 01-30-2011, 01:51 AM
  2. 2 mb filesize limit?
    By wild_korun in forum Free Hosting
    Replies: 23
    Last Post: 07-09-2009, 11:19 PM
  3. External HD
    By diabolo in forum Computers & Technology
    Replies: 1
    Last Post: 11-06-2008, 03:17 PM
  4. External CSS
    By Ryuji666 in forum Programming Help
    Replies: 11
    Last Post: 08-08-2008, 02:33 PM
  5. External HDD?
    By akami50 in forum Computers & Technology
    Replies: 3
    Last Post: 06-21-2007, 06:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers