Last active
December 16, 2015 17:41
-
-
Save rturowicz/5472429 to your computer and use it in GitHub Desktop.
Revisions
-
rturowicz renamed this gist
Apr 27, 2013 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
rturowicz created this gist
Apr 27, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ # models.py: overwritten model save method def save(self, *args, **kwargs): if self.cover: img_string = StringIO() pil_image = Image.open(self.cover.file) if pil_image: res_image = pil_image.resize((1034, 1400)) res_image.save(img_string, pil_image.format) # original image replaced by thumbnail self.cover.file = InMemoryUploadedFile( img_string, self.cover.file.field_name, self.cover.file.name, self.cover.file.content_type, img_string.len, self.cover.file.charset ) super(Issue, self).save()