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


Python Image.destroy方法代码示例

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


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

示例1: generate_sprite

# 需要导入模块: from wand.image import Image [as 别名]
# 或者: from wand.image.Image import destroy [as 别名]
def generate_sprite(image_dir, images):
    """ (str, list of Image) -> str

    Generate sprites with 4 images

    Returns the name of the generated sprite
    """
    image_width = 160
    image_height = 232
    sprite = None
    left_position = 0
    for image in images:
        i = get_resized_image(image=image, width=image_width, height=image_height)
        if sprite is None:
            if i.height == i.width:
                sprite = Image(width=image_width*4, height=image_width, background=Color("#fff"))
            else:
                sprite = Image(width=image_width*4, height=image_height, background=Color("#fff"))
        sprite.composite(image=i, left=left_position, top=0)
        left_position += image_width
        i.destroy()
    sprite_file = "%s/sprite.jpg" % (image_dir)

    if not isdir(image_dir):
        makedirs(image_dir)

    sprite.save(filename=sprite_file)
    sprite.destroy()

    return sprite_file
开发者ID:dafiti,项目名称:ImageProcessing,代码行数:32,代码来源:images.py

示例2: compose_base_image

# 需要导入模块: from wand.image import Image [as 别名]
# 或者: from wand.image.Image import destroy [as 别名]
    def compose_base_image(self):
        # compose the base image

        # "stop" image
        img_stop = Image(filename=self.path_img_stop)
        scale = int(img_stop.height * self.img_stop_width_target / img_stop.width)
        img_stop.resize(self.img_stop_width_target, scale)

        # "payoff" image
        img_payoff = Image(filename=self.path_img_payoff)
        scale = int(img_payoff.height * self.img_payoff_width_target / img_payoff.width)
        img_payoff.resize(self.img_payoff_width_target, scale)

        # name
        img_name = Image(filename=self.path_img_name)
        scale = int(img_name.height * self.img_name_width_target / img_name.width)
        img_name.resize(self.img_name_width_target, scale)

        # logo
        img_logo = Image(filename=self.path_img_logo)
        scale = int(img_logo.height * self.img_logo_width_target / img_logo.width)
        img_logo.resize(self.img_logo_width_target, scale)

        # calc the offsets
        self.stop_y_offset = int(self.height*0.11)
        self.stop_x_offset = 0

        self.text_y_offset = int(self.stop_y_offset+img_stop.height)
        self.text_x_offset = 0

        self.name_y_offset = int(self.height*0.88)
        self.name_x_offset = int(self.width*0.08)

        self.payoff_y_offset = int(self.height*0.888)
        self.payoff_x_offset = int(self.width*0.57)

        self.logo_y_offset = int(self.height*0.858)
        self.logo_x_offset = int(self.width*0.80)

        # compose the base image
        base_img = Image(
            height=self.height,
            width=self.width,
            background=COLOR_DARK)

        base_img.composite(img_stop,
                           left=self.stop_x_offset,
                           top=self.stop_y_offset)

        base_img.composite(img_name,
                           left=self.name_x_offset,
                           top=self.name_y_offset)
        base_img.composite(img_payoff,
                           left=self.payoff_x_offset,
                           top=self.payoff_y_offset)
        base_img.composite(img_logo,
                           left=self.logo_x_offset,
                           top=self.logo_y_offset)

        if self.width >= 200:
            with Drawing() as footer_draw:
                footer_draw.font = self.lzy_path_font
                footer_draw.font_size = 14
                footer_draw.fill_color = COLOR_DIM
                footer_draw.gravity = "south_east"
                footer_draw.text(5, 5, "csigerstop.lzy.dk")
                footer_draw.draw(base_img)

        img_stop.destroy()
        img_payoff.destroy()
        img_name.destroy()
        img_logo.destroy()

        return base_img
开发者ID:tbug,项目名称:csigerstop,代码行数:76,代码来源:render.py

示例3: Card

# 需要导入模块: from wand.image import Image [as 别名]
# 或者: from wand.image.Image import destroy [as 别名]
class Card(object):
	"""Individual object containing an image and actions to manipulate it.
	Posible kwargs to __init__ are filename, file, image, blob. it will load the image from there"""
	def __init__(self, *args, **kwargs):
		"""Init a new cards with *img* being a wand.image.Image object"""
		self.img = Image(*args, **kwargs)
		self.border = None
		self.changed = True
		self.pixmap()

	def __del__(self):
		self.img.destroy()

	def format(self, fmt=None):
		if fmt is None:
			return self.img.format.lower()
		else:
			self.img.format = fmt

	@set_changed
	def resize(self, width, height, newres=300):
		"""Resize this card to (*width*, *height*) inches, with a resolution of *newres*"""
		self.img.transform(resize=str(int(width*newres)) + "x" + str(int(height*newres)) + "!")
		self.img.reset_coords()
		self.img.resolution = (newres, newres)
		return newres

	def width(self):
		return self.img.size[0]

	def height(self):
		return self.img.size[1]

	def reset_coords(self):
		self.img.reset_coords()

	@set_changed
	def set_border(self, border):
		"""Set a new *border* for this card"""
		if self.border is not None:
			self.del_border()
		self.border = border
		with Color(self.border.colour) as colour:
			self.img.border(colour, self.border.wide, self.border.wide)

	@set_changed
	def crop(self, *args, **kwargs):
		"""Crop this card *top*, *bottom*, *left* and *right* pixels"""
		w, h = self.img.size
		if "right" in kwargs:
			kwargs["right"] = w - kwargs["right"]
		if "bottom" in kwargs:
			kwargs["bottom"] = h - kwargs["bottom"]
		self.img.crop(*args, **kwargs)
		self.reset_coords()

	def del_border(self):
		"""Remove the border of this card"""
		if self.border is not None:
			w = self.border.wide
			self.crop(top=w, bottom=w, right=w, left=w)
			self.border = None
			self.changed = True

	@set_changed
	def trim(self, fuzz=13):
		self.img.trim(fuzz=fuzz)
		self.reset_coords()

	def save_as(self, filename):
		"""Save this card in a file named *filename*"""
		self.img.save(filename = filename)

	def split(self, rows, cols, separation=0):
		"""Divide this cards in *rows* by *cols* cards, and returns a list"""
		width, hight = self.img.size
		width, hight = (int(width), int(hight))
		cardWidth = (width - separation * (cols-1)) / cols
		cardHight = (hight - separation * (rows-1)) / rows
		res = []
		for i in range(rows):
			for j in range(cols):
				with self.img.clone() as clon:
					clon.crop(top=i*cardHight+i*separation, width=cardWidth, left=j*cardWidth+j*separation, height=cardHight)
					clon.reset_coords()
					res.append(Card(image=clon))
		return res

	@set_changed
	def round_corners(self):
		"""Round the corners of the card (setting them to alpha)"""
		pass

	def clone(self):
		c = Card(image=self.img.clone())
		c.border = self.border
		return c

	def pixmap(self):
		"""Update and returns the pixmap (QPixmap) of the contained image"""
#.........这里部分代码省略.........
开发者ID:Ja-vi,项目名称:pnp,代码行数:103,代码来源:card.py


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