Uploading JPEG image problem

135 views
Skip to first unread message

Rodney Topor

unread,
Sep 10, 2008, 10:21:04 PM9/10/08
to Django users
I've installed the Python Imaging Library (PIL) so that I could upload
and display images (for the first time). Everything works fine when I
upload PNG or GIF or TIFF files (from my Mac), but whenever I try to
upload any JPEG file, form validation gives the following error:

Upload a valid image. The file you uploaded was either not an image or
a corrupted image.

Is this a problem with PIL, or do I need to do something more complex
in my view than:

form = MessageForm(request.POST, request.FILES)
if form.is_valid():
form.save()

And by the way, what is the recommended way to resize images to a
desired maximum size after uploading? E.g., using an appropriate PIL
function?

Thanks,

Rodney



TiNo

unread,
Sep 11, 2008, 3:34:40 AM9/11/08
to django...@googlegroups.com
In your PIL installation, you need to tell PIL where to find the JPEG decoder (which you probably need to install first)

or google for "mac os x jpeg pil"

Gremmie

unread,
Sep 12, 2008, 9:18:33 AM9/12/08
to Django users
On Sep 10, 9:21 pm, Rodney Topor <r.to...@gmail.com> wrote:
> And by the way, what is the recommended way to resize images to a
> desired maximum size after uploading?  E.g., using an appropriate PIL
> function?
>

I can't directly answer that, but you may want to check out the
Photologue application. It makes working with images in django a
breeze. You can define a set of sizes and Photologue will
automatically resize your images if you request a picture in one of
your defined set of sizes.

Rodney Topor

unread,
Sep 12, 2008, 11:52:32 PM9/12/08
to Django users
Thanks TiNo and Gremmie.
Rodney
Reply all
Reply to author
Forward
0 new messages