当前位置: 首页>>代码示例>>Python>>正文


Python Image.init方法代码示例

本文整理汇总了Python中PIL.Image.init方法的典型用法代码示例。如果您正苦于以下问题:Python Image.init方法的具体用法?Python Image.init怎么用?Python Image.init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PIL.Image的用法示例。


在下文中一共展示了Image.init方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_bytes

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import init [as 别名]
def get_bytes(self, format='PNG'):
    '''
    usage:  i = Identicon('xx')
            print(i.base64())
    return: this image's base64 code
    created by: liuzheng712
    bug report: https://github.com/liuzheng712/identicons/issues
    '''
    self.calculate()
    fp = io.BytesIO()
    self.image.encoderinfo = {}
    self.image.encoderconfig = ()

    if format.upper() not in Image.SAVE:
      Image.init()
    save_handler = Image.SAVE[format.upper()]
    try:
      save_handler(self.image, fp, '')
    finally:
      fp.seek(0)
    return fp 
开发者ID:F0RE1GNERS,项目名称:eoj3,代码行数:23,代码来源:identicon.py

示例2: __init__

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import init [as 别名]
def __init__(self, service_name='images', host_prefix=''):
    """Preloads PIL to load all modules in the unhardened environment.

    Args:
      service_name: Service name expected for all calls.
      host_prefix: the URL prefix (protocol://host:port) to preprend to
        image urls on a call to GetUrlBase.
    """
    super(ImagesServiceStub, self).__init__(
        service_name, max_request_size=MAX_REQUEST_SIZE)
    self._blob_stub = images_blob_stub.ImagesBlobStub(host_prefix)
    Image.init() 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:14,代码来源:images_stub.py

示例3: __init__

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import init [as 别名]
def __init__(self, lang, areaType, statusBar):
        QGraphicsView.__init__(self)

        self.ocrscene = OcrScene(self, lang, areaType)
        self.setScene(self.ocrscene)

        self.setCacheMode(QGraphicsView.CacheBackground)
        self.setRenderHint(QPainter.Antialiasing)
        self.setTransformationAnchor(QGraphicsView.AnchorUnderMouse)
        self.setResizeAnchor(QGraphicsView.AnchorViewCenter)

        self.setMinimumSize(200, 200)

        self.language = lang
        self.statusBar = statusBar
        self.areaType = areaType

        self.resizingArea = None
        self.resizingAreaPos = None
        self.resizingAreaRect = None
        self.resizingEdge = None
        self.resizingStartingPos = None
        self.areaBorder = float()
        self.areaTextSize = float()

        self.setCursor(Qt.CrossCursor)
        self.scene().isModified = False
        self.bResizing = False
        self.filename = None
        Image.init() 
开发者ID:zdenop,项目名称:lector,代码行数:32,代码来源:ocrwidget.py

示例4: calculate

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import init [as 别名]
def calculate(self):
    """
    Creates the identicon.
    First three bytes are used to generate the color,
    remaining bytes are used to create the drawing
    """
    color = (self.hash & 0xff, self.hash >> 8 & 0xff, self.hash >> 16 & 0xff)
    self.hash >>= 24  # skip first three bytes
    square_x = square_y = 0  # init square position
    for x in range(GRID_SIZE * (GRID_SIZE + 1) // 2):
      if self.hash & 1:
        x = BORDER_SIZE + square_x * SQUARE_SIZE
        y = BORDER_SIZE + square_y * SQUARE_SIZE
        self.draw.rectangle(
          (x, y, x + SQUARE_SIZE, y + SQUARE_SIZE),
          fill=color,
          outline=color
        )
        # following is just for mirroring
        x = BORDER_SIZE + (GRID_SIZE - 1 - square_x) * SQUARE_SIZE
        self.draw.rectangle(
          (x, y, x + SQUARE_SIZE, y + SQUARE_SIZE),
          fill=color,
          outline=color
        )
      self.hash >>= 1  # shift to right
      square_y += 1
      if square_y == GRID_SIZE:  # done with first column
        square_y = 0
        square_x += 1 
开发者ID:F0RE1GNERS,项目名称:eoj3,代码行数:32,代码来源:identicon.py


注:本文中的PIL.Image.init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。