Reputation: 1990
Good day,
I have a question here. I am trying to fetch image from few external sites as i'm trying to develop link sharing website for my project.
Right now i'm stuck at this part,
getimagesize
It took basically > 100 seconds to get width and height of remote images. Is there any alternative method to reduce the time?
I tried sites like digg, facebook, image from external site appear very fast. How do they achieve it with any examples?
Thank you for your help.
Upvotes: 1
Views: 6802
Reputation: 3251
Getimagesize downloads the whole file before it evaluates its contents. It's a better idea to use some kind of script which will get a few thousand bytes from the given file and get the width/height from the JPEG/GIF etc. headers.
Check the comments at this url:
http://php.net/manual/en/function.getimagesize.php
Upvotes: 2
Reputation: 14873
its depend on server of each site , how fast they are responding your request. Everything runs at least as fast on the VPS as it does on the shared account, except for getimagesize() which is vastly slower. Here is quick solution 1. get file on your server using file_get_contents or curl for temporary purpose. 2. get dimension getimagesize 3. delete the file alternative else you can also find some api , where you can submit link or image , they will give info + thumbnails. Info is actually what you are looking for.
Upvotes: 1