Bonjour,

J'ai écrit grace a tkinter et à beaucoup d'aide un diaporama qui prend en compte à chaque fois les nouvelles photos contenues dans un dossier, je les redimensionne ensuite, hors, je voudrais les redimensionner à chaque incrément une par une (pour eviter de saturer la mémoire), et inclure les données EXIF pour l'orientation de l'image, comment procéder ?
(je suis débutant, et je cherche une solution ) merci d'avance pour votre aide précieuse
Ci-joint mon code

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import glob
import os
from Tkinter import *
import Tkinter as Tk
import tkFont
import time
from PIL import Image, ImageTk
 
 
 
 
#creation fenetre tkinter
fen1 = Tk.Tk()
fen1.title('DiapoMail-SlideShow')
 
#Chargement de toutes les images dans une liste
print "Regarder dans le dossier de sortie et lister"
 
listeimage = [ ]
for s in glob.glob(os.getcwd()+"/sortie/*.jpg"):
 print s
 image = Image.open(s)
 
 ##image.resize
 baseheight = 900
 hpercent = (baseheight / float(image.size[1]))
 wsize = int((float(image.size[0]) * float(hpercent)))
 
 image=image.resize((wsize , baseheight), Image.ANTIALIAS)
 ##image.resize
 
 photo = ImageTk.PhotoImage(image)
 listeimage.append(photo)
 
def lister():
       #Chargement de toutes les images dans une liste
    print "Regarder dans le dossier de sortie et lister"
    del listeimage[:-1]
    #listeimage = []
    for s in glob.glob(os.getcwd()+"/sortie/*.jpg"):
     print s
     image = Image.open(s)
 
     ##image.resize
     baseheight = 900
     hpercent = (baseheight / float(image.size[1]))
     wsize = int((float(image.size[0]) * float(hpercent)))
 
     image=image.resize((wsize , baseheight), Image.ANTIALIAS)
     ##image.resize
 
     photo = ImageTk.PhotoImage(image)
     listeimage.append(photo)
 
 
 
## l'affichage se fera sur un label
#affichage du label dans le canvas
can1 = Canvas(fen1,bg='black',height=900,width=1950)
item=lbl=Tk.Label(can1)
can1.pack(side=TOP,expand=True, fill=BOTH)
lbl.pack()
#configuration d'image pour affichage dans le canvas
 
#increment
 
j = 0
## affichage des images
def diapo():
    global j
    ## on essaie d'afficher une image dans le canvas
    lbl.config(image = listeimage[j])
    #except: exit ## on a passe en revu toutes les images
 
 
    j+=1
    if j == len(listeimage):
        j=0
        #time.sleep()
        lister()
 
 
 
 
    fen1.after(2000, diapo)  ## on rappelle la fonction diapo dans 2 secondes
 
 
 
fen1.after(100, diapo)
#j=0
 
#Boutons de commande
bou1 = Button(fen1, text='Quitter', command = fen1.destroy)
bou1.pack(side=LEFT, padx =0, pady =0)
bou2 = Button(fen1, text='Moderer', command = fen1.destroy)
bou2.pack(side=LEFT, padx =0, pady =0)
#texte d'information dans la fenetre
text1 = Label(fen1, text = 'Pour participer au diaporama :')
text1.pack(side =TOP, padx =3, pady =3)
text2 = Label(fen1, text = 'gege@outlook.fr')
text2.pack(side =BOTTOM, padx =3, pady =3)
#Configuration du texte dans la fenetre
font10 = "-family {FreeSans} -size 28 "
text1.configure(font=font10,fg='black')
text2.configure(font=font10,fg='red')
 
j=0
 
 
#demarrage
 
 
fen1.mainloop()
En gros j'ai ça :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
can1 = Canvas(fen1,bg='black',height=900,width=1950)
item=lbl=Tk.Label(can1) #insersion du label dans le canevas
can1.pack(side=TOP,expand=True, fill=BOTH)
lbl.pack()
que je veux lier avec ça

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
#Redimensionner l'image avant l'insersion dans PIL
baseheight = 900
hpercent = (baseheight / float(image.size[1]))
wsize = int((float(image.size[0]) * float(hpercent)))
 
image=image.resize((wsize , baseheight), Image.ANTIALIAS)
 
#Utilisation de PIL
 
photo = ImageTk.PhotoImage(image)
listeimage.append(photo)