Skip to content

Instantly share code, notes, and snippets.

@philippWassibauer
Created October 20, 2010 15:55
Show Gist options
  • Save philippWassibauer/636693 to your computer and use it in GitHub Desktop.
Save philippWassibauer/636693 to your computer and use it in GitHub Desktop.
A test for checking if PIL has Jpeg support, including instructions to fix it for Ubuntu
import os
import unittest
from os.path import abspath
from PIL import Image
class PhotoTests(unittest.TestCase):
"""Checks JPEG support for your system. You need a folder 'testdata' that has a test.jpg in it
could be improved, but works fine for me at the moment"""
def test_jpg(self):
image_path = os.path.dirname(os.path.abspath(__file__))
image_path = os.path.join(image_path, "testdata", "test.jpg")
trial_image = Image.open(image_path)
try:
trial_image.load()
except:
print "!!!NO JPEG SUPPORT!!!"
print "To fix this:"
print "sudo aptitude install libjpeg libjpeg-dev"
print "sudo aptitude install libfreetype6 libfreetype6-dev"
print "in your virtual env: pip install http://effbot.org/media/downloads/Imaging-1.1.6.tar.gz"
self.assertTrue(False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment