當前位置: 首頁>>代碼示例>>Python>>正文


Python ImageFile._save方法代碼示例

本文整理匯總了Python中PIL.ImageFile._save方法的典型用法代碼示例。如果您正苦於以下問題:Python ImageFile._save方法的具體用法?Python ImageFile._save怎麽用?Python ImageFile._save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PIL.ImageFile的用法示例。


在下文中一共展示了ImageFile._save方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _save

# 需要導入模塊: from PIL import ImageFile [as 別名]
# 或者: from PIL.ImageFile import _save [as 別名]
def _save(im, fp, filename):
    if im.mode[0] != "F":
        im = im.convert('F')

    hdr = makeSpiderHeader(im)
    if len(hdr) < 256:
        raise IOError("Error creating Spider header")

    # write the SPIDER header
    try:
        fp = open(filename, 'wb')
    except:
        raise IOError("Unable to open %s for writing" % filename)
    fp.writelines(hdr)

    rawmode = "F;32NF"  # 32-bit native floating point
    ImageFile._save(im, fp, [("raw", (0, 0)+im.size, 0, (rawmode, 0, 1))])

    fp.close() 
開發者ID:skylander86,項目名稱:lambda-text-extractor,代碼行數:21,代碼來源:SpiderImagePlugin.py

示例2: _save

# 需要導入模塊: from PIL import ImageFile [as 別名]
# 或者: from PIL.ImageFile import _save [as 別名]
def _save(im, fp, filename):
    if im.mode[0] != "F":
        im = im.convert('F')

    hdr = makeSpiderHeader(im)
    if len(hdr) < 256:
        raise IOError("Error creating Spider header")

    # write the SPIDER header
    fp.writelines(hdr)

    rawmode = "F;32NF"  # 32-bit native floating point
    ImageFile._save(im, fp, [("raw", (0, 0)+im.size, 0, (rawmode, 0, 1))]) 
開發者ID:tp4a,項目名稱:teleport,代碼行數:15,代碼來源:SpiderImagePlugin.py

示例3: _save_spider

# 需要導入模塊: from PIL import ImageFile [as 別名]
# 或者: from PIL.ImageFile import _save [as 別名]
def _save_spider(im, fp, filename):
    # get the filename extension and register it with Image
    ext = os.path.splitext(filename)[1]
    Image.register_extension(SpiderImageFile.format, ext)
    _save(im, fp, filename)

# -------------------------------------------------------------------- 
開發者ID:tp4a,項目名稱:teleport,代碼行數:9,代碼來源:SpiderImagePlugin.py

示例4: _save

# 需要導入模塊: from PIL import ImageFile [as 別名]
# 或者: from PIL.ImageFile import _save [as 別名]
def _save(im, fp, filename):
    if im.mode[0] != "F":
        im = im.convert("F")

    hdr = makeSpiderHeader(im)
    if len(hdr) < 256:
        raise OSError("Error creating Spider header")

    # write the SPIDER header
    fp.writelines(hdr)

    rawmode = "F;32NF"  # 32-bit native floating point
    ImageFile._save(im, fp, [("raw", (0, 0) + im.size, 0, (rawmode, 0, 1))]) 
開發者ID:tp4a,項目名稱:teleport,代碼行數:15,代碼來源:SpiderImagePlugin.py

示例5: _save_spider

# 需要導入模塊: from PIL import ImageFile [as 別名]
# 或者: from PIL.ImageFile import _save [as 別名]
def _save_spider(im, fp, filename):
    # get the filename extension and register it with Image
    ext = os.path.splitext(filename)[1]
    Image.register_extension(SpiderImageFile.format, ext)
    _save(im, fp, filename)


# -------------------------------------------------------------------- 
開發者ID:tp4a,項目名稱:teleport,代碼行數:10,代碼來源:SpiderImagePlugin.py

示例6: _save

# 需要導入模塊: from PIL import ImageFile [as 別名]
# 或者: from PIL.ImageFile import _save [as 別名]
def _save(im, fp, filename, check=0):
    try:
        rawmode, bits, colors = SAVE[im.mode]
    except KeyError:
        raise IOError("cannot write mode %s as BMP" % im.mode)

    if check:
        return check

    info = im.encoderinfo

    dpi = info.get("dpi", (96, 96))

    # 1 meter == 39.3701 inches
    ppm = tuple(map(lambda x: int(x * 39.3701), dpi))

    stride = ((im.size[0]*bits+7)//8+3) & (~3)
    header = 40  # or 64 for OS/2 version 2
    offset = 14 + header + colors * 4
    image = stride * im.size[1]

    # bitmap header
    fp.write(b"BM" +                      # file type (magic)
             o32(offset+image) +          # file size
             o32(0) +                     # reserved
             o32(offset))                 # image data offset

    # bitmap info header
    fp.write(o32(header) +                # info header size
             o32(im.size[0]) +            # width
             o32(im.size[1]) +            # height
             o16(1) +                     # planes
             o16(bits) +                  # depth
             o32(0) +                     # compression (0=uncompressed)
             o32(image) +                 # size of bitmap
             o32(ppm[0]) + o32(ppm[1]) +  # resolution
             o32(colors) +                # colors used
             o32(colors))                 # colors important

    fp.write(b"\0" * (header - 40))       # padding (for OS/2 format)

    if im.mode == "1":
        for i in (0, 255):
            fp.write(o8(i) * 4)
    elif im.mode == "L":
        for i in range(256):
            fp.write(o8(i) * 4)
    elif im.mode == "P":
        fp.write(im.im.getpalette("RGB", "BGRX"))

    ImageFile._save(im, fp, [("raw", (0, 0)+im.size, 0,
                    (rawmode, stride, -1))])

#
# --------------------------------------------------------------------
# Registry 
開發者ID:ee0703,項目名稱:console_video,代碼行數:58,代碼來源:BmpImagePlugin.py


注:本文中的PIL.ImageFile._save方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。