thumbnails and rackspace files

89 views
Skip to first unread message

garagefan

unread,
Jan 19, 2011, 2:37:06 PM1/19/11
to Django users
setting up django-storages was simple... using rackspace's python API
to send an image to my container... met with some troubles (broken
pipe error on code that worked).

however... on the save of my gallery application i'm creating
thumbnails. this is easy to do with my custom field... normally.
django-storages doesnt work so well with this. So i need to come up
with a work around. My first thought was to grab the image from the
CDN server, open it with PIL, crop and create the thumbnail, save it
to my server, push it to my files server then delete the files on the
working server.

this seems like a lot of processes to be running and there has got to
be a simpler way. and my idea on injecting this code would be into a
signal, pre save, assuming that the file is written to the files
server prior to the item being saved. currently i have a custom field
extending the ImageField w/ an attr_class that extends the
ImageFieldFile. I'd prefer to run everything in the attr_class if
possible and would prefer to stay away from grabbing the image from
the public url and do modify the image and create the thumbnail along
the way.

i suppose i could go the simple route and and use css to alter the
main image.

Michel Thadeu Sabchuk

unread,
Jan 19, 2011, 2:56:05 PM1/19/11
to Django users
Hi,

> setting up django-storages was simple...

I recommend you to use django-cumulus [1] rather than django-storages.
The first one is a rewrite made by the same author.

> however... on the save of my gallery application i'm creating
> thumbnails. this is easy to do with my custom field... normally.
> django-storages doesnt work so well with this. So i need to come up
> with a work around. My first thought was to grab the image from the
> CDN server, open it with PIL, crop and create the thumbnail, save it
> to my server, push it to my files server then delete the files on the
> working server.

Do you know django easy-thumbnails [2]? I think it will fit your
needs.

Feel free to contact me on private to share rackspace cloudfiles
specific experiences ;)

Best regards.

[1] https://github.com/richleland/django-cumulus
[2] https://github.com/SmileyChris/easy-thumbnails

--
Michel Sabchuk

garagefan

unread,
Jan 19, 2011, 3:57:30 PM1/19/11
to Django users
easy thumbnails certainly does a decent job of creating thumbnails.
I'm not too fond of having a template tag do that though... it
basically does what i'm think of doing, but in a different area. it
also doesn't send the thumbnail over to cloudfiles, which is really
what i'm wanting to do, and without running syncstatic.

i'll take a look through easy thumbnail and see if there are any clues
for me... i should just have to override it's save functionality to
get what i need.

thanks for cumulus! its nicer having a specific backend for this
instead of one that is useful for multiples.. at this time anyway.

Michel Thadeu Sabchuk

unread,
Jan 20, 2011, 1:16:47 PM1/20/11
to Django users
Hi!

> basically does what i'm think of doing, but in a different area

I make the thumb generation using the template tag but AFAIK easy
thumbnails have a ThumbnailerImageField that can be configured to pre
generate the thumbs.

> also doesn't send the thumbnail over to cloudfiles, which is really
> what i'm wanting to do, and without running syncstatic.

Easy thumbnails connects with the storage and then the file is sent to
cloudfiles... You can use similar approach, anyway, I would give a
change to easy thumbnails ;)

> thanks for cumulus! its nicer having a specific backend for this
> instead of one that is useful for multiples.

The cumulus package and storage's mosso backend is the same software,
the cumulus is a rewrite of it. Someday the storages backend for
cloudfiles would be updated with cumulus news, but today, the cumulus
is the one actively updated.

Best regards,

--
Michel Sabchuk
Reply all
Reply to author
Forward
0 new messages