Fix in ImageField
This commit is contained in:
parent
d2a043c034
commit
f03103fd85
1 changed files with 22 additions and 20 deletions
|
|
@ -222,24 +222,6 @@ class ImageField(CharField):
|
||||||
|
|
||||||
save_file=self.save_folder+'/'+filename
|
save_file=self.save_folder+'/'+filename
|
||||||
|
|
||||||
if self.yes_thumbnail:
|
|
||||||
|
|
||||||
for name, width_t in self.thumbnail.items():
|
|
||||||
|
|
||||||
im_thumb=im.copy()
|
|
||||||
|
|
||||||
ratio=(real_width/width_t)
|
|
||||||
height_t=round(real_height/ratio)
|
|
||||||
|
|
||||||
size=(width_t, height_t)
|
|
||||||
|
|
||||||
save_file_thumb=self.save_folder+'/'+name+filename
|
|
||||||
|
|
||||||
im_thumb.thumbnail(size, Image.LANCZOS)
|
|
||||||
im_thumb.save(save_file_thumb, "JPEG", quality=self.default_quality_thumb)
|
|
||||||
|
|
||||||
im_thumb.close()
|
|
||||||
|
|
||||||
# Save file
|
# Save file
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -269,6 +251,26 @@ class ImageField(CharField):
|
||||||
|
|
||||||
os.remove(save_file)
|
os.remove(save_file)
|
||||||
|
|
||||||
|
# Save thumbnails
|
||||||
|
|
||||||
|
if self.yes_thumbnail:
|
||||||
|
|
||||||
|
for name, width_t in self.thumbnail.items():
|
||||||
|
|
||||||
|
im_thumb=im.copy()
|
||||||
|
|
||||||
|
ratio=(real_width/width_t)
|
||||||
|
height_t=round(real_height/ratio)
|
||||||
|
|
||||||
|
size=(width_t, height_t)
|
||||||
|
|
||||||
|
save_file_thumb=self.save_folder+'/'+name+filename
|
||||||
|
|
||||||
|
im_thumb.thumbnail(size, Image.LANCZOS)
|
||||||
|
im_thumb.save(save_file_thumb, "JPEG", quality=self.default_quality_thumb)
|
||||||
|
|
||||||
|
im_thumb.close()
|
||||||
|
|
||||||
im.save(save_file)
|
im.save(save_file)
|
||||||
|
|
||||||
# Delete old files
|
# Delete old files
|
||||||
|
|
@ -309,7 +311,7 @@ class ImageField(CharField):
|
||||||
self.model.yes_reset_conditions=old_reset
|
self.model.yes_reset_conditions=old_reset
|
||||||
|
|
||||||
|
|
||||||
#self.model.conditions=old_conditions
|
#self.model.conditions=old_conditions
|
||||||
|
|
||||||
im.close()
|
im.close()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue