annotate verysimpleslideshow/verysimpleslideshow.py @ 15:18816a0c1fc2

bing4desktop-0.240206-4
author prymula <prymula76@outlook.com>
date Tue, 06 Feb 2024 19:40:55 +0100
parents 82b75cc1e524
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
prymula <prymula76@outlook.com>
parents:
diff changeset
1 #!/usr/bin/env python3
prymula <prymula76@outlook.com>
parents:
diff changeset
2 # Very Simple Slide Show
prymula <prymula76@outlook.com>
parents:
diff changeset
3 # autor: Prymula (PRP)
prymula <prymula76@outlook.com>
parents:
diff changeset
4 # licencja: Public Domain
prymula <prymula76@outlook.com>
parents:
diff changeset
5 # data 02-09-2023
prymula <prymula76@outlook.com>
parents:
diff changeset
6 # edytor: Geany
prymula <prymula76@outlook.com>
parents:
diff changeset
7
prymula <prymula76@outlook.com>
parents:
diff changeset
8 import os, sys
prymula <prymula76@outlook.com>
parents:
diff changeset
9 import tempfile
prymula <prymula76@outlook.com>
parents:
diff changeset
10 import shutil
prymula <prymula76@outlook.com>
parents:
diff changeset
11 from sys import platform
prymula <prymula76@outlook.com>
parents:
diff changeset
12 from PIL import Image
prymula <prymula76@outlook.com>
parents:
diff changeset
13 from itertools import filterfalse
prymula <prymula76@outlook.com>
parents:
diff changeset
14
prymula <prymula76@outlook.com>
parents:
diff changeset
15 VER = "0.230913-0"
prymula <prymula76@outlook.com>
parents:
diff changeset
16
prymula <prymula76@outlook.com>
parents:
diff changeset
17 if platform == "linux" or platform == "linux2":
prymula <prymula76@outlook.com>
parents:
diff changeset
18 SLA = '/'
prymula <prymula76@outlook.com>
parents:
diff changeset
19 elif platform == "darwin":
prymula <prymula76@outlook.com>
parents:
diff changeset
20 SLA = '/'
prymula <prymula76@outlook.com>
parents:
diff changeset
21 elif platform == "win32":
prymula <prymula76@outlook.com>
parents:
diff changeset
22 SLA = '\\'
prymula <prymula76@outlook.com>
parents:
diff changeset
23
prymula <prymula76@outlook.com>
parents:
diff changeset
24 #count = 0
prymula <prymula76@outlook.com>
parents:
diff changeset
25 tmp_path = tempfile.mkdtemp()
prymula <prymula76@outlook.com>
parents:
diff changeset
26 #mp_path = dir_path = os.getcwd()
prymula <prymula76@outlook.com>
parents:
diff changeset
27 #list_path = dir_path = os.getcwd()
prymula <prymula76@outlook.com>
parents:
diff changeset
28 tmp_list = tmp_path + SLA + "list.txt"
prymula <prymula76@outlook.com>
parents:
diff changeset
29 # NIE USUWAC !
prymula <prymula76@outlook.com>
parents:
diff changeset
30 #command = "ffmpeg -framerate 0.3 -pattern_type glob -i '"+tmp_path+"/*.jpg' -c:v libopenh264 -profile:v high -crf 20 -pix_fmt yuv420p output.mp4"
1
82b75cc1e524 postagelabels-0.220120-0.1
prymula <prymula76@outlook.com>
parents: 0
diff changeset
31 command = "ffmpeg -f concat -r 0.2 -safe 0 -i '"+tmp_list+"' -framerate 1 -c:v libx264 -profile:v high -crf 20 -pix_fmt yuv420p -filter:a 'atempo=0.5' output.mp4"
0
prymula <prymula76@outlook.com>
parents:
diff changeset
32 #command = "ffmpeg -f concat -y -r 0.2 -safe 0 -i '"+tmp_list+"' -framerate 1 -c:v mpeg4 -crf 20 -pix_fmt yuv420p output.mp4"
prymula <prymula76@outlook.com>
parents:
diff changeset
33
prymula <prymula76@outlook.com>
parents:
diff changeset
34 #num = 0
prymula <prymula76@outlook.com>
parents:
diff changeset
35 sample = None
prymula <prymula76@outlook.com>
parents:
diff changeset
36 try:
prymula <prymula76@outlook.com>
parents:
diff changeset
37 sample = Image.Resampling.LANCZOS
prymula <prymula76@outlook.com>
parents:
diff changeset
38 print ("Uzywam LANCZOS")
prymula <prymula76@outlook.com>
parents:
diff changeset
39 except AttributeError:
prymula <prymula76@outlook.com>
parents:
diff changeset
40 sample = Image.ANTIALIAS
prymula <prymula76@outlook.com>
parents:
diff changeset
41 print ("Uzywam: ANTIALIAS")
prymula <prymula76@outlook.com>
parents:
diff changeset
42
prymula <prymula76@outlook.com>
parents:
diff changeset
43
prymula <prymula76@outlook.com>
parents:
diff changeset
44 class App():
prymula <prymula76@outlook.com>
parents:
diff changeset
45
prymula <prymula76@outlook.com>
parents:
diff changeset
46 BASE_APSC = 724
prymula <prymula76@outlook.com>
parents:
diff changeset
47 LONG = 1080
prymula <prymula76@outlook.com>
parents:
diff changeset
48 HALF = 540
prymula <prymula76@outlook.com>
parents:
diff changeset
49 BASE_MICRO = 810
prymula <prymula76@outlook.com>
parents:
diff changeset
50 BASE = None
prymula <prymula76@outlook.com>
parents:
diff changeset
51 #n_pictures = 0
prymula <prymula76@outlook.com>
parents:
diff changeset
52 count = 0
prymula <prymula76@outlook.com>
parents:
diff changeset
53
prymula <prymula76@outlook.com>
parents:
diff changeset
54 def list_files(self, dir_path):
prymula <prymula76@outlook.com>
parents:
diff changeset
55 res = []
prymula <prymula76@outlook.com>
parents:
diff changeset
56 try:
prymula <prymula76@outlook.com>
parents:
diff changeset
57 for file_path in os.listdir(dir_path):
prymula <prymula76@outlook.com>
parents:
diff changeset
58 if os.path.isfile(os.path.join(dir_path, file_path)):
prymula <prymula76@outlook.com>
parents:
diff changeset
59 res.append(os.path.join(dir_path, file_path))
prymula <prymula76@outlook.com>
parents:
diff changeset
60 except FileNotFoundError:
prymula <prymula76@outlook.com>
parents:
diff changeset
61 print(f"The directory {dir_path} does not exist")
prymula <prymula76@outlook.com>
parents:
diff changeset
62 except PermissionError:
prymula <prymula76@outlook.com>
parents:
diff changeset
63 print(f"Permission denied to access the directory {dir_path}")
prymula <prymula76@outlook.com>
parents:
diff changeset
64 except OSError as e:
prymula <prymula76@outlook.com>
parents:
diff changeset
65 print(f"An OS error occurred: {e}")
prymula <prymula76@outlook.com>
parents:
diff changeset
66 return res
prymula <prymula76@outlook.com>
parents:
diff changeset
67
prymula <prymula76@outlook.com>
parents:
diff changeset
68 def file_exclusion(self, files):
prymula <prymula76@outlook.com>
parents:
diff changeset
69 for f in files[:]:
prymula <prymula76@outlook.com>
parents:
diff changeset
70 if f.rfind('.jpg') == -1:
prymula <prymula76@outlook.com>
parents:
diff changeset
71 #print('usuwam: '+f)
prymula <prymula76@outlook.com>
parents:
diff changeset
72 files.remove(f)
prymula <prymula76@outlook.com>
parents:
diff changeset
73 return files
prymula <prymula76@outlook.com>
parents:
diff changeset
74
prymula <prymula76@outlook.com>
parents:
diff changeset
75 def get_files(self):
prymula <prymula76@outlook.com>
parents:
diff changeset
76 dir_path = os.getcwd()
prymula <prymula76@outlook.com>
parents:
diff changeset
77 print ("GETCWD: "+dir_path)
prymula <prymula76@outlook.com>
parents:
diff changeset
78 files = self.list_files(dir_path)
prymula <prymula76@outlook.com>
parents:
diff changeset
79 return a.file_exclusion(files)
prymula <prymula76@outlook.com>
parents:
diff changeset
80
prymula <prymula76@outlook.com>
parents:
diff changeset
81 def create_horizontal_surface(self):
prymula <prymula76@outlook.com>
parents:
diff changeset
82 return Image.new('RGB', (a.LONG, a.BASE))
prymula <prymula76@outlook.com>
parents:
diff changeset
83
prymula <prymula76@outlook.com>
parents:
diff changeset
84 def create_vertical_surface(self):
prymula <prymula76@outlook.com>
parents:
diff changeset
85 return Image.new('RGB', (a.BASE, a.LONG))
prymula <prymula76@outlook.com>
parents:
diff changeset
86
prymula <prymula76@outlook.com>
parents:
diff changeset
87 def put_horizontal_image(self, image):
prymula <prymula76@outlook.com>
parents:
diff changeset
88 global sample
prymula <prymula76@outlook.com>
parents:
diff changeset
89 new = Image.new("RGB", (a.LONG, a.BASE))
prymula <prymula76@outlook.com>
parents:
diff changeset
90 if image.size[0] != a.LONG:
prymula <prymula76@outlook.com>
parents:
diff changeset
91 image = image.resize((a.LONG, a.BASE), sample, None, 3.0)
prymula <prymula76@outlook.com>
parents:
diff changeset
92 new.paste(image, (0,0), mask = image)
prymula <prymula76@outlook.com>
parents:
diff changeset
93 return new
prymula <prymula76@outlook.com>
parents:
diff changeset
94
prymula <prymula76@outlook.com>
parents:
diff changeset
95 def put_vertical_image(self, image):
prymula <prymula76@outlook.com>
parents:
diff changeset
96 global sample
prymula <prymula76@outlook.com>
parents:
diff changeset
97 new = Image.new("RGB", (a.BASE, a.LONG))
prymula <prymula76@outlook.com>
parents:
diff changeset
98 if image.size[0] != a.BASE:
prymula <prymula76@outlook.com>
parents:
diff changeset
99 image = image.resize((a.BASE, a.LONG), sample, None, 3.0)
prymula <prymula76@outlook.com>
parents:
diff changeset
100 new.paste(image, (0,0), mask = image)
prymula <prymula76@outlook.com>
parents:
diff changeset
101 return new
prymula <prymula76@outlook.com>
parents:
diff changeset
102
prymula <prymula76@outlook.com>
parents:
diff changeset
103 # dodaje portrety do kraiobrazu
prymula <prymula76@outlook.com>
parents:
diff changeset
104 def join_image_to_horizontal(self, image, destinity):
prymula <prymula76@outlook.com>
parents:
diff changeset
105 global sample # n_pictures
prymula <prymula76@outlook.com>
parents:
diff changeset
106 single = False
prymula <prymula76@outlook.com>
parents:
diff changeset
107 print ("DLUGOSC: "+str(len(image)))
prymula <prymula76@outlook.com>
parents:
diff changeset
108 if len(image) == 1: # and n_pictures > 0: # 1
prymula <prymula76@outlook.com>
parents:
diff changeset
109 print ("SINGIELEK")
prymula <prymula76@outlook.com>
parents:
diff changeset
110 #num += 1 # tymczasowy
prymula <prymula76@outlook.com>
parents:
diff changeset
111 tmp = image[-1]. resize((a.HALF, a.BASE), sample, None, 3.0)
prymula <prymula76@outlook.com>
parents:
diff changeset
112 destinity.paste(tmp, (300,0), mask = tmp)
prymula <prymula76@outlook.com>
parents:
diff changeset
113 image.pop()
prymula <prymula76@outlook.com>
parents:
diff changeset
114 single = True
prymula <prymula76@outlook.com>
parents:
diff changeset
115 elif len(image) > 0:
prymula <prymula76@outlook.com>
parents:
diff changeset
116 #num += 1 # tymczasowy
prymula <prymula76@outlook.com>
parents:
diff changeset
117 tmp = image[-1].resize((a.HALF, a.BASE), sample, None, 3.0)
prymula <prymula76@outlook.com>
parents:
diff changeset
118 destinity.paste(tmp, (0,0), mask = tmp)
prymula <prymula76@outlook.com>
parents:
diff changeset
119 image.pop()
prymula <prymula76@outlook.com>
parents:
diff changeset
120 if len(image) > 0:
prymula <prymula76@outlook.com>
parents:
diff changeset
121 #num += 1 # tymczasowy
prymula <prymula76@outlook.com>
parents:
diff changeset
122 tmp = image[-1]. resize((a.HALF, a.BASE), sample, None, 3.0)
prymula <prymula76@outlook.com>
parents:
diff changeset
123 destinity.paste(tmp, (a.HALF,0), mask = tmp)
prymula <prymula76@outlook.com>
parents:
diff changeset
124 image.pop()
prymula <prymula76@outlook.com>
parents:
diff changeset
125
prymula <prymula76@outlook.com>
parents:
diff changeset
126 return destinity, len(image), single
prymula <prymula76@outlook.com>
parents:
diff changeset
127
prymula <prymula76@outlook.com>
parents:
diff changeset
128 # dodaje kraiobrazy do portretu
prymula <prymula76@outlook.com>
parents:
diff changeset
129 def join_image_to_vertical(self, image, destinity):
prymula <prymula76@outlook.com>
parents:
diff changeset
130 global sample # n_pictures
prymula <prymula76@outlook.com>
parents:
diff changeset
131 single = False
prymula <prymula76@outlook.com>
parents:
diff changeset
132 print ("DLUGOSC: "+str(len(image)))
prymula <prymula76@outlook.com>
parents:
diff changeset
133 if len(image) == 1: # and a.n_pictures > 0: # 1
prymula <prymula76@outlook.com>
parents:
diff changeset
134 print ("SINGIELEK")
prymula <prymula76@outlook.com>
parents:
diff changeset
135 #num += 1 # tymczasowy
prymula <prymula76@outlook.com>
parents:
diff changeset
136 tmp = image[-1]. resize((a.BASE, a.HALF), sample, None, 3.0)
prymula <prymula76@outlook.com>
parents:
diff changeset
137 destinity.paste(tmp, (0,300), mask = tmp)
prymula <prymula76@outlook.com>
parents:
diff changeset
138 image.pop()
prymula <prymula76@outlook.com>
parents:
diff changeset
139 single = True
prymula <prymula76@outlook.com>
parents:
diff changeset
140 #a.n_pictures -= 1
prymula <prymula76@outlook.com>
parents:
diff changeset
141 elif len(image) > 0:
prymula <prymula76@outlook.com>
parents:
diff changeset
142 #num += 1 # tymczasowy
prymula <prymula76@outlook.com>
parents:
diff changeset
143 tmp = image[-1].resize((a.BASE, a.HALF), sample, None, 3.0)
prymula <prymula76@outlook.com>
parents:
diff changeset
144 destinity.paste(tmp, (0,0), mask = tmp)
prymula <prymula76@outlook.com>
parents:
diff changeset
145 image.pop()
prymula <prymula76@outlook.com>
parents:
diff changeset
146 #a.n_pictures -= 1
prymula <prymula76@outlook.com>
parents:
diff changeset
147 if len(image) > 0:
prymula <prymula76@outlook.com>
parents:
diff changeset
148 #num += 1 # tymczasowy
prymula <prymula76@outlook.com>
parents:
diff changeset
149 tmp = image[-1]. resize((a.BASE, a.HALF), sample, None, 3.0)
prymula <prymula76@outlook.com>
parents:
diff changeset
150 destinity.paste(tmp, (0, a.HALF), mask = tmp)
prymula <prymula76@outlook.com>
parents:
diff changeset
151 image.pop()
prymula <prymula76@outlook.com>
parents:
diff changeset
152 #a.n_pictures -= 1
prymula <prymula76@outlook.com>
parents:
diff changeset
153
prymula <prymula76@outlook.com>
parents:
diff changeset
154 return destinity, len(image), single
prymula <prymula76@outlook.com>
parents:
diff changeset
155
prymula <prymula76@outlook.com>
parents:
diff changeset
156 def read_images_from_directory(self, files):
prymula <prymula76@outlook.com>
parents:
diff changeset
157 #global n_pictures
prymula <prymula76@outlook.com>
parents:
diff changeset
158 images_vertical = []
prymula <prymula76@outlook.com>
parents:
diff changeset
159 images_horizontal = []
prymula <prymula76@outlook.com>
parents:
diff changeset
160 if len(files) == 0:
prymula <prymula76@outlook.com>
parents:
diff changeset
161 print ('Brak plików JPG !')
prymula <prymula76@outlook.com>
parents:
diff changeset
162 a.cleanup()
prymula <prymula76@outlook.com>
parents:
diff changeset
163 exit (1)
prymula <prymula76@outlook.com>
parents:
diff changeset
164 for f in files:
prymula <prymula76@outlook.com>
parents:
diff changeset
165 image = Image.open(f).convert('RGBA')
prymula <prymula76@outlook.com>
parents:
diff changeset
166 if image.size[1] > image.size[0]:
prymula <prymula76@outlook.com>
parents:
diff changeset
167 s = float(image.size[0] / image.size[1])
prymula <prymula76@outlook.com>
parents:
diff changeset
168 if s > 0.6 and s < 0.69:
prymula <prymula76@outlook.com>
parents:
diff changeset
169 a.BASE = a.BASE_APSC
prymula <prymula76@outlook.com>
parents:
diff changeset
170 print ("obraz vertical APSC: "+f+" s:"+str(s))
prymula <prymula76@outlook.com>
parents:
diff changeset
171 images_vertical.insert(-1, image)
prymula <prymula76@outlook.com>
parents:
diff changeset
172 #a.n_pictures += 1
prymula <prymula76@outlook.com>
parents:
diff changeset
173 elif s > 0.7 and s < 0.79:
prymula <prymula76@outlook.com>
parents:
diff changeset
174 a.BASE = a.BASE_MICRO
prymula <prymula76@outlook.com>
parents:
diff changeset
175 print ("obraz vertical MICRO: "+f+" s:"+str(s))
prymula <prymula76@outlook.com>
parents:
diff changeset
176 images_vertical.insert(-1, image)
prymula <prymula76@outlook.com>
parents:
diff changeset
177 #a.n_pictures += 1
prymula <prymula76@outlook.com>
parents:
diff changeset
178 else:
prymula <prymula76@outlook.com>
parents:
diff changeset
179 print ("Ver - Niedozwolony rozmiar zdjęcia s: "+str(s) + " Foto: "+f)
prymula <prymula76@outlook.com>
parents:
diff changeset
180
prymula <prymula76@outlook.com>
parents:
diff changeset
181 if image.size[0] > image.size[1]:
prymula <prymula76@outlook.com>
parents:
diff changeset
182 s = float(image.size[0] / image.size[1])
prymula <prymula76@outlook.com>
parents:
diff changeset
183 if s > 1.4 and s <= 1.51:
prymula <prymula76@outlook.com>
parents:
diff changeset
184 a.BASE = a.BASE_APSC
prymula <prymula76@outlook.com>
parents:
diff changeset
185 print ("obraz horizontal APSC: "+f+" s:"+str(s));
prymula <prymula76@outlook.com>
parents:
diff changeset
186 images_horizontal.insert(-1, image)
prymula <prymula76@outlook.com>
parents:
diff changeset
187 #a.n_pictures += 1
prymula <prymula76@outlook.com>
parents:
diff changeset
188 elif s > 1.3 and s < 1.39:
prymula <prymula76@outlook.com>
parents:
diff changeset
189 a.BASE = a.BASE_MICRO
prymula <prymula76@outlook.com>
parents:
diff changeset
190 print ("obraz horizontal MICRO: "+f+" s:"+str(s));
prymula <prymula76@outlook.com>
parents:
diff changeset
191 images_horizontal.insert(-1, image)
prymula <prymula76@outlook.com>
parents:
diff changeset
192 #a.n_pictures += 1
prymula <prymula76@outlook.com>
parents:
diff changeset
193 else:
prymula <prymula76@outlook.com>
parents:
diff changeset
194 print ("Hor - Niedozwolony rozmiar zdjęcia s: "+str(s) + " Foto: "+f)
prymula <prymula76@outlook.com>
parents:
diff changeset
195
prymula <prymula76@outlook.com>
parents:
diff changeset
196
prymula <prymula76@outlook.com>
parents:
diff changeset
197
prymula <prymula76@outlook.com>
parents:
diff changeset
198 #print ("N_PICTURES: "+str(a.n_pictures))
prymula <prymula76@outlook.com>
parents:
diff changeset
199 return images_vertical, images_horizontal
prymula <prymula76@outlook.com>
parents:
diff changeset
200
prymula <prymula76@outlook.com>
parents:
diff changeset
201 def cleanup(self):
prymula <prymula76@outlook.com>
parents:
diff changeset
202 # NIEBEZPIECZNA ! lepiej niczym innym nie nadpisywać tych zmiennych
prymula <prymula76@outlook.com>
parents:
diff changeset
203 shutil.rmtree(tmp_path)
prymula <prymula76@outlook.com>
parents:
diff changeset
204
prymula <prymula76@outlook.com>
parents:
diff changeset
205 def save_vertical_to_horizontal(self, images_vertical, jpg_names):
prymula <prymula76@outlook.com>
parents:
diff changeset
206 #global count
prymula <prymula76@outlook.com>
parents:
diff changeset
207 for i in images_vertical[:]:
prymula <prymula76@outlook.com>
parents:
diff changeset
208 output, list_size, single = a.join_image_to_horizontal(images_vertical, a.create_horizontal_surface())
prymula <prymula76@outlook.com>
parents:
diff changeset
209 if list_size != 0 or single == True:
prymula <prymula76@outlook.com>
parents:
diff changeset
210 #output.show()
prymula <prymula76@outlook.com>
parents:
diff changeset
211 output.save(str(tmp_path)+SLA+jpg_names[a.count], format='JPEG')
prymula <prymula76@outlook.com>
parents:
diff changeset
212 a.count += 1
prymula <prymula76@outlook.com>
parents:
diff changeset
213
prymula <prymula76@outlook.com>
parents:
diff changeset
214 def save_horizontal_to_vertical(self, images_horizontal, jpg_names):
prymula <prymula76@outlook.com>
parents:
diff changeset
215 #global count
prymula <prymula76@outlook.com>
parents:
diff changeset
216 for i in images_horizontal[:]:
prymula <prymula76@outlook.com>
parents:
diff changeset
217 output, list_size, single = a.join_image_to_vertical(images_horizontal, a.create_vertical_surface())
prymula <prymula76@outlook.com>
parents:
diff changeset
218 if list_size != 0 or single == True:
prymula <prymula76@outlook.com>
parents:
diff changeset
219 #output.show()
prymula <prymula76@outlook.com>
parents:
diff changeset
220 output.save(str(tmp_path)+SLA+jpg_names[a.count], format='JPEG')
prymula <prymula76@outlook.com>
parents:
diff changeset
221 a.count += 1
prymula <prymula76@outlook.com>
parents:
diff changeset
222
prymula <prymula76@outlook.com>
parents:
diff changeset
223 def save_vertical(self, images_vertica, jpg_names):
prymula <prymula76@outlook.com>
parents:
diff changeset
224 #global count
prymula <prymula76@outlook.com>
parents:
diff changeset
225 for i in images_vertical[:]:
prymula <prymula76@outlook.com>
parents:
diff changeset
226 output = a.put_vertical_image(i)
prymula <prymula76@outlook.com>
parents:
diff changeset
227 output.save(str(tmp_path)+SLA+jpg_names[a.count], format='JPEG')
prymula <prymula76@outlook.com>
parents:
diff changeset
228 #output.show()
prymula <prymula76@outlook.com>
parents:
diff changeset
229 images_vertical.pop()
prymula <prymula76@outlook.com>
parents:
diff changeset
230 a.count += 1
prymula <prymula76@outlook.com>
parents:
diff changeset
231
prymula <prymula76@outlook.com>
parents:
diff changeset
232 def save_horizontal(self, images_horizontal, jpg_names):
prymula <prymula76@outlook.com>
parents:
diff changeset
233 #global count
prymula <prymula76@outlook.com>
parents:
diff changeset
234 for i in images_horizontal[:]:
prymula <prymula76@outlook.com>
parents:
diff changeset
235 output = a.put_horizontal_image(i)
prymula <prymula76@outlook.com>
parents:
diff changeset
236 output.save(str(tmp_path)+SLA+jpg_names[a.count], format='JPEG')
prymula <prymula76@outlook.com>
parents:
diff changeset
237 #output.show()
prymula <prymula76@outlook.com>
parents:
diff changeset
238 images_horizontal.pop()
prymula <prymula76@outlook.com>
parents:
diff changeset
239 a.count += 1
prymula <prymula76@outlook.com>
parents:
diff changeset
240
prymula <prymula76@outlook.com>
parents:
diff changeset
241 def name_jpg_wihout_path(self):
prymula <prymula76@outlook.com>
parents:
diff changeset
242 files_jpg_names = a.file_exclusion(os.listdir())
prymula <prymula76@outlook.com>
parents:
diff changeset
243 for f in files_jpg_names:
prymula <prymula76@outlook.com>
parents:
diff changeset
244 f = f[0] + "file "
prymula <prymula76@outlook.com>
parents:
diff changeset
245 #print ("Ekstrat: " + str(files_jpg_names))
prymula <prymula76@outlook.com>
parents:
diff changeset
246 return files_jpg_names
prymula <prymula76@outlook.com>
parents:
diff changeset
247
prymula <prymula76@outlook.com>
parents:
diff changeset
248 def at_unslash(self, path):
prymula <prymula76@outlook.com>
parents:
diff changeset
249 p = path.replace("\\","/")
prymula <prymula76@outlook.com>
parents:
diff changeset
250 print("PO KONWERSJI: "+p)
prymula <prymula76@outlook.com>
parents:
diff changeset
251 return p
prymula <prymula76@outlook.com>
parents:
diff changeset
252
prymula <prymula76@outlook.com>
parents:
diff changeset
253 def dump_jpg_list(self, files_jpg_names):
prymula <prymula76@outlook.com>
parents:
diff changeset
254 print("tmp_list")
prymula <prymula76@outlook.com>
parents:
diff changeset
255 with open(tmp_list, 'w') as fp:
prymula <prymula76@outlook.com>
parents:
diff changeset
256 for item in files_jpg_names:
prymula <prymula76@outlook.com>
parents:
diff changeset
257 # FIXME - to nic nie daje dalej wyrzuca "invalid argument"
prymula <prymula76@outlook.com>
parents:
diff changeset
258 if platform == "win32":
prymula <prymula76@outlook.com>
parents:
diff changeset
259 fp.write("file '"+a.at_unslash(str(tmp_path) + SLA +"%s'\r\n" % item))
prymula <prymula76@outlook.com>
parents:
diff changeset
260 else:
prymula <prymula76@outlook.com>
parents:
diff changeset
261 # write each item on a new line
prymula <prymula76@outlook.com>
parents:
diff changeset
262 fp.write("file '"+str(tmp_path) + SLA +"%s'\r\n" % item)
prymula <prymula76@outlook.com>
parents:
diff changeset
263
prymula <prymula76@outlook.com>
parents:
diff changeset
264 print("Zapisany plik do list.txt --> "+item)
prymula <prymula76@outlook.com>
parents:
diff changeset
265 return files_jpg_names
prymula <prymula76@outlook.com>
parents:
diff changeset
266 a = App()
prymula <prymula76@outlook.com>
parents:
diff changeset
267 jpg_names = a.dump_jpg_list(a.name_jpg_wihout_path())
prymula <prymula76@outlook.com>
parents:
diff changeset
268 if len(sys.argv) == 1 or sys.argv[-1] == '-H':
prymula <prymula76@outlook.com>
parents:
diff changeset
269 images_vertical, images_horizontal = a.read_images_from_directory(a.get_files())
prymula <prymula76@outlook.com>
parents:
diff changeset
270 a.save_horizontal(images_horizontal, jpg_names)
prymula <prymula76@outlook.com>
parents:
diff changeset
271 a.save_vertical_to_horizontal(images_vertical, jpg_names)
prymula <prymula76@outlook.com>
parents:
diff changeset
272 #print ("_---------------N_PIC: "+str(a.n_pictures))
prymula <prymula76@outlook.com>
parents:
diff changeset
273
prymula <prymula76@outlook.com>
parents:
diff changeset
274 print(command)
prymula <prymula76@outlook.com>
parents:
diff changeset
275 os.popen(command).read()
prymula <prymula76@outlook.com>
parents:
diff changeset
276 elif sys.argv[-1] == '-V':
prymula <prymula76@outlook.com>
parents:
diff changeset
277 images_vertical, images_horizontal = a.read_images_from_directory(a.get_files())
prymula <prymula76@outlook.com>
parents:
diff changeset
278 a.save_vertical(images_vertical, jpg_names)
prymula <prymula76@outlook.com>
parents:
diff changeset
279 a.save_horizontal_to_vertical(images_horizontal, jpg_names)
prymula <prymula76@outlook.com>
parents:
diff changeset
280 #print ("_---------------N_PIC: "+str(a.n_pictures))
prymula <prymula76@outlook.com>
parents:
diff changeset
281 print(command)
prymula <prymula76@outlook.com>
parents:
diff changeset
282 os.popen(command).read()
prymula <prymula76@outlook.com>
parents:
diff changeset
283 else:
prymula <prymula76@outlook.com>
parents:
diff changeset
284 print ("\n\nUżycie:\n\n Uruchom skrypt w katalogu z plikami JPG\n\n 'vsss -H' | 'vsss' dla video horyzontalnego\n 'vsss -V' dla video vertykalnego\n\n \
prymula <prymula76@outlook.com>
parents:
diff changeset
285 'vsss -h' aby wyświetlić pomoc i numer wersji.\n verysimpleslideshow (vsss) ver. "+VER+"\n SEPT-2023")
prymula <prymula76@outlook.com>
parents:
diff changeset
286
prymula <prymula76@outlook.com>
parents:
diff changeset
287
prymula <prymula76@outlook.com>
parents:
diff changeset
288 a.cleanup()