1

I have a php web application which has a gallery.

This gallery uses justified javascript.

Then it uses timthumb.php to resize the images without saving the images in the server.

i would like to know which one would be better..

  1. Loading all the images using timthumb.php

  2. Or saving resized images in the server cache folder and loading all the images from the cache folder.

I have tried these two methods. Strangely 2nd method is slower than first for the first load.

Thank you for all the help.

Lynn

Manthan Dave
  • 2,137
  • 2
  • 17
  • 31
Lynn Rey
  • 231
  • 3
  • 17

2 Answers2

2

Timthumb tends to have security issues and either way image processing requires a great deal of RAM so having cache folders is the best option. Notice that I said folders and not a cache folder. On IIS servers or any windows based server you will run into slowness accessing folders which have more than a few thousand files. Linux is known to have the same problem but not until you have a few hundred thousand files in a folder. Either way, if you're dealing with millions of images it is best to categorize them in some way into separate folders so you don't end up with slowdowns from the OS trying to locate the file.

Ralph Ritoch
  • 3,260
  • 27
  • 37
  • I am on a linux machine. This is a new website. May be in future the image count can grow. I did see that timthumb.php can have security issues and I turned off processing foreign links. – Lynn Rey Nov 29 '16 at 05:10
  • Lynn Rey, serving image files directly vs serving them from a PHP process should always be faster. Having a huge database of files can be an exception to this rule. Server settings could also be part of your issue if you are using server side compression on image files. Compression requires CPU time on the server and on the browser and can cause non-compressed images, such as those from php, to load faster than their compressed counterparts. – Ralph Ritoch Nov 29 '16 at 05:16
  • Thanks Ralph. Looks like I need to check out more regarding the server settings. – Lynn Rey Nov 29 '16 at 05:20
1

Honestly I do not have much idea about timthumb.php.

Although saving the photos in a server cached folder seems to be a better idea, You can save the save the path of the image in your datasource (normally a relational database) , and then while retrieving the photos , extract it from cached folder.

It might be a possibility that your cache is getting reloaded time and again and thats why taking sometime in the first load.

Ankush Tanwar
  • 239
  • 2
  • 4
  • I just created a folder to store these images. It is not getting erased out. But still.. loading images via timthumb.php is faster when compared to disk read. – Lynn Rey Nov 29 '16 at 05:11
  • I think timthumb.php is just a resizing script ...what is the source of your images before it is given as input to the timthumb.php – Ankush Tanwar Nov 29 '16 at 05:45
  • yankianki..yes timthumb.php is a resizing script. Images to this script are already uploaded to the server. – Lynn Rey Nov 29 '16 at 08:49