Reputation: 535
I'm going to have different ways to present an objects image in my templates. Full size, medium size and smaller thumbnails in lists. It's a dynamic structure and needs to be fast for sorting, searching, filtering..
As a beginner I'm thinking of three ways to handle this:
Simply use the image from the image field and change the size in templates with css.
Save different image versions (size) in different fields in the model and in media files.
Create the thumbnails dynamically in the templates with sorl-thumbnail or easy-thumbnails
The thumbnail apps is a bit complicated and would need some extra requirements like PIL and I need to make some choices about caching. Not sure if I win so much performance by going down this path or if there is other smarter ways? Is it better to plan ahead for scaling/performance.
How are you handling thumbnails? And are you using redis or memcached?
Upvotes: 0
Views: 423
Reputation: 8891
First neither redis or memcached handles caching of images. Memcached is a simple key-value store. Redis essentially works as a key-value store but it has support for other types as well. Such as lists. When it comes to caching images you would use something like nginx.
Secondly, the first option is suboptimal if you want your page to load as quickly as possible. As it will need to load a bigger file than necessary. The second and the third option is essentially the same. Easy-thumbnails for example doesn't create thumbnails on the fly in the template. It generates them as needed and then you can access those thumbnails from your static_folder.
If you want to manipulate images, you will need PIL or Pillow if you're using Python 3.
Upvotes: 1