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


Python Image.Image方法代碼示例

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


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

示例1: expect_crop

# 需要導入模塊: import Image [as 別名]
# 或者: from Image import Image [as 別名]
def expect_crop(self, left_x=None, right_x=None, top_y=None, bottom_y=None):
    """Setup a mox expectation to images_stub._Crop."""
    crop_xform = images_service_pb.Transform()
    if left_x is not None:
      if not isinstance(left_x, float):
        raise self.failureException('Crop argument must be a float.')
      crop_xform.set_crop_left_x(left_x)
    if right_x is not None:
      if not isinstance(right_x, float):
        raise self.failureException('Crop argument must be a float.')
      crop_xform.set_crop_right_x(right_x)
    if top_y is not None:
      if not isinstance(top_y, float):
        raise self.failureException('Crop argument must be a float.')
      crop_xform.set_crop_top_y(top_y)
    if bottom_y is not None:
      if not isinstance(bottom_y, float):
        raise self.failureException('Crop argument must be a float.')
      crop_xform.set_crop_bottom_y(bottom_y)
    self._images_stub._Crop(mox.IsA(Image.Image), crop_xform).AndReturn(
        self._image) 
開發者ID:elsigh,項目名稱:browserscope,代碼行數:23,代碼來源:blob_image_test.py

示例2: __init__

# 需要導入模塊: import Image [as 別名]
# 或者: from Image import Image [as 別名]
def __init__(self, fp=None, filename=None):
        Image.Image.__init__(self)

        self.tile = None
        self.readonly = 1 # until we know better

        self.decoderconfig = ()
        self.decodermaxblock = MAXBLOCK

        if Image.isStringType(fp):
            # filename
            self.fp = open(fp, "rb")
            self.filename = fp
        else:
            # stream
            self.fp = fp
            self.filename = filename

        try:
            self._open()
        except IndexError, v: # end of data
            if Image.DEBUG > 1:
                traceback.print_exc()
            raise SyntaxError, v 
開發者ID:awslabs,項目名稱:mxnet-lambda,代碼行數:26,代碼來源:ImageFile.py

示例3: setUp

# 需要導入模塊: import Image [as 別名]
# 或者: from Image import Image [as 別名]
def setUp(self):
    self.mox = mox.Mox()
    self._environ = {'PATH_INFO': 'http://test.com/_ah/img/SomeBlobKey',
                     'REQUEST_METHOD': 'GET'}
    self._images_stub = self.mox.CreateMock(images_stub.ImagesServiceStub)
    self._image = Image.Image()
    self.app = blob_image.Application()
    os.environ['APPLICATION_ID'] = 'testapp'
    self._get_images_stub = blob_image._get_images_stub
    blob_image._get_images_stub = lambda: self._images_stub 
開發者ID:elsigh,項目名稱:browserscope,代碼行數:12,代碼來源:blob_image_test.py

示例4: expect_resize

# 需要導入模塊: import Image [as 別名]
# 或者: from Image import Image [as 別名]
def expect_resize(self, resize):
    """Setup a mox expectation to images_stub._Resize."""
    resize_xform = images_service_pb.Transform()
    resize_xform.set_width(resize)
    resize_xform.set_height(resize)
    self._images_stub._Resize(mox.IsA(Image.Image),
                              resize_xform).AndReturn(self._image) 
開發者ID:elsigh,項目名稱:browserscope,代碼行數:9,代碼來源:blob_image_test.py

示例5: expect_encode_image

# 需要導入模塊: import Image [as 別名]
# 或者: from Image import Image [as 別名]
def expect_encode_image(self, data,
                          mime_type=images_service_pb.OutputSettings.JPEG):
    """Setup a mox expectation to images_stub._EncodeImage."""
    output_settings = images_service_pb.OutputSettings()
    output_settings.set_mime_type(mime_type)
    self._images_stub._EncodeImage(mox.IsA(Image.Image),
                                   output_settings).AndReturn(data) 
開發者ID:elsigh,項目名稱:browserscope,代碼行數:9,代碼來源:blob_image_test.py

示例6: __init__

# 需要導入模塊: import Image [as 別名]
# 或者: from Image import Image [as 別名]
def __init__(self, size, interpolation=Image.BILINEAR):
        self.size = size
        self.interpolation = interpolation 
開發者ID:Kashu7100,項目名稱:Qualia2.0,代碼行數:5,代碼來源:transforms.py

示例7: __call__

# 需要導入模塊: import Image [as 別名]
# 或者: from Image import Image [as 別名]
def __call__(self, image):
        if isinstance(image, Image.Image):
            image = numpy.asarray(image)
            image = image.transpose(2,0,1)
            image = image.reshape(1,*image.shape) / 255
        elif isinstance(image, np.ndarray):
            image = image / 255
        else:
            raise TypeError
        return Tensor(image) 
開發者ID:Kashu7100,項目名稱:Qualia2.0,代碼行數:12,代碼來源:transforms.py

示例8: main

# 需要導入模塊: import Image [as 別名]
# 或者: from Image import Image [as 別名]
def main():
    filename = os.path.join(tempfile.gettempdir(), "image.xpm")
    image = Image.Image(300, 60)
    draw_and_save_image(image, filename)

    filename = os.path.join(tempfile.gettempdir(), "proxy.xpm")
    image = ImageProxy(Image.Image, 300, 60)
    draw_and_save_image(image, filename) 
開發者ID:lovexiaov,項目名稱:python-in-practice,代碼行數:10,代碼來源:imageproxy1.py

示例9: __init__

# 需要導入模塊: import Image [as 別名]
# 或者: from Image import Image [as 別名]
def __init__(self, ImageClass, width=None, height=None, filename=None):
        assert (width is not None and height is not None) or \
                filename is not None
        self.Image = ImageClass
        self.commands = []
        if filename is not None:
            self.load(filename)
        else:
            self.commands = [(self.Image, width, height)] 
開發者ID:lovexiaov,項目名稱:python-in-practice,代碼行數:11,代碼來源:imageproxy1.py

示例10: load

# 需要導入模塊: import Image [as 別名]
# 或者: from Image import Image [as 別名]
def load(self, filename):
        self.commands = [(self.Image, None, None, filename)] 
開發者ID:lovexiaov,項目名稱:python-in-practice,代碼行數:4,代碼來源:imageproxy1.py

示例11: set_pixel

# 需要導入模塊: import Image [as 別名]
# 或者: from Image import Image [as 別名]
def set_pixel(self, x, y, color):
        self.commands.append((self.Image.set_pixel, x, y, color)) 
開發者ID:lovexiaov,項目名稱:python-in-practice,代碼行數:4,代碼來源:imageproxy1.py

示例12: line

# 需要導入模塊: import Image [as 別名]
# 或者: from Image import Image [as 別名]
def line(self, x0, y0, x1, y1, color):
        self.commands.append((self.Image.line, x0, y0, x1, y1, color)) 
開發者ID:lovexiaov,項目名稱:python-in-practice,代碼行數:4,代碼來源:imageproxy1.py

示例13: ellipse

# 需要導入模塊: import Image [as 別名]
# 或者: from Image import Image [as 別名]
def ellipse(self, x0, y0, x1, y1, outline=None, fill=None):
        self.commands.append((self.Image.ellipse, x0, y0, x1, y1,
                outline, fill))

    # Incomplete API. Unsupported are:
    # pixel(), subsample(), scale(), and size() 
開發者ID:lovexiaov,項目名稱:python-in-practice,代碼行數:8,代碼來源:imageproxy1.py

示例14: __init__

# 需要導入模塊: import Image [as 別名]
# 或者: from Image import Image [as 別名]
def __init__(self, ImageClass, width=None, height=None, filename=None):
        assert (width is not None and height is not None) or \
                filename is not None
        self.Image = ImageClass
        self.__image = None
        self.commands = []
        if filename is not None:
            self.load(filename)
        else:
            self.commands = [(self.Image, width, height)] 
開發者ID:lovexiaov,項目名稱:python-in-practice,代碼行數:12,代碼來源:imageproxy2.py

示例15: load

# 需要導入模塊: import Image [as 別名]
# 或者: from Image import Image [as 別名]
def load(self, filename):
        self.__image = None
        self.commands = [(self.Image, None, None, filename)] 
開發者ID:lovexiaov,項目名稱:python-in-practice,代碼行數:5,代碼來源:imageproxy2.py


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