python Pythonista脚本将两个图像合并在一起

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python Pythonista脚本将两个图像合并在一起相关的知识,希望对你有一定的参考价值。

# ** Universal iOS screenshot merge **
# Script will take two images of same orientation and merge them together. 
#
# By: Jason Verly (@mygeekdaddy)
# Date: 2014-10-13
# Ver: 1.02

import clipboard
import Image
import console
import photos

console.clear()

console.alert("Pick first image", "", "Select")
im1 = photos.pick_image(show_albums=True)

console.alert("Pick second image", "", "Select")
im2 = photos.pick_image(show_albums=True)

console.show_activity()

w,h = im1.size

print im1.size
print 'Ratio is ' + str((w*1.0)/h)

def image_merge(img):
	if (w*1.0)/h > 1:
		print 'Landscape screenshot...'
		#(2048, 1536)
		#Landscape screenshot
		background = Image.new('RGB', ((w+20), ((h*2)+30)), (255,255,255))
		print "Generating image..."
		background.paste(im1,(10,10))
		background.paste(im2,(10,(h+20)))
		# background.show()
		photos.save_image(background)	
	else:
		print 'Portrait screenshot...'
		#(1536, 2048)
		#Portrait screenshot
		background = Image.new('RGB', (((w*2)+30),(h+20)), (255, 255, 255))
		print "Generating image..."
		background.paste(im1,(10,10))
		background.paste(im2,((w+20),10))
		# background.show()
		photos.save_image(background)	

image = image_merge(im1)
print "\n\nImage saved to camera roll."

以上是关于python Pythonista脚本将两个图像合并在一起的主要内容,如果未能解决你的问题,请参考以下文章

python 从Bookmarklet.py导入Pythonista脚本

python Github文件查看器/ Pythonista的一般URL下载脚本

python Pythonista脚本用于创建与Trello列表相关的Launch Center Pro操作

python Pythonista(iOS)脚本从剪贴板中获取Twitter状态链接,然后喜欢/喜欢它

提供从 Siri 语音输入到可编写脚本或 pythonista 脚本的参数?

如何让 Siri 读取 Pythonista 脚本的返回值?