Skip to content

Commit

Permalink
Fixing PIL import
Browse files Browse the repository at this point in the history
Apparently you can't just import PIL and get the Image submodule:

https://stackoverflow.com/questions/11911480/python-pil-has-no-attribute-image
  • Loading branch information
mtlynch committed Oct 8, 2017
1 parent ad26fe0 commit f9b54f3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 2 additions & 2 deletions processor/resize.py
@@ -1,6 +1,6 @@
import logging

import PIL
from PIL import Image

logger = logging.getLogger(__name__)

Expand All @@ -10,7 +10,7 @@


def resize(image_path, resized_path):
image = PIL.Image.open(image_path)
image = Image.open(image_path)
x, y = image.size
if (float(x) / float(y)) >= THUMBNAIL_RATIO:
delta = x - (THUMBNAIL_RATIO * float(y))
Expand Down
4 changes: 1 addition & 3 deletions tests/test_resize.py
@@ -1,16 +1,14 @@
import unittest

import mock
import PIL
assert PIL # workaround for pyflakes unused import warning

from processor import resize


class ResizeTest(unittest.TestCase):

def setUp(self):
mock_pil_patch = mock.patch('PIL.Image.open')
mock_pil_patch = mock.patch('processor.resize.Image.open')
self.addCleanup(mock_pil_patch.stop)
self.mock_pil = mock_pil_patch.start()

Expand Down

0 comments on commit f9b54f3

Please sign in to comment.