How can php efficiently get remote picture information?

Source: Internet
Author: User
Tags echo date fread unpack

  
   

如下,我有一个页面,要展示图片信息,但getimagesize时间太长了,有其他高效的方法吗?
我是获取图片信息,不是查看存不存在

Reply content:


  
    

如下,我有一个页面,要展示图片信息,但getimagesize时间太长了,有其他高效的方法吗?
我是获取图片信息,不是查看存不存在

The problem is this. This thing for PHP is definitely a pit.
Traffic up, the image source station is not stable, network problems, minutes to kill the server.

Can ask the front-end great God there is no plan, or compromise method.

If not, you can build a table in the database to maintain a picture information data.

Then when there is a picture to join, the first to determine whether the table has data, if not to get the size of the picture into the table, and then do the back operation.

When the page is displayed, look it up directly.

Here does not say cache, do not say the queue, do not say the picture localization (instead of using his station picture), because it seems that these will greatly increase the complexity, when necessary to reconsider.

V2 There is no great God in the station has proposed a solution?
Http://v2ex.com/t/286977#reply17

Getimageinfo try it.
GetImageSize time is too long, probably because your bandwidth is too low, or the picture server slow response speed caused by

I copied a comment.
GetImageSize

As noted below, getimagesize would download the entire image before it checks for the requested information. This was extremely slow on large images that was accessed remotely. Since the Width/height is in the first few bytes of the file, there are no need to download the entire file. I wrote a function to get the size of a JPEG by streaming bytes until the proper data are found to report the width and Hei Ght:


    
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.