Commits

Justin Driscoll committed 7551468

Updated preprocessor implementation

  • Participants
  • Parent commits c5d4cfa

Comments (0)

Files changed (2)

imagekit/models.py

                 prop._create()
 
     def save(self, clear_cache=True, *args, **kwargs):
-        is_new_object = self._get_pk_val is None
+        is_new_object = self._get_pk_val() is None
         super(ImageModel, self).save(*args, **kwargs)
         if is_new_object:
             clear_cache = False
             if spec is not None:
                 newfile = self._imgfield.storage.open(str(self._imgfield))
                 img = Image.open(newfile)
-                img = spec.process(img, None)
-                format = img.format or 'JPEG'
+                img, format = spec.process(img, self)
                 if format != 'JPEG':
                     imgfile = img_to_fobj(img, format)
                 else:

imagekit/specs.py

         fp.seek(0)
         fp = StringIO(fp.read())
         self._img, self._fmt = self.spec.process(Image.open(fp), self._obj)
-        for key, val in Image.EXTENSION.iteritems():
-            if val == self._fmt:
-                extension = key
         # save the new image to the cache
         content = ContentFile(self._get_imgfile().read())
         self._obj._imgfield.storage.save(self.name, content)