django-imagekit
django-imagekit copied to clipboard
Rotating and updating cached
What is the best way to rotate an image and have it quickly update the cached images? What I have works but if you have a 'best practices' way of rotating I'd love to hear it. With the old imagekit I would create a new file and name for the rotated image, update the db to point to the new file and delete all the cached and original images with os.remove(self.large.path).
Sorry, I'm not sure I'm getting the scenario. Do you want to just have a rotated version of an image that a user uploaded? If that's the case, you can just update your spec and IK3 will automatically create a new image.
Sorry, I didn't explain it well.
Sometimes images are uploaded wrong and require rotation after the other cached images have been created. I gave the user a rotation tool to fix the photo. I need all versions of that image to be rotated too. Right now, I'm rotating and updating a way that probably wastes resources even though it is working. If I rotate the original and delete all cached images that will correct things internally but I still have the issue of the browser caching the images based on the name. So even though the image is rotated the refreshed page will show the old image. I fixed this problem by giving the image a new name and updating the database to point to the newly named rotated file. I'm hoping to find the best way to handle rotating images and making sure the browser gets the newly updated one. What I have works but I'm not sure it's the best way of handling it. I'm also not sure if my way of deleting the cached images works anymore with IK3.
In the model I call something like this to delete cached images. Does this still grab the correct location of the cached image?
os.remove(self.large.path)
Hopefully that helps explain it a bit better.
On Aug 19, 2013, at 1:43 PM, Matthew Tretter [email protected] wrote:
Sorry, I'm not sure I'm getting the scenario. Do you want to just have a rotated version of an image that a user uploaded? If that's the case, you can just update your spec and IK3 will automatically create a new image.
— Reply to this email directly or view it on GitHub.
I see. If you save the original image with a new name, IK3 will automatically generate the new versions from the updated source.
What's the correct way to change the name?