diff --git a/.gitignore b/.gitignore index 3808001..e3abc3c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ *.pyc *.db *.orig -.DS_Store \ No newline at end of file +.DS_Store +dist +build +MANIFEST diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..27e27bd --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,2 @@ +include AUTHORS +include LICENSE diff --git a/imagekit/__init__.py b/imagekit/__init__.py index 1d30445..aa78b1e 100644 --- a/imagekit/__init__.py +++ b/imagekit/__init__.py @@ -1,10 +1,11 @@ """ - Django ImageKit Author: Justin Driscoll -Version: 0.3.3 +Version: 0.3.4 """ -VERSION = "0.3.3" - \ No newline at end of file +__author__ = 'Justin Driscoll, Bryan Veloso, Greg Newman, Chris Drackett' +__version__ = (0, 3, 4) + + diff --git a/imagekit/specs.py b/imagekit/specs.py index 4814c52..9d7fb87 100644 --- a/imagekit/specs.py +++ b/imagekit/specs.py @@ -51,19 +51,20 @@ class Accessor(object): return imgfile def _create(self): - if self._exists(): - return - # process the original image file - try: - fp = self._obj._imgfield.storage.open(self._obj._imgfield.name) - except IOError: - return - fp.seek(0) - fp = StringIO(fp.read()) - self._img, self._fmt = self.spec.process(Image.open(fp), self._obj) - # save the new image to the cache - content = ContentFile(self._get_imgfile().read()) - self._obj._storage.save(self.name, content) + if self._obj._imgfield: + if self._exists(): + return + # process the original image file + try: + fp = self._obj._imgfield.storage.open(self._obj._imgfield.name) + except IOError: + return + fp.seek(0) + fp = StringIO(fp.read()) + self._img, self._fmt = self.spec.process(Image.open(fp), self._obj) + # save the new image to the cache + content = ContentFile(self._get_imgfile().read()) + self._obj._storage.save(self.name, content) def _delete(self): self._obj._storage.delete(self.name) @@ -73,21 +74,22 @@ class Accessor(object): @property def name(self): - filepath, basename = os.path.split(self._obj._imgfield.name) - filename, extension = os.path.splitext(basename) - for processor in self.spec.processors: - if issubclass(processor, processors.Format): - extension = processor.extension - cache_filename = self._obj._ik.cache_filename_format % \ - {'filename': filename, - 'specname': self.spec.name(), - 'extension': extension.lstrip('.')} - if callable(self._obj._ik.cache_dir): - return self._obj._ik.cache_dir(self._obj, filepath, - cache_filename) - else: - return os.path.join(self._obj._ik.cache_dir, filepath, - cache_filename) + if self._obj._imgfield.name: + filepath, basename = os.path.split(self._obj._imgfield.name) + filename, extension = os.path.splitext(basename) + for processor in self.spec.processors: + if issubclass(processor, processors.Format): + extension = processor.extension + cache_filename = self._obj._ik.cache_filename_format % \ + {'filename': filename, + 'specname': self.spec.name(), + 'extension': extension.lstrip('.')} + if callable(self._obj._ik.cache_dir): + return self._obj._ik.cache_dir(self._obj, filepath, + cache_filename) + else: + return os.path.join(self._obj._ik.cache_dir, filepath, + cache_filename) @property def url(self): diff --git a/setup.py b/setup.py index 184925d..0c0d585 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,9 @@ setup( author_email='justin@driscolldev.com', url='http://github.com/jdriscoll/django-imagekit/', packages=[ - 'imagekit' + 'imagekit', + 'imagekit.management', + 'imagekit.management.commands' ], classifiers=[ 'Development Status :: 3 - Alpha',