Pentru ca o imagine valoreaza cat o mie de cuvinte, mi-am actualizat blog-ul cu o imagine reprezentativa.
Imaginea am construit-o din cinci imagini mai mici, in stilul facebook (poza personala combinata cu imaginea de fundal).
Programul este simplu si foloseste biblioteca PIL (Python Imaging Library) sau pillow, ambele trebuie sa fie compatibile.
#
# Construieste o imagine din altele mai mici
#
import os
from PIL import Image
def main():
lista_imagini = ('DSCF9154.JPG','DSCF9159.JPG','DSCF9161.JPG','DSCF9165.JPG')
dir_folder = r'D:\undeva\canva\un folder\cu poze'
eu = 'eu.jpg'
width = None
height = None
for filename in lista_imagini:
print filename
fullname = os.path.sep.join((dir_folder, filename))
small_img = Image.open(fullname)
if not width:
width = len(lista_imagini) * small_img.size[0]
w = small_img.size[0]
height = small_img.size[1]
new_img = Image.new('RGBA', (width, height))
x_coord = 0
new_img.paste(small_img, (x_coord, 0))
x_coord += small_img.size[0]
small_img = Image.open(eu)
new_img.paste(small_img, (w*len(lista_imagini) - 350 - small_img.size[0], 350))
new_img.show()
new_img.save('full_image1.jpg')
if __name__ == "__main__":
try:
main()
except Exception as ex:
print ex
raw_input("Enter")