Home >Backend Development >PHP Tutorial >How to speed up the download speed when getting (downloading) QQ avatar is very slow?
Opening the link directly shows that it is very fast, but downloading or obtaining information online is very slow. How can I speed it up?
<code class="php"><?php $url = "http://q.qlogo.cn/qqapp/101327045/D560BE9F90D5B2529BD75F976DDB628C/100"; $t1 = time(); var_dump(@getimagesize($url)); $t2 = time(); echo "<img src='$url' />"; echo $t2-$t1."秒"; ?> </code>
The following is the running result (it took 17 seconds, which is unbearable)
I want to download this picture and rename it to jpg format
Opening the link directly shows that it is very fast, but downloading or obtaining information online is very slow. How can I speed it up?
<code class="php"><?php $url = "http://q.qlogo.cn/qqapp/101327045/D560BE9F90D5B2529BD75F976DDB628C/100"; $t1 = time(); var_dump(@getimagesize($url)); $t2 = time(); echo "<img src='$url' />"; echo $t2-$t1."秒"; ?> </code>
The following is the running result (it took 17 seconds, which is unbearable)
I want to download this picture and rename it to jpg format
This is equivalent to downloading twice. Depending on the speed of your server, it will definitely be slower.
Since you want to get the size, size, and format of the image. Instead of using php, you can just use js to get it. In this way, the calculations are all done on the client side.
If you use this function to obtain remote image information, it will be slower.
You can try to get it with get_file_content
first, save it locally and then imagegetsize
to see if it can be faster.