code: def is_portrait(file_):
      
      if sorl_settings.THUMBNAIL_DUMMY:
          return sorl_settings.THUMBNAIL_DUMMY_RATIO < 1
      if not file_:
          return False
      image_file = default.kvstore.get_or_set(ImageFile(file_))
      return image_file.is_portrait()
docs: A very handy filter to determine if an image is portrait or landscape.