MockY Posted July 14, 2011 Share Posted July 14, 2011 I'm on the last leg of my picture library application. My initial idea was to have only one copy of the picture on the server and then display the desired size of it on the fly (thumbs or slightly smaller version) using ImageMagick. The problem is that the generation of the cached picture is extremely slow. If the user opens up a "folder" that has 20 pictures in it, it will take at least that many seconds to display them, if not more. Obviously, next time a user goes in there, the cached pictures are used and display is instant. But this lag is not desired. I'm using the function found at joedesigns.com and the server has hardware that includes an i7 cpu and 4+GB or ram. I noticed that it is slightly faster to use -scale instead of -resize, but it is still very slow. So I figured that I would create thumbs at the time when pictures are added to the library, and then simply display the thumb that was generated wherever it should be displayed. That way, even the first user that goes into the "folder" will have it displayed instantly instead of forcing the script to generate the thumbs at that time. The problem with that approach is that if the user uploads a picture that needs to be rotated, it will have to be rotated via the admin interface. I will then have to rotate both the original and the thumb, which I have something that works. But users browsers stores a cached version of this image itself, so because the rotated image has the same name, the non rotated picture is what the browser will display. Even a redirect wont solve this problem. I can provide the code that I am currently using, but since it is not working properly, I figured I would ask if any of you have a greater solution for my problem. Not necessarily code, but how to approach this dilemma. Quote Link to comment https://forums.phpfreaks.com/topic/242010-want-some-advice-on-how-to-handle-pictures/ Share on other sites More sharing options...
requinix Posted July 14, 2011 Share Posted July 14, 2011 The server and browser could be using Expires caching headers, which means the browser won't even bother checking if the image has updated until the expiration date has passed. A quick solution would be to change the name of the thumbnail when it's altered. A smart solution would be to set up the server to use different headers (such as Last-Modified and ETag) instead of Expires... I tend to prefer the latter, but they're both reasonable solutions. Quote Link to comment https://forums.phpfreaks.com/topic/242010-want-some-advice-on-how-to-handle-pictures/#findComment-1242900 Share on other sites More sharing options...
MockY Posted July 16, 2011 Author Share Posted July 16, 2011 I went with the first option. Once the thumb is rotated, I change the name of it. All thumbs ends with _thumb000001.jpg and I simply increase that number with one each time it is rotated. Excessive with so many numbers in the end, but I wanted to be truly sure I never get the same name again. Thank you for the advice. Quote Link to comment https://forums.phpfreaks.com/topic/242010-want-some-advice-on-how-to-handle-pictures/#findComment-1243538 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.