Ticket #693 (new defect)

Opened 4 years ago

Last modified 3 years ago

Image gallery produces thumbnails without actually changing size of produced images

Reported by: rspivak Assigned to: ogrisel
Priority: P3 Milestone: CPS 3.5.0
Component: CPSDocument Version: 3.3.3
Severity: normal Keywords:
Cc:

Description

Generated 'thumbnails' are produced with <img /> tag with given height and width, but that doesn't influence actual size of produced images that leads to long loading of gallery in case there are lots of big images.

This can be solved by on-fly thumbnails generation with PIL(falling back to original image size in case PIL is absent). I have created branch for this purpose: rspivak-imagegallery-branch.

Some logic will be added to new Image class. The trickiest part seems to be migration of class names in ZODB, as currently objects with portal type 'Image' are instances of Products.CPSDocument.CPSDocument.CPSDocument class.

Change History

08/03/05 11:52:25 changed by rspivak

  • milestone changed from CPS 3.3.5 to CPS 3.3.6.

09/15/05 19:59:23 changed by fguillaume

  • milestone changed from CPS 3.3.6 to CPS 3.4.0.

Ruslan, what's the status of this? You shouldn't keep branches too long.

09/15/05 20:23:21 changed by ogrisel

  • owner changed from rspivak to ogrisel.

I'll try to integrate it to trunk tomorrow as I need it for a customer project.

10/07/05 16:48:54 changed by ogrisel

I have a look at your branch but I don't really like it, sorry ;)

I would like to find a generic solution to generate thumbnails on the fly when PIL is available however, it would be better if we could do it for all image document, not only those in the image gallery. It would be nice to use it in the preview occuring in the folder listing template (source:CPSDefault/trunk/skins/cps_default/content_lib_info_detail.pt).

Furthermore, we need to make it RAM cacheable so as the thumbnail generation is not done at each view request.

I don't know if you should do that at document level (in your branch you create a Image class that derives from CPSDocument) or at some image widget level. I find the current image widget loosy since it does not keep the original file when resizing is allowed and thus resizing can only be done at upload time. The photo widget is a bit better but it only has a single persistent thumbnail which is not enough.

Maybe we sould derive the OFS.Image.Image class to add a method getThumbnail(self, max_height, max_width, keep_ration=True) and use that class instead of OFS.Image in CPSSchemas. But remember, we need to make the thumnails generation RAM cacheable in some way.

10/07/05 17:28:40 changed by rspivak

It was highly tentative and i thought you already took over it to mercilessly refactor :)

Making thumbnails generation stuff generic(to be applicable as you mentioned also in folder listing, for example) and cacheable would be great, of course.

10/07/05 19:13:13 changed by ogrisel

I was wondering if there already exists such a PIL based generic Zope Product before reinventing the wheel. I did some googling but I could not find anything.

So the plan is to write a new Zope product (with no CPS/CMF dependency) to implement the PILImage class that derives from the OFS.Image.Image class and overrides it's default ZCacheable_* methods to take care of the thumbnails as well.

Furthermore, we need add a default RAMCacheManager somewhere in a default CPS instance and find a way to make CPS (maybe the image widget) update the associations automatically each time an image field is updated.

10/10/05 12:41:20 changed by lregebro

The EasyImage? product I did for EasyPublisher? years ago did thumbnail resizing with PIL. It's not particularily difficult, but still, there is code you can steal: http://www.easypublisher.com/

10/26/05 14:51:56 changed by lregebro

I also think that instead of using caching (which just is problematic) it might be easier to just save the preview? Doing something in computeDependentFields, for example. But then you need a way to set the preview-size on the fild then, which maybe isn't the most logical place to put it. Or it can be done during the validation, in which case the preview-size can ge defined as properties on the ImageWidget?.

10/26/05 15:09:47 changed by jmorliaguet

Saving a preview in the ZODB is also called "caching" (persistent caching) which also requires a method for invalidating outdated previews and managing a collection of thumbnails of different sizes (some sort of garbage collector). RAM-caching makes garbage collection slightly easier.

The question is whether to do the 100% on-the-fly image conversions or to save the resized images in a cache.

11/22/05 19:10:00 changed by gracinet

Seen on boxless branch, but shouldn't make any difference: no resizing at all for thumbnails. In other words, it's broken.

11/30/05 21:58:20 changed by fguillaume

Ok,

  • thumbnails should be computed when the image is uploaded
  • thumbnail size should be a parameter of the gallery

Has there been any progress on this front?

12/22/05 20:08:32 changed by ogrisel

I tend to prefer JMO's approach with RAM caching because there is no dataloss + it allows to change the thumbnail size afterward (a timeout base RAM cache will act as a natural garbage collector for useless thumnails).

What about having some kind of generic Zope3 based 'PILCachingThumbnailer' adapter in CPSUtil that could be used by the ImageGallery? and other documents/portlets/widgets?

01/03/06 19:58:06 changed by fguillaume

  • milestone changed from CPS 3.4.0 to CPS 3.4.1.

03/31/06 16:36:23 changed by ogrisel

Interesting layout sample: pure CSS imagegallery laying with zooming on thumnails.

http://www.cssplay.co.uk/menu/lightbox.html#Trees

05/16/06 17:11:24 changed by sfermigier

  • milestone changed from CPS 3.4.1 to CPS 3.4.2.

Can we implement a quick solution soon?

05/19/06 16:57:44 changed by sfermigier

  • milestone changed from CPS 3.4.2 to CPS 3.4.3.