用Python Script做PS:PIL多图合并DIY桌面之纪伯伦小诗
我的心曾经不爽八次
第一次,它告诉全世界它只做自己,但它更想取悦他人。
第二次,每个无关紧要的情绪,都会被它无限放大。
第三次,它以无私之名付出,得不到回报却比谁都气恼。
第四次,它总觉得自己可以做得更好,却没有为此付出辛劳。
第五次,它看不起自己,却借此对他人嗤之以鼻。
第六次,它常回忆过去,陷入自己营造的忧伤。
第七次,它也幻想未来,困于自己假想的纷扰。
第八次,它明知自己的想法不着边际毫无意义,虽想终止,却又停不下来。
看完觉得中了好多箭,决定将这几幅萌图弄成桌面以时常内省。
不得不怒赞resize滤镜Image.ANTIALIAS,缩小图片后几乎没有降低图片质量。
不使用滤镜,放大到桌面那么大小字根本看不清楚
代码挺朴素的
1 import Image 2 root = 'D:/Users/Administrator/Desktop/' 3 im = list() 4 for i in range(10): 5 im.append(Image.open(root + str(i) + '.jpg')) 6 ratio = 0.0 7 for i in im: 8 x, y = i.size 9 ratio += float(y)/x 10 ratio /= len(im) 11 x, y = im[9].size 12 ratio9 = float(y)/x 13 y = 800/3 14 x = int(y/ratio) 15 a = int(1280-3*x) 16 b = int(a*ratio9) 17 im = [i.resize((x, y), Image.ANTIALIAS) for i in im] 18 im[9] = im[9].resize((a, b), Image.ANTIALIAS) 19 ims = Image.new('RGB', (1280, 800), color='white') 20 ims.paste(im[9], (0, (800-b))) 21 ims.paste(im[0], (a, 0)) 22 ims.paste(im[1], (a+x, 0)) 23 ims.paste(im[2], (a+x*2, 0)) 24 ims.paste(im[3], (a, y)) 25 ims.paste(im[4], (a+x, y)) 26 ims.paste(im[5], (a+x*2, y)) 27 ims.paste(im[6], (a, y*2)) 28 ims.paste(im[7], (a+x, y*2)) 29 ims.paste(im[8], (a+x*2, y*2)) 30 ims.save(root+'sorrow.jpg')
卡里·纪伯伦:我的心曾悲伤七次
第一次,当它本可进取时,却故作谦卑;
第二次,当它在空虚时,用爱欲来填充;
第三次,在困难和容易之间,它选择了容易;
第四次,它犯了错,却借由别人也会犯错来宽慰自己;
第五次,它自由软弱,却把它认为是生命的坚韧;
第六次,当它鄙夷一张丑恶的嘴脸时,却不知那正是自己面具中的一副;
第七次,它侧身于生活的污泥中,虽不甘心,却又畏首畏尾。
Kahlil Gibran,1883—1931
The first time when I saw her being meek that she might attain height.
The second time when I saw her limping before the crippled.
The third time when she was given to choose between the hard and the easy,
and she chose the easy.
The fourth time when she committed a wrong,
and comforted herself that others also commit wrong.
The fifth time when she forbore for weakness, and attributed her patience to strength.
The sixth time when she despised the ugliness of a face,
and knew not that it was one of her own masks.
And the seventh time when she sang a song of praise, and deemed it a virtue.