Forum OpenACS Q&A: storing several sizes of an image in the content repository

I'm working on ec2, a CR and subsite-aware ecommerce package, and I'm debating on how to store images. I'm using ImageMagick to convert product images to several sizes: 600px, 400px, 200px, and 100px.

It appears that using the CR for images would require creating a content item for each image size so four entries per image revision. To me this is alot of overhead for an image.

A store could have millions of products so you could end up with a huge number of entries in the CR, even bigger if you are an ASP with several subsites running off the codebase.

I want to make use of the CR, but I don't want performance to suffer. Any advice?

I'm not sure why you'd use the CR for all deriving image sizes. I'd suggest to store the original image in the CR as a child item of your product and keep the additional images as files on the harddisk (e.g. /www/ec-resources/<revision_id>-<size>.jpg).

But maybe the photo-book developers (Jeff et.al.) can say a little bit more on that matter from past experience.

James,

Photo album does this. Can you tell me what performance problems you think would occur? If you use the filesystem storage method, all the actual image data is stored on the filesystem.

The latest cr_write_content uses ns_returnfile which will cache the data if you have fastpath enabled. (I am not sure of the details of this, but sounds like it could be helpful).

I assume if you have millions of products that your store will have more millions of orders than photos.

You can look at the photo-album package. It creates a cr_item for a photo, and one cr_item for each image size. I believe is has a thumbnail, medium and full size image for each.

Dave