简体   繁体   中英

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 .

Now, I displayed the image in my webpage, localhost/home.php and fetched the image in here.

 <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:

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

Is there any other way to load the imagecreatefromjpeg faster?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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