Commits

Justin Driscoll  committed 40dcfa7

We now seek to the begining of the file in spec._create to prevent PIL errors when multiple specs have pre_cache=True

  • Participants
  • Parent commits 40e171a

Comments (0)

Files changed (1)

File src/imagekit/specs.py

     def _create(self):
         if self._exists():
             return
-        self._img = self.spec.process(Image.open(self._obj._imgfield.file),
-                                      self._obj)
+        # process the original image file
+        fp = self._obj._imgfield.file.file
+        fp.seek(0)
+        self._img = self.spec.process(Image.open(fp), self._obj)
+        # save the new image to the cache
         content = ContentFile(self._get_imgfile().read())
         self._obj._imgfield.storage.save(self._path(), content)