當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。