[图片来自Nathan Barry的Instagram,
http://instagram.com/nathanbarry/]
图片的操作:
import media
path = media.choose_file()
pic = media.load_picture(path)
media.show(pic)
for p in media.get_pixels(pic):
new_blue = int(0.6 * media.get_blue(p))
new_green = int(0.6 * media.get_green(p))
media.set_blue(p, new_blue)
media.set_green(p, new_green)
media.show(pic)
print pic.title
new_name = raw_input("Enter the name to save the new file:")
new_name += '.jpg'
media.save_as(pic, new_name)
print pic.title
将图片的每个像素的蓝 {MOD}和绿 {MOD}降低为原来的60%,以便让图片看起来更暗,更红些。像是在暮光下拍的。
Python Shell:
[evaluate sunset.py]
C:/Python27/nearFlorence.jpg
Enter the name to save the new file:nearFlorenceSunset
nearFlorenceSunset.jpg