Did I find the right examples for you? yes no

All Samples(58)  |  Call(58)  |  Derive(0)  |  Import(0)
Helper to save image based on tile list

:param im: Image object.
:param fp: File object.
:param tile: Tile list.
:param bufsize: Optional buffer size

        def _save(im, fp, tile, bufsize=0):
    """Helper to save image based on tile list

    :param im: Image object.
    :param fp: File object.
    :param tile: Tile list.
    :param bufsize: Optional buffer size
    """

    im.load()
    if not hasattr(im, "encoderconfig"):
        im.encoderconfig = ()
    tile.sort(key=_tilesort)
    # FIXME: make MAXBLOCK a configuration parameter
    # It would be great if we could have the encoder specifiy what it needs
    # But, it would need at least the image size in most cases. RawEncode is
    # a tricky case.
    bufsize = max(MAXBLOCK, bufsize, im.size[0] * 4) # see RawEncode.c
    try:
        fh = fp.fileno()
        fp.flush()
    except (AttributeError, io.UnsupportedOperation):
        # compress to Python file-compatible object
        for e, b, o, a in tile:
            e = Image._getencoder(im.mode, e, a, im.encoderconfig)
            if o > 0:
                fp.seek(o, 0)
            e.setimage(im.im, b)
            while True:
                l, s, d = e.encode(bufsize)
                fp.write(d)
                if s:
                    break
            if s < 0:
                raise IOError("encoder error %d when writing image file" % s)
    else:
        # slight speedup: compress to real file object
        for e, b, o, a in tile:
            e = Image._getencoder(im.mode, e, a, im.encoderconfig)
            if o > 0:
                fp.seek(o, 0)
            e.setimage(im.im, b)
            s = e.encode_to_file(fh, bufsize)
            if s < 0:
                raise IOError("encoder error %d when writing image file" % s)
    try:
        fp.flush()
    except: pass
        


src/a/n/antisocial-HEAD/ve/lib/python2.7/site-packages/PIL/JpegImagePlugin.py   antisocial(Download)
    bufsize = max(ImageFile.MAXBLOCK, bufsize, len(info.get("exif",b"")) + 5 )
 
    ImageFile._save(im, fp, [("jpeg", (0,0)+im.size, 0, rawmode)], bufsize)
 
def _save_cjpeg(im, fp, filename):

src/p/i/Pillow-2.4.0/PIL/JpegImagePlugin.py   Pillow(Download)
    bufsize = max(ImageFile.MAXBLOCK, bufsize, len(info.get("exif",b"")) + 5 )
 
    ImageFile._save(im, fp, [("jpeg", (0,0)+im.size, 0, rawmode)], bufsize)
 
def _save_cjpeg(im, fp, filename):

src/p/i/Pillow-HEAD/PIL/JpegImagePlugin.py   Pillow(Download)
    bufsize = max(ImageFile.MAXBLOCK, bufsize, len(info.get("exif",b"")) + 5 )
 
    ImageFile._save(im, fp, [("jpeg", (0,0)+im.size, 0, rawmode)], bufsize)
 
def _save_cjpeg(im, fp, filename):

src/a/n/antisocial-HEAD/ve/lib/python2.7/site-packages/PIL/PdfImagePlugin.py   antisocial(Download)
            im = Image.new("L", (len(data), 1), None)
            im.putdata(data)
        ImageFile._save(im, op, [("hex", (0,0)+im.size, 0, im.mode)])
    elif filter == "/DCTDecode":
        Image.SAVE["JPEG"](im, op, filename)
    elif filter == "/FlateDecode":
        ImageFile._save(im, op, [("zip", (0,0)+im.size, 0, im.mode)])
    elif filter == "/RunLengthDecode":
        ImageFile._save(im, op, [("packbits", (0,0)+im.size, 0, im.mode)])

src/p/i/Pillow-2.4.0/PIL/PdfImagePlugin.py   Pillow(Download)
            im = Image.new("L", (len(data), 1), None)
            im.putdata(data)
        ImageFile._save(im, op, [("hex", (0,0)+im.size, 0, im.mode)])
    elif filter == "/DCTDecode":
        Image.SAVE["JPEG"](im, op, filename)
    elif filter == "/FlateDecode":
        ImageFile._save(im, op, [("zip", (0,0)+im.size, 0, im.mode)])
    elif filter == "/RunLengthDecode":
        ImageFile._save(im, op, [("packbits", (0,0)+im.size, 0, im.mode)])

src/p/i/Pillow-HEAD/PIL/PdfImagePlugin.py   Pillow(Download)
            im = Image.new("L", (len(data), 1), None)
            im.putdata(data)
        ImageFile._save(im, op, [("hex", (0,0)+im.size, 0, im.mode)])
    elif filter == "/DCTDecode":
        Image.SAVE["JPEG"](im, op, filename)
    elif filter == "/FlateDecode":
        ImageFile._save(im, op, [("zip", (0,0)+im.size, 0, im.mode)])
    elif filter == "/RunLengthDecode":
        ImageFile._save(im, op, [("packbits", (0,0)+im.size, 0, im.mode)])

src/a/n/antisocial-HEAD/ve/lib/python2.7/site-packages/PIL/PngImagePlugin.py   antisocial(Download)
        chunk(fp, b"iCCP", data)
 
    ImageFile._save(im, _idat(fp, chunk), [("zip", (0,0)+im.size, 0, rawmode)])
 
    chunk(fp, b"IEND", b"")

src/p/i/Pillow-2.4.0/PIL/PngImagePlugin.py   Pillow(Download)
        chunk(fp, b"iCCP", data)
 
    ImageFile._save(im, _idat(fp, chunk), [("zip", (0,0)+im.size, 0, rawmode)])
 
    chunk(fp, b"IEND", b"")

src/a/n/antisocial-HEAD/ve/lib/python2.7/site-packages/PIL/TiffImagePlugin.py   antisocial(Download)
        offset = ifd.save(fp)
 
        ImageFile._save(im, fp, [
            ("raw", (0,0)+im.size, offset, (rawmode, stride, 1))
            ])

src/a/n/antisocial-HEAD/ve/lib/python2.7/site-packages/PIL/BmpImagePlugin.py   antisocial(Download)
        fp.write(im.im.getpalette("RGB", "BGRX"))
 
    ImageFile._save(im, fp, [("raw", (0,0)+im.size, 0, (rawmode, stride, -1))])
 
#

  1 | 2 | 3 | 4 | 5  Next