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
|
||||
|
||||
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
|
||||
|
||||
try:
|
||||
|
|
@ -269,6 +251,26 @@ class ImageField(CharField):
|
|||
|
||||
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)
|
||||
|
||||
# Delete old files
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue