简体   繁体   English

如何使用php更快地在网站中加载图像

[英]How to load a images in a website faster using php

I am creating an image using the code below:我正在使用以下代码创建图像:

http://php.net/manual/en/function.imagecreatefromjpeg.php . http://php.net/manual/en/function.imagecreatefromjpeg.php

Now, I displayed the image in my webpage, localhost/home.php and fetched the image in here.现在,我在我的网页 localhost/home.php 中显示图像并在此处获取图像。

 <img src="<?php echo  http://localhost/imagecreate.php; ?>" />

and displayed correctly.并正确显示。

However, my problem is that, it takes time to load the website because of that imagecreate script unlike with the usual image below:但是,我的问题是,加载网站需要时间,因为该 imagecreate 脚本与下面的通常图像不同:

  <img src="images/img.jpg" />

Is there any other way to load the imagecreatefromjpeg faster?有没有其他方法可以更快地加载imagecreatefromjpeg

You are dynamically creating an image every time.您每次都在动态创建图像。 So the caching won't work.所以缓存不起作用。 That's why it's taking more time to load.这就是为什么加载需要更多时间。 Better convert the image while uploading, to desired format and save it.上传时更好地将图像转换为所需的格式并保存。 Then load image directly without imagecreate.然后直接加载图片,不用imagecreate。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM