Created
October 2, 2014 17:26
-
-
Save rizumu/ee9b2e7defecb18725e8 to your computer and use it in GitHub Desktop.
mixin snippet
This file contains 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 characters
width = models.PositiveIntegerField(_("height"), db_index=True) | |
height = models.PositiveIntegerField(_("width"), db_index=True) | |
def is_horizontal(self): | |
if float(self.height) / self.width <= 0.7: | |
return True | |
def is_vertical(self): | |
if float(self.height) / self.width > 0.7: | |
return True | |
def is_square(self): | |
if self.width == self.height: | |
return True | |
def save(self): | |
if not self.image: | |
self.delete() | |
else: | |
image = Image.open(cStringIO.StringIO(urllib.urlopen(self.image.url).read())) | |
self.width, self.height = image.size | |
super(Poster, self).save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment