mirror of
https://github.com/Hopiu/django-imagekit.git
synced 2026-03-16 21:30:23 +00:00
Close the file only if it has been opened locally
This commit is contained in:
parent
47ff56cfe2
commit
732f7045e4
1 changed files with 4 additions and 1 deletions
|
|
@ -143,6 +143,7 @@ class ImageSpec(BaseImageSpec):
|
|||
raise MissingSource("The spec '%s' has no source file associated"
|
||||
" with it." % self)
|
||||
|
||||
file_opened_locally = False
|
||||
# TODO: Move into a generator base class
|
||||
# TODO: Factor out a generate_image function so you can create a generator and only override the PIL.Image creating part. (The tricky part is how to deal with original_format since generator base class won't have one.)
|
||||
try:
|
||||
|
|
@ -151,12 +152,14 @@ class ImageSpec(BaseImageSpec):
|
|||
|
||||
# Re-open the file -- https://code.djangoproject.com/ticket/13750
|
||||
self.source.open()
|
||||
file_opened_locally = True
|
||||
img = open_image(self.source)
|
||||
|
||||
new_image = process_image(img, processors=self.processors,
|
||||
format=self.format, autoconvert=self.autoconvert,
|
||||
options=self.options)
|
||||
self.source.close()
|
||||
if file_opened_locally:
|
||||
self.source.close()
|
||||
return new_image
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue