i have a webservice that generates an image using 6 different parameters. the process lasts 1 second.
i use the functions ImageCreateFromPNG,ImageCopy and ImageJPEG
Now i want to speed it up.
the idea is to save the images that were already generated on the server and use them if they are already there by using a name with the 6 parameters.
My question is:
Are there better ways to store the image than saving the jpg-files in a directory on the server ?
(because there are 6^6 (imho 6 to the power of 6) combination possibilities)
bye jogi
Store the images in good old fashioned file form on the server.
Storing images in a database is not efficient and will likely end up with more pain than it is worth. Store the images in a folder (perhaps even their own little folder) and link to them as per normal. This will allow users to cache the images easily and will be the least impact-heavy on your server.
It will take much less resources to serve a file from a file structure than to query a database, pull the info out, tell the user what that data is and do it many times a second/minute/hour/day.
Now, on the other hand, if these are large images and take a heck of a lot of space, you might consider generating them dynamically on the fly until you can afford more drive space, but I would suggest the first option if you can.
Lastly (and possibly most importantly – think outside the box), I don’t know what these images are like, but you might also consider other methods of creating them. Can they be tiled for example? Rather than storing hundreds of images, can you make those hundreds of images from say 10 segments? You might even be able to send them to the client as they are without joining them up and simply arranging them on the page so that they LOOK like they are one image – but that’s just spitballing now.