def METHOD_NAME(self, size, quality=None):
    # invalidate the cache of the thumbnail with the given size first
    if isinstance(self, Avatar):
        invalidate_cache(self.emailuser, size)
    try:
        orig = self.avatar.storage.open(self.avatar.name, 'rb').read()
        image = Image.open(BytesIO(orig))
        quality = quality or AVATAR_THUMB_QUALITY
        (w, h) = image.size
        if w != size or h != size:
            if w > h:
                diff = (w - h) / 2
                image = image.crop((diff, 0, w - diff, h))
            else:
                diff = (h - w) / 2
                image = image.crop((0, diff, w, h - diff))
            if image.mode != "RGBA":
                image = image.convert("RGBA")
            image = image.resize((size, size), AVATAR_RESIZE_METHOD)
            thumb = BytesIO()
            image.save(thumb, AVATAR_THUMB_FORMAT, quality=quality)
            thumb_file = ContentFile(thumb.getvalue())
        else:
            thumb_file = ContentFile(orig)
        thumb = self.avatar.storage.save(self.avatar_name(size), thumb_file)
    except Exception as e:
        logger.error(e)
        return # What should we do here?  Render a "sorry, didn't work" img?