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


Python Image.magick方法代码示例

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


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

示例1: convertGMtoPIL

# 需要导入模块: from pgmagick import Image [as 别名]
# 或者: from pgmagick.Image import magick [as 别名]
def convertGMtoPIL(gmimage):
    """
    Convert GraphicsMagick image to PIL

    work with grayscale and colour
    """
    img = Image(gmimage)  # make copy
    gmimage.depth(8)
    img.magick("RGB")
    w, h = img.columns(), img.rows()
    blob = Blob()
    img.write(blob)
    data = blob.data

    # convert string array to an RGB PIL image
    pilimage = PilImage.fromstring("RGB", (w, h), data)
    return pilimage
开发者ID:uq-eresearch,项目名称:uqam,代码行数:19,代码来源:source_generators.py

示例2: gera_xyz

# 需要导入模块: from pgmagick import Image [as 别名]
# 或者: from pgmagick.Image import magick [as 别名]
def gera_xyz(imagem):
    '''
    * reduz a imagem a 25% da dimensão em pixels e converte para GIF 64 cores;
    * gera um arquivo .txt com os dados pixel a pixel, quanto às cores em RGB
      e xyz
    '''

    print messages.strings['welcome']
    print messages.strings['crexyz']

    img_base = Blob(open(imagem).read())
    img_alvo = Image(img_base)
    img_alvo.magick('GIF')
    img_alvo.colorSpace = 'XYZ'
    img_alvo.scale('25%')
    img_alvo.quantizeColors(64)
    img_alvo.quantizeDither(img_alvo.quantize(64))
    img_alvo.write('./tmp.txt')

    with open('./tmp.txt', 'r') as tt:
        return tt.readlines()
开发者ID:jeanmenezes,项目名称:pictophon,代码行数:23,代码来源:pictophon.py

示例3: buildNodeImage

# 需要导入模块: from pgmagick import Image [as 别名]
# 或者: from pgmagick.Image import magick [as 别名]
	def buildNodeImage(self,node):
		

		self.buildCounterNode+=1

		node['name'] = node['name'].encode("utf-8")


		print "{0:.2f}".format(self.buildCounterNode / (self.buildCounterNodeTotal) * 100)," percent complete of this batch                                         \r",

		scale = self.scaleFactor

		#if node['size'] > 10:

		#cale = 4.75

		#if node['size'] < 900:
		#	scale = 4




		circleHeight = int(float(node['size'])*scale)
		circleWidth = int(float(node['size'])*scale)


		canvasHeight = int(circleHeight *2)
		canvasWidth = int(circleWidth* 2) 


		im = Image(Geometry(10,10), 'transparent')
		fontsize = self.returnFontSize(canvasHeight)
		im.fontPointsize(fontsize)
		tm = TypeMetric()
		im.fontTypeMetrics(node['name'], tm)

		if tm.textWidth() > canvasWidth:
			canvasWidth = int(tm.textWidth()) + 5

		im = Image(Geometry(canvasWidth,canvasHeight), 'transparent')
		im.density("72x72")
		im.magick('RGB')
		im.resolutionUnits(ResolutionType.PixelsPerInchResolution)

		im.strokeAntiAlias(True)

		color = (node['rgb'][0],node['rgb'][1],node['rgb'][2])

		color = self.rgb_to_hex( color )
		im.fillColor(color);

		im.strokeWidth(2);

		if circleWidth <= 20:
			im.strokeColor("transparent");
		else:
			im.strokeColor("black");

		if circleWidth <= 50:
			im.strokeWidth(1);


		circle = DrawableCircle( canvasWidth/2 , canvasHeight/2, (canvasWidth/2) + (circleWidth/2), (canvasHeight/2) + (circleHeight/2))
		im.draw(circle)

		im.fillColor("white");
		im.strokeColor("black");
		im.strokeWidth(1);



		fontsize = self.returnFontSize(canvasHeight)
		im.fontPointsize(fontsize)

		

		tm = TypeMetric()
		im.fontTypeMetrics(node['name'], tm)

		textWidth = tm.textWidth()
		textHeight = tm.textHeight()


		if fontsize <= 30:
			im.strokeColor("transparent")
		

		text = DrawableText((canvasWidth / 2) - (textWidth/2), canvasHeight/2 + 6 , node['name'])
		im.draw(text)
		


		im.write(self.dataCircles + str(node['id']) + '.png')
开发者ID:thisismattmiller,项目名称:catalog-network,代码行数:95,代码来源:process.py


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