本文整理汇总了Python中pgmagick.Image.fileName方法的典型用法代码示例。如果您正苦于以下问题:Python Image.fileName方法的具体用法?Python Image.fileName怎么用?Python Image.fileName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pgmagick.Image
的用法示例。
在下文中一共展示了Image.fileName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: int
# 需要导入模块: from pgmagick import Image [as 别名]
# 或者: from pgmagick.Image import fileName [as 别名]
print >> sys.stderr, "Usage: ensure_tilesize.py <FILENAME> <TILESIZE>"
sys.exit(1)
image_path = sys.argv[1]
tile_size = int(sys.argv[2])
# Make sure the file actually exists
if not os.path.exists(image_path):
print >> sys.stderr, "Could not find file!"
sys.exit(1)
# Get properties of image
image = Image(image_path)
image_width = image.size().width()
image_height = image.size().height()
image_name = image.fileName()
# If the image has the correct size, just exit
if image_width == tile_size and image_height == tile_size:
sys.exit(0)
# A new image with the correct size is needed, create it
geometry = Geometry(tile_size, tile_size)
color = Color("black")
new_image = Image(geometry, color)
# Copy original image to position 0,0 of new image
new_image.composite(image, 0, 0, co.OverCompositeOp)
# Override original image
new_image.write(image_name)
print >> sys.stdout, "Corrected " + image_name + " from " + str(image_width) + "x" + str(image_height) + " to " + str(tile_size) + "x" + str(tile_size)