user1709301
user1709301

Reputation: 33

php image loading time consumption

I have a products website where in I have around 100 images of high quality. Each image is around 6-7MB in size.

In my database I have stored the path of all the images along with their names. The images are saved in a folder /images/product_name/, But when I go to display these images in a web page, the page takes forever to load. All I do is send the id to the table, get the image paths and display it in the products page.

It would be very helpful if I could get any sort of advice on how to optimize the process.

Upvotes: 3

Views: 651

Answers (6)

transilvlad
transilvlad

Reputation: 14532

Use http://luci.criosweb.ro/riot/ to compress images. It is one of the simple and free tools recommended by Google to compress images.

Also as it was mentioned before make sure the thumbs you send to the listing pages are around 100px and only if the user clicks to zoom in show him the large ones one by one, and still even in the zoom option you should only display a 1000px size image max and that should not have more then 200-500k depending on format and quality.

Upvotes: 0

George Reith
George Reith

Reputation: 13476

From reading your comments I think you are looking for some automated process to optimize the files and serve them at a more decent filesize.

You should take a look at imageMagick or the GD library which allows you to resize images (among many other things - http://php.net/manual/en/book.imagick.php) and optimize them. This can be combined with something like the YUI Image cropper to allow you to choose certain parts of the image to show in the thumbnail.

This is best done at the point of upload so the Server doesn't unnecessarily regenerate the images each time they are requested, and stored under a thumbnail column in the database.

If you must show bigger images I suggest you use a lightbox (see an example here - http://leandrovieira.com/projects/jquery/lightbox/) or similar technique that only loads the larger image when the client requests it.

Upvotes: 1

freaky
freaky

Reputation: 294

reduce the size of the images to a thumbnail and when the user clicks on the thumbnail then load the original file. This can increase the performance.

Upvotes: 0

Omid Kamangar
Omid Kamangar

Reputation: 5788

You should really optimize your images. You can use a commercial product like Photoshop or use a free one like the GIMP to optimize the files.
Loading about 700 MBs of images will take exactly 1 day for me!!

Upvotes: 0

Gung Foo
Gung Foo

Reputation: 13568

The images you send to the client are most likely way too big. 7MB of size sounds very large for a product picture so 100*7MB = 700MB of data transfered if you display all the product images.

If you only need small images, scale them down to some KB's (thumbnails) and use those to display in your table.

NOTE: you can just preprend a prefix like "tmb_" or "tmb_200x200_" to the original filename, and you won't have to touch the paths in the database.

Upvotes: 6

Laurent Brieu
Laurent Brieu

Reputation: 3367

Do you have optimized your images (in term of file size) ? Like on Smush.it for example http://www.smushit.com/ysmush.it/

Upvotes: 0

Related Questions