2

Background: I have to upload images from users.

Problem: The images need to be re-sized so that I don't end up with huge images on my disk. This re-sizing should happen just after the image is saved.

I have checked the following code

Django Snippet for image scaling

But couldn't use it directly, as the windows path of the image was giving a issue. Is there a simple way in which the scaling can be done. Are there any python or django modules which can directly be used for this ? If yes which will be the most optimized one ?

Akash Deshpande
  • 2,583
  • 10
  • 41
  • 82
  • Check this question which is almost same. http://stackoverflow.com/questions/9549059/sorl-thumnail-resizing-and-saving/9555764#9555764 – Zubair Afzal Mar 06 '12 at 07:01
  • 1
    sorl-thumbnail is a django app. You can install it through pip easily.Documentation: http://thumbnail.sorl.net/ – Zubair Afzal Mar 06 '12 at 07:34
  • "But couldn't use it directly, as the windows path of the image was giving a issue." will you be using windows when it comes to production? – Matt Seymour Mar 06 '12 at 17:18

1 Answers1

2

Make use of the Python PIL library. With this library you can manipulate images and make the changes you require. There are loads of examples of using PIL over the net.

I would recommend you using the PIL library and writing your own code as it can be a lot easier than trying to get third party libraries working (personal experience).

Matt Seymour
  • 8,880
  • 7
  • 60
  • 101