def _get_raw_data(self, image, format, quality):
        ImageFile.MAXBLOCK = 1024 * 1024
        buf = StringIO()

        try:
            # ptimize makes the encoder do a second pass over the image, if
            # the format supports it.
            image.save(buf, format=format, quality=quality, optimize=1)
        except IOError:
            # optimize is a no-go, omit it this attempt.
            image.save(buf, format=format, quality=quality)

        raw_data = buf.getvalue()
        buf.close()
        return raw_data
Returns the raw data from the Image, which can be directly written
dataset/ETHPy150Open gtaylor/django-athumb/athumb/pial/engines/pil_engine.py/PILEngine._get_raw_data