'Takes a raw image (in image_body) and resizes it to fit given
dimensions. Returns a  file-like object in the form of a StringIO.
This must happen in this function because PIL is transforming the
original as it works.'

@classmethod
def resize_image(cls, image_body, size, fit_to_size=False):

    image_file = StringIO(image_body)
    try:
        image = Image.open(image_file)
    except IOError:
        return False
    format = image.format
    image = cls.adjust_image_orientation(image)
    if (not fit_to_size):
        image.thumbnail(PROFILE_PICTURE_SIZES[size], Image.ANTIALIAS)
    else:
        image = PILOps.fit(image, PROFILE_PICTURE_SIZES[size], method=Image.ANTIALIAS, centering=(0.5, 0.5))
    output = StringIO()
    if (format.lower() == 'jpg'):
        format = 'jpeg'
    image.save(output, format=format, quality=95)
    return output
