I'm working on a photography website in Django.

Because the site is “responsive”, we pre-generate numerous sizes of each image using set aliases. In particular, 7 images with a variety of widths starting with 960 to 3,840 pixels wide in 480px increments. These images will be used when a photo is shown full-screen (as in, not in a list-view).

The site is also built for HiDPI/Retina displays/devices. So, we'd like to use the setting: THUMBNAIL_HIGH_RESOLUTION to automatically prepare the @2x versions of some of the aliases, but most notably, NOT for the aliases used to create the range of 7 images used for the full-screen images above.

As this project is meant to show off the work of a photographer, we're using rather high quality settings, so each image starts out at roughly 3840x2160 pixels in size and, through our pre-generation becomes approximately 50MBs of JPGs. Unfortunately nearly 50% of this is pure waste, because we only use the @2x versions on an image when we show lists or collections of images on a page. These are generally only 300px/600px wide and are relatively tiny compared to our "full screen" image sets.

We've considered disabling THUMBNAIL_HIGH_RESOLUTION and just creating new aliases for the @2x versions, but it isn't clear how to generate the correct filenames with an alias.

So, how can we pre-generate HiDPI/Retina images with the standard @2x (or _2x) infix for just SOME of our aliases?

UPDATE: This is now a feature of easy_thumbnails! In aliases you can use HIGH_RESOLUTION: False to disable their creation, or HIGH_RESOLUTION: True to force them. Thanks @ChrisSmiley!

有帮助吗?

解决方案

In easy-thumbnails-1.3, the @2x infix currently is hard-coded, but in the next version, users may choose another infix through a configuration setting. Have a look at this pull request for details.

To answer your second question, currently it is not possible to generate Retina thumbnails only for certain entries. easy-thumbnails has a all-or-none policy, but this in theory, could be changed.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top