Skip to content

Instantly share code, notes, and snippets.

@zodman
Created March 2, 2012 17:01
Show Gist options
  • Save zodman/1959668 to your computer and use it in GitHub Desktop.
Save zodman/1959668 to your computer and use it in GitHub Desktop.
Validator image width and height
from django.core.files.images import get_image_dimensions
from django.core.exceptions import ValidationError
HELP_TEXT_570 = _(u"El tamaño debe ser 570px y altura variable.")
HELP_TEXT_604 = _(u"El tamaño debe ser ancho 604px y altura variable.")
def validator_570( image ):
w, h = get_image_dimensions(image)
if h != 570:
ValidationError(HELP_TEXT_570)
def validator_604( image ):
w, h = get_image_dimensions(image)
if h != 604:
ValidationError(HELP_TEXT_604)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment