3

Not sure exactly what I broke. I have an ubuntu natty linux server, and have several virtualenvs on it. Django image upload was working fine on the dev virtualenv, so it was time to get it working in production. PIL was misbehaving there so I tried to uninstall and reinstall several times after fiddling with libjpeg dependencies and ended up following the steps here: http://littlebrain.org/2011/08/21/installing-pil-in-virtualenv-in-ubuntu/

and now image upload is broken in all virtualenvs.

The PIL setup summary says all should work:

--- TKINTER support available
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
--- FREETYPE2 support available
--- LITTLECMS support available

and when I run the following test within the shell it works fine, with both JPG and PNG:

>>> import PIL
>>> import Image
>>> import _imaging
>>> i = Image.open("someimage.jpg")
>>> i
<JpegImagePlugin.JpegImageFile image mode=RGB size=600x599 at 0x9646C0C>
>>> i.load()
<PixelAccess object at 0x2b86510>

however when I try to upload images in the CMS I get the dreaded:

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

Anyone have an idea what could be going wrong?

user573117
  • 91
  • 1
  • 8
  • duplicate? http://stackoverflow.com/questions/1402002/why-cant-i-upload-jpg-files-to-my-django-app-via-admin – Timmy O'Mahony Nov 09 '11 at 01:39
  • 1
    it's slightly different, though they seem similar I don't think we have the same issue. I can't upload PNGs or JPGs, while the above user was not having a problem with PNGs. – user573117 Nov 09 '11 at 01:42
  • 1
    Does the file get uploaded at all? Can you see it in the "upload_to" directory? If not does the webserver have permissions for that directory? – mtnpaul Dec 06 '11 at 15:30

1 Answers1

0

Debugging tip: add some print statements in your code (or add logging) in the place in your code where you're having problems.

import sys
print sys.path
print PIL.__file__
print your_image_object
print type(your_image_object)

Things like that. Perhaps it will pinpoint your problem

Another thought: you said you installed pip in a virtualenv. Is your virtualenv active when you run it via your webserver?

Reinout van Rees
  • 13,486
  • 2
  • 36
  • 68