On Mon, Feb 4, 2013 at 6:32 AM, Spencer Summerville <[email protected]> wrote: > Hello, there are a lot of solutions to resizing images in Django. I commend > you for wanting to create your own solution, but one of the greatest things > about Django is that there's tons of projects that people have made that > solve your problems and usually there's enough of them that you can find one > that implements itself in a way that lets you do what you want to do. I'm > not a great programmer and usually these modules are taken from websites > that in order to function, they have had to work properly in an environment > where anything can go wrong. > > In my own experience, sorl-thumbnail has never let gotten in my way, it lets > you do what you want and if you want to do something special you can easily > write your own functionality. Don't want to use PIL? Use ImageMagick or > write your own class. Have some sort of radical key value cache that nobody > has ever heard of? Write your own class. Do you want to generate thumbnails > in a batch process or in the model or in the template? sorl-thumbnail lets > you choose what you want to do. >
+1 for sorl. I have been using it for a while now with no significant problems, and has made thumbnail generation a non-issue. Sorry for the slightly off-topic statement here, but since we're talking about Sorl :) - the one problem I've had is this: In general, I want images to be resized in the format the user uploads them - i.e. if a user uploads a PNG, I want the thumbnail to be a PNG, and if the user uploads a JPEG, I want the thumbnail to be a JPEG. It seems a bit silly, but I have not found a way to do this - I set an option in settings.py for THUMBNAIL_FORMAT = "PNG", and then all the thumbnails are PNG, which is non-optimal. And if I set the format to JPEG, it will take uploaded PNGs with transparencies and convert them to JPEGs without transparency, which is, again, unacceptable .. I had looked around a fair bit in the docs, etc. but did not find a way to specify something like "keep format of uploaded image" - this was some time ago, though, so I'll check again - if anyone has dealt with this, though, would love to know how :) Cheers, Sanjay > https://github.com/sorl/sorl-thumbnail > > > On Saturday, February 2, 2013 12:33:36 PM UTC-8, nYmo wrote: >> >> Hi all, >> I'm new to django and also python but have already some programming >> experience. I'm currently creating my first application in django and get >> stucked because I'm looking for the best way to resize uploaded images. >> I'm already so far that I can upload/delete/update my images and show them >> in my view. Now I want to resize the images for my view and thought about >> the best way? >> >> First question: Is it possible to resize the images on the fly? For >> example I uploaded an image in 1920x1080px and now want to transform it to >> 400x200 or something similar when the view is being loaded? Is this a >> convenient way in django or not? >> >> The only other way in my opinion could be to resize the image during the >> file is being uploaded. What I don't like about this is that I have more >> than one copy of one image only because of different image sizes. >> >> Any other thoughs? >> >> I know that there are some nice packages out there where such problems are >> already solved. But since I'm new to django I want to learn by myself how to >> accomplish the basic stufff :) >> >> Thanks in advance >> >> Regards nymo > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/django-users?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.

