Home  >  Article  >  Backend Development  >  How to speed up the download speed when getting (downloading) QQ avatar is very slow?

How to speed up the download speed when getting (downloading) QQ avatar is very slow?

WBOY
WBOYOriginal
2016-07-06 13:51:291663browse

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)
How to speed up the download speed when getting (downloading) QQ avatar is very slow?

I want to download this picture and rename it to jpg format

Reply content:

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)
How to speed up the download speed when getting (downloading) QQ avatar is very slow?

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.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn