[Answered ]-Image upload and Manipulation in Django

2👍

Uhm, you need to be more specific with your question, but we’re doing the same thing and the workflow is as follows:

1) You get the file handle on file upload from request.FILES and store it somewhere on your local filesystem, so you don’t work on stream — which is what i would guess is causing your problems

2) You use PIL (or better yet, Pillow) to manipulate the image on the FS, do resizing, thumbnailing, whatever.

3) You use Boto (http://boto.cloudhackers.com/en/latest/) to upload to S3, because Boto takes the handling of AWS out of your hands.

It’s quite straightforward and works well

0👍

Did your PIL installation find the correct libraries when compiling. You might try uninstalling it and reinstalling it with pip.

Look towards the end of the compilation output and there is a section detailing which libraries are available.

I spent a long time trying to find out why it wasn’t discovering my jpeg, png/zip libraries before realising it was looking in the wrong places.

In Debian, I needed to download the PIL/Pillow source and add:

_add_directory(library_dirs, "/usr/lib/x86_64-linux-gnu")

to the ‘standard locations’ section of the settings.py file – this is the directory my libjpeg.so was installed to

I then needed to run

python setup.py install

and check the output to make sure it had found the right library

Hope this helps

0👍

I finally figured it out. The problem was that it was a stream that the uploaded file is stored into, so everytime i read the file it would reach the EOF.

The only and best way out is to seek(0) everytime we read the file.

This is also needed when playing with other files also in django.

Leave a comment