Results 1 to 4 of 4

Thread: Is getimagesize efficient??

  1. #1
    Join Date
    May 2009
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Is getimagesize efficient??

    HI,
    Please excuse if similar issue has been posted earlier.

    I want to check if a remote image exists or not.
    say if url is http://example/image.png
    and no image exists there, then...??

    Earlier I was using @getimagesize function, but later on found this comment saying that it makes server slow for on large images.

    http://www.php.net/manual/en/functio...size.php#88793

    I don't know if the solution mentioned in that comment is correct rather efficient?

    Is there any other efficient, fast, small solution for this?

    Thanks in advance...
    Regards

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    No, not really. Anything with images will be somewhat inefficient. You could instead just verify that the file exists and has a valid extension for images like .jpg but that won't guarantee the file is valid. It would work in most cases though.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    The @ is inefficient. You should suppress errors via your php.ini instead.

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    True, but that will suppress all errors: for this sort of test, sometimes you must suppress that to avoid a warning if it fails.

    Also, the efficiency lost from the @ compared to the time it takes to process getimagesize() would be insignificant.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •