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


Python Image.Image类代码示例

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


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

示例1: load

    def load(self):

        """ Load the image and return an :class:`Image` instance. """

        bits_per_pixel = self.get_bits_per_sample()
        height = self.get_image_length()
        samples_per_pixel = self.get_sample_per_pixel()
        width = self.get_image_width()
        photometric = self.get_photometric()
        planar_config = self.get_planar_config()
    
        is_planar = planar_config == Tiff.PLANARCONFIG_SEPARATE
        # Tiff.PLANARCONFIG_CONTIG   = 1 = Chunky format
        # Tiff.PLANARCONFIG_SEPARATE = 2 = Planar format
        
        if samples_per_pixel == 1 and bits_per_pixel == 16 and photometric == Tiff.PHOTOMETRIC_MINISBLACK:
            format_ = 'gray16'
        elif samples_per_pixel == 3 and bits_per_pixel == 8 and photometric == Tiff.PHOTOMETRIC_RGB:
            format_ = 'rgb8'
        else:
            raise NameError('Image format of %s is not supported' % (self.file_name))
    
        image = Image(format_, width, height, is_planar)
    
        image.reshape_to_linear()
        if format_ == 'gray16':
            Tiff.read_scanline_gray16(self.tif, image.buffer)
        elif format_ == 'rgb8':
            Tiff.read_scanline_rgb8(self.tif, image.buffer)
        else:
            raise NotImplementedError
        image.reshape()
    
        return image
开发者ID:FabriceSalvaire,项目名称:PyLibTiff,代码行数:34,代码来源:TiffImage.py

示例2: convert2

def convert2(path):
    image=Image.open(path)
    out = os.path.splitext(path)[0] + ".png"
    non_transparent=Image.new('RGBA', image.size, (255,255,255,255))
    non_transparent.paste(image,(0,0),image)
    #non_transparent.paste(image,image)
    non_transparent.save(out)
开发者ID:licface,项目名称:chm2webcmd,代码行数:7,代码来源:ico2png.py

示例3: output

def output(id):
	'''Renders output page with lightbox image and related photos. 
	Lightbox title is absent from the page source unless logged into 
	iStockphoto so making title flat and editable on page'''
	file_contents = get_lightbox_source(id)
	exp_imgs      = re.compile(r"file_thumbview_approve\\\/(\d+)\\\/")
#	soup          = BeautifulSoup(file_contents)
#	title         = soup.findAll(id='searchTitleCaption')
#	matches       = re.search(r'\| Lightbox: ([\b\w\s\b]+) ', file_contents)
	ubbstr        = ''
	thumbs        = []

#	if matches:
#		name = matches.group(1)
#	else:
#		name = soup.title #'Lightbox Name Goes Here'

	ids = exp_imgs.findall(file_contents)
	ids = list(set(ids)) # dedupe
	for image_id in ids:
		i = Image(None, None, None, image_id)
		ubbstr += i.get_ubb_string() + ' '
		thumbs.append({
			'id'  : image_id, 
			'src' : i.get_thumb_src(), 
			'ubb' : i.get_ubb_string()
		})
	return render_template('output.html', id=id, name='Lightbox', thumbs=thumbs, ubbstring=ubbstr)
开发者ID:subchild,项目名称:iStockUtils,代码行数:28,代码来源:istockutils.py

示例4: getAll

 def getAll(self, env=None):
     imglinks = Model.getAll(self,env)
     image_model = Image()
     for imglink in imglinks:
         img = image_model.get(imglink.Imageid)
         imglink['uri'] = img.uri if img is not None else ''
     return imglinks
开发者ID:ajiexw,项目名称:old-zarkpy,代码行数:7,代码来源:ImgLink.py

示例5: deserialize

 def deserialize(self,serial):
     imlist = ast.literal_eval(serial)
     for k,v in imlist.iteritems():
         #print "deserializing: %s" % k
         image = Image()
         image.deserialize(v)
         #print image
         self.addimage(image, k)
开发者ID:teuben,项目名称:admit,代码行数:8,代码来源:MultiImage.py

示例6: convert

def convert(path):
    from PIL import Image

    out = os.path.splitext(path)[0] + ".png"
    im = Image.open(path)
    bg = Image.new("RGB", im.size, (255,255,255))
    bg.paste(im,im)
    bg.save(out)
开发者ID:licface,项目名称:chm2webcmd,代码行数:8,代码来源:ico2png.py

示例7: __init__

	def __init__(self, image):
		Box.__init__(self)
		Visible.__init__(self)
		if issubclass(image.__class__, Image):
			self.w = image.w
			self.h = image.h
			self.nativeW = image.nativeW
			self.nativeH = image.nativeH
			self._texture = image._texture
		elif issubclass(image.__class__, pygame.Surface):
		    self._texture = None
			Image.initFromSurface(self, image)
开发者ID:nbudin,项目名称:solidfuel,代码行数:12,代码来源:Sprite.py

示例8: generateImageFromFile

   def generateImageFromFile(file_path, output_dir):
      'Generates an image file from each slide. Returns the paths to the images.'

      presentation = PptxFile(file_path)
      no_of_slides = len(presentation.getSlides())
      presentation.destroy() #Delete extracted folder

      image = Image()

      pptx = os.path.abspath(file_path)
      output_folder = os.path.abspath(output_dir)

      image_paths = image.generateFromPpt(pptx, output_folder, no_of_slides)
      return image_paths
开发者ID:JoseCamino,项目名称:DPresenter,代码行数:14,代码来源:Parser.py

示例9: getImages

    def getImages(self):
        """ returns a dict of image_tag => Image instance """
        
        self.images = {}
        
        for img in self.client.images(all=True):
            tags = [ ImageTag.parse(t) for t in img["RepoTags"] ]

            image = Image(img["Id"])
            image.tags = tags
            
            for t in image.tags:
                if t:
                    self.images[t] = image
            
        return self.images
开发者ID:ryandoherty,项目名称:docker-sync,代码行数:16,代码来源:DockerSyncWrapper.py

示例10: image_print

def image_print(m, name='lines.png'):
    shape = m3d.shape(m)
    im = Image.new('RGB', shape)

    for j in xrange(shape[0]):
        for i in xrange(shape[1]):
            im.putpixel((i,j), m[j][i])
    im.save(name)    
开发者ID:mihandrei,项目名称:pybook,代码行数:8,代码来源:view.py

示例11: getImage

 def getImage(self, name):
     """ returns an Image for the given name, or None if not found """
     
     retVal = None
     
     img_data = self.client.inspect_image(name)
     
     if img_data:
         img_cfg = img_data.get("config", {})
         
         retVal = Image(img_data["id"])
         retVal.tags = [ name if isinstance(name, ImageTag) else ImageTag.parse(name) ]
         
         retVal.entrypoint = img_cfg.get("Entrypoint", [None])
         retVal.command = img_cfg.get("Cmd", [None])
     
     return retVal
开发者ID:carriercomm,项目名称:docker-sync,代码行数:17,代码来源:DockerSyncWrapper.py

示例12: Create_Instance

 def Create_Instance(self,instance_name,image_id,flavor_id):
     
     image = Image()
     image_href = image.get_anactiveimagehref()
     flavor = Flavor()
     flavor_href = flavor.get_specificflavorhref(flavor_id)
     
     instance = { "server": { "name": instance_name, "imageRef": image_href, "flavorRef": flavor_href} }
     params = json.dumps(instance)
     headers = { "X-Auth-Token":self.apitoken, "Content-type":"application/json" }
     conn = httplib.HTTPConnection(self.apiurlt[1])
     conn.request("POST", "%s/servers" % self.apiurlt[2], params, headers)
     request = conn.getresponse()
     instance_metadata = request.read()
     instance_metadata = json.loads(instance_metadata)
     conn.close()
     return instance_metadata
开发者ID:yxakuo,项目名称:hacloud-whu,代码行数:17,代码来源:Instance.py

示例13: compute

    def compute(self):
        im = self.get_input("Input Image")

        #check for input PixelType
        if self.has_input("Input PixelType"):
            inPixelType = self.get_input("Input PixelType")
        else:
            inPixelType = im.getPixelType()

        #check for dimension
        if self.has_input("Dimension"):
            dim = self.get_input("Dimension")
        else:
            dim = im.getDim()

        #setup filter
        inImgType = itk.Image[inPixelType._type, dim]
        up = self.get_input("Upper Value")
        lo = self.get_input("Lower Value")

        self.filter_ = itk.ThresholdImageFilter[inImgType].New(im.getImg())

        self.filter_.SetUpper(up)
        self.filter_.SetLower(lo)
#       self.filter_.ThresholdAbove(up)
        self.filter_.Update()

        #setup output image
        outIm = Image()
        outIm.setImg(self.filter_.GetOutput())
        outIm.setPixelType(inPixelType)
        outIm.setDim(dim)

        self.set_output("Output Image", outIm)
开发者ID:AnyarInc,项目名称:VisTrails,代码行数:34,代码来源:IntensityFilters.py

示例14: loadImage

 def loadImage(self,name):
     '''Open image with given name in viewer'''    
     if self.image: del self.image
     self.image = Image(name)
     if not self.image:
         return False
     
     self.flushImage()
     return True
开发者ID:PhoenixZhao,项目名称:CTDiagnosis,代码行数:9,代码来源:ImageView.py

示例15: compute

    def compute(self):
        im = self.get_input("Input Image")

        #check for input PixelType
        if self.has_input("Input PixelType"):
            inPixelType = self.get_input("Input PixelType")
        else:
            inPixelType = im.getPixelType()

        #check for output PixelType
        if self.has_input("Output PixelType"):
            outPixelType = self.get_input("Output PixelType")
        else:
            outPixelType = inPixelType

        #check for dimension
        if self.has_input("Dimension"):
            dim = self.get_input("Dimension")
        else:
            dim = im.getDim()

        #set up filter
        inImgType = itk.Image[inPixelType._type, dim]
        outImgType = itk.Image[outPixelType._type, dim]

        if self.has_input("Upper Threshold"):
            upper_threshold = self.get_input("Upper Threshold")
        else:
            upper_threshold = 255

        lower_threshold = self.get_input("Lower Threshold")

        if self.has_input("Outside Value"):
            outside_value = self.get_input("Outside Value")
        else:
            outside_value = 0

        if self.has_input("Inside Value"):
            inside_value = self.get_input("Inside Value")
        else:
            inside_value = 255

        self.filter_ = itk.BinaryThresholdImageFilter[inImgType, outImgType].New(im.getImg())
        self.filter_.SetUpperThreshold(upper_threshold)
        self.filter_.SetLowerThreshold(lower_threshold)
        self.filter_.SetOutsideValue(outside_value)
        self.filter_.SetInsideValue(inside_value)
        self.filter_.Update()

        #setup output image
        outIm = Image()
        outIm.setImg(self.filter_.GetOutput())
        outIm.setPixelType(outPixelType)
        outIm.setDim(dim)

        #set results
        self.set_output("Output Image", outIm)
        self.set_output("Filter", self)
        self.set_output("Output PixelType", outPixelType)
开发者ID:AnyarInc,项目名称:VisTrails,代码行数:59,代码来源:ThresholdFilters.py


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