Переглянути джерело

Release 2f1c613a70 - Pillow and ffmpeg adaptions

master
Dirk Alders 4 роки тому
джерело
коміт
0a67ebeb48
5 змінених файлів з 3018 додано та 1563 видалено
  1. 1
    1
      __init__.py
  2. 66
    56
      _testresults_/coverage.xml
  3. 2936
    1501
      _testresults_/unittest.json
  4. BIN
      _testresults_/unittest.pdf
  5. 15
    5
      metadata.py

+ 1
- 1
__init__.py Переглянути файл

@@ -167,7 +167,7 @@ class image(object):
167 167
             if type(orientation) == int and orientation > 8:
168 168
                 logger.warning('Orientation %s unknown for rotation', repr(orientation))
169 169
             return False
170
-        logger.debug('Rotating picture by %d°', angle)
170
+        logger.debug('Rotating picture by %d (deg)', angle)
171 171
         self._im = self._im.rotate(angle, expand=True)
172 172
         return True
173 173
 

+ 66
- 56
_testresults_/coverage.xml Переглянути файл

@@ -1,10 +1,10 @@
1 1
 <?xml version="1.0" ?>
2
-<coverage branch-rate="0.9674" branches-covered="89" branches-valid="92" complexity="0" line-rate="0.9777" lines-covered="351" lines-valid="359" timestamp="1591793830295" version="4.5">
2
+<coverage branch-rate="0.9479" branches-covered="91" branches-valid="96" complexity="0" line-rate="0.9729" lines-covered="359" lines-valid="369" timestamp="1598724989106" version="4.5.2">
3 3
 	<!-- Generated by coverage.py: https://coverage.readthedocs.io -->
4 4
 	<!-- Based on https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd -->
5 5
 	<sources/>
6 6
 	<packages>
7
-		<package branch-rate="0.9674" complexity="0" line-rate="0.9777" name=".user_data.data.dirk.prj.unittest.media.pylibs.media">
7
+		<package branch-rate="0.9479" complexity="0" line-rate="0.9729" name=".user_data.data.dirk.prj.unittest.media.pylibs.media">
8 8
 			<classes>
9 9
 				<class branch-rate="0.9565" complexity="0" filename="/user_data/data/dirk/prj/unittest/media/pylibs/media/__init__.py" line-rate="0.9934" name="__init__.py">
10 10
 					<methods/>
@@ -218,7 +218,7 @@
218 218
 						<line hits="1" number="35"/>
219 219
 					</lines>
220 220
 				</class>
221
-				<class branch-rate="1" complexity="0" filename="/user_data/data/dirk/prj/unittest/media/pylibs/media/metadata.py" line-rate="0.9815" name="metadata.py">
221
+				<class branch-rate="0.9412" complexity="0" filename="/user_data/data/dirk/prj/unittest/media/pylibs/media/metadata.py" line-rate="0.9709" name="metadata.py">
222 222
 					<methods/>
223 223
 					<lines>
224 224
 						<line hits="1" number="1"/>
@@ -227,10 +227,10 @@
227 227
 						<line hits="1" number="4"/>
228 228
 						<line hits="1" number="5"/>
229 229
 						<line hits="1" number="6"/>
230
-						<line hits="1" number="9"/>
231
-						<line hits="1" number="12"/>
230
+						<line hits="1" number="7"/>
231
+						<line hits="1" number="10"/>
232 232
 						<line hits="1" number="13"/>
233
-						<line hits="1" number="16"/>
233
+						<line hits="1" number="14"/>
234 234
 						<line hits="1" number="17"/>
235 235
 						<line hits="1" number="18"/>
236 236
 						<line hits="1" number="19"/>
@@ -247,7 +247,7 @@
247 247
 						<line hits="1" number="30"/>
248 248
 						<line hits="1" number="31"/>
249 249
 						<line hits="1" number="32"/>
250
-						<line hits="1" number="35"/>
250
+						<line hits="1" number="33"/>
251 251
 						<line hits="1" number="36"/>
252 252
 						<line hits="1" number="37"/>
253 253
 						<line hits="1" number="38"/>
@@ -257,59 +257,59 @@
257 257
 						<line hits="1" number="42"/>
258 258
 						<line hits="1" number="43"/>
259 259
 						<line hits="1" number="44"/>
260
-						<line hits="1" number="47"/>
260
+						<line hits="1" number="45"/>
261 261
 						<line hits="1" number="48"/>
262
-						<line hits="1" number="51"/>
262
+						<line hits="1" number="49"/>
263 263
 						<line hits="1" number="52"/>
264
-						<line branch="true" condition-coverage="100% (2/2)" hits="1" number="54"/>
265
-						<line hits="1" number="55"/>
264
+						<line hits="1" number="53"/>
265
+						<line branch="true" condition-coverage="100% (2/2)" hits="1" number="55"/>
266 266
 						<line hits="1" number="56"/>
267 267
 						<line hits="1" number="57"/>
268
-						<line branch="true" condition-coverage="100% (2/2)" hits="1" number="59"/>
268
+						<line hits="1" number="58"/>
269 269
 						<line branch="true" condition-coverage="100% (2/2)" hits="1" number="60"/>
270 270
 						<line branch="true" condition-coverage="100% (2/2)" hits="1" number="61"/>
271
-						<line hits="1" number="63"/>
271
+						<line branch="true" condition-coverage="100% (2/2)" hits="1" number="62"/>
272 272
 						<line hits="1" number="64"/>
273
-						<line hits="1" number="66"/>
273
+						<line hits="1" number="65"/>
274 274
 						<line hits="1" number="67"/>
275
-						<line hits="1" number="69"/>
275
+						<line hits="1" number="68"/>
276 276
 						<line hits="1" number="70"/>
277 277
 						<line hits="1" number="71"/>
278
-						<line hits="1" number="74"/>
278
+						<line hits="1" number="72"/>
279 279
 						<line hits="1" number="75"/>
280 280
 						<line hits="1" number="76"/>
281
-						<line hits="1" number="78"/>
281
+						<line hits="1" number="77"/>
282 282
 						<line hits="1" number="79"/>
283
-						<line hits="1" number="81"/>
283
+						<line hits="1" number="80"/>
284 284
 						<line hits="1" number="82"/>
285 285
 						<line hits="1" number="83"/>
286 286
 						<line hits="1" number="84"/>
287 287
 						<line hits="1" number="85"/>
288
-						<line hits="0" number="86"/>
288
+						<line hits="1" number="86"/>
289 289
 						<line hits="0" number="87"/>
290 290
 						<line hits="0" number="88"/>
291
-						<line hits="1" number="90"/>
292
-						<line branch="true" condition-coverage="100% (2/2)" hits="1" number="91"/>
293
-						<line hits="1" number="92"/>
294
-						<line branch="true" condition-coverage="100% (2/2)" hits="1" number="93"/>
295
-						<line hits="1" number="94"/>
291
+						<line hits="0" number="89"/>
292
+						<line hits="1" number="91"/>
293
+						<line branch="true" condition-coverage="100% (2/2)" hits="1" number="92"/>
294
+						<line hits="1" number="93"/>
295
+						<line branch="true" condition-coverage="100% (2/2)" hits="1" number="94"/>
296 296
 						<line hits="1" number="95"/>
297
-						<line branch="true" condition-coverage="100% (2/2)" hits="1" number="97"/>
298
-						<line hits="1" number="98"/>
297
+						<line hits="1" number="96"/>
298
+						<line branch="true" condition-coverage="100% (2/2)" hits="1" number="98"/>
299 299
 						<line hits="1" number="99"/>
300 300
 						<line hits="1" number="100"/>
301 301
 						<line hits="1" number="101"/>
302 302
 						<line hits="1" number="102"/>
303 303
 						<line hits="1" number="103"/>
304
-						<line hits="1" number="106"/>
304
+						<line hits="1" number="104"/>
305 305
 						<line hits="1" number="107"/>
306 306
 						<line hits="1" number="108"/>
307 307
 						<line hits="1" number="109"/>
308 308
 						<line hits="1" number="110"/>
309 309
 						<line hits="1" number="111"/>
310 310
 						<line hits="1" number="112"/>
311
-						<line hits="1" number="114"/>
312
-						<line hits="1" number="116"/>
311
+						<line hits="1" number="113"/>
312
+						<line hits="1" number="115"/>
313 313
 						<line hits="1" number="117"/>
314 314
 						<line hits="1" number="118"/>
315 315
 						<line hits="1" number="119"/>
@@ -322,67 +322,77 @@
322 322
 						<line hits="1" number="126"/>
323 323
 						<line hits="1" number="127"/>
324 324
 						<line hits="1" number="128"/>
325
-						<line branch="true" condition-coverage="100% (2/2)" hits="1" number="129"/>
325
+						<line hits="1" number="129"/>
326 326
 						<line branch="true" condition-coverage="100% (2/2)" hits="1" number="130"/>
327
-						<line hits="1" number="131"/>
327
+						<line branch="true" condition-coverage="100% (2/2)" hits="1" number="131"/>
328 328
 						<line hits="1" number="132"/>
329
-						<line branch="true" condition-coverage="100% (2/2)" hits="1" number="133"/>
329
+						<line hits="1" number="133"/>
330 330
 						<line hits="1" number="134"/>
331 331
 						<line hits="1" number="135"/>
332
-						<line hits="1" number="139"/>
333
-						<line hits="1" number="140"/>
334
-						<line hits="1" number="141"/>
332
+						<line branch="true" condition-coverage="100% (2/2)" hits="1" number="136"/>
333
+						<line hits="1" number="137"/>
334
+						<line hits="1" number="138"/>
335
+						<line hits="1" number="142"/>
336
+						<line hits="1" number="143"/>
335 337
 						<line hits="1" number="144"/>
336
-						<line hits="1" number="145"/>
337
-						<line hits="1" number="146"/>
338 338
 						<line hits="1" number="147"/>
339 339
 						<line hits="1" number="148"/>
340 340
 						<line hits="1" number="149"/>
341
-						<line branch="true" condition-coverage="100% (2/2)" hits="1" number="150"/>
341
+						<line hits="1" number="150"/>
342 342
 						<line hits="1" number="151"/>
343 343
 						<line hits="1" number="152"/>
344
-						<line hits="1" number="153"/>
344
+						<line branch="true" condition-coverage="100% (2/2)" hits="1" number="153"/>
345
+						<line hits="1" number="154"/>
346
+						<line hits="1" number="155"/>
345 347
 						<line hits="1" number="156"/>
346
-						<line hits="1" number="157"/>
347
-						<line hits="1" number="170"/>
348
-						<line hits="1" number="171"/>
349
-						<line hits="1" number="188"/>
350
-						<line hits="1" number="189"/>
351
-						<line hits="1" number="190"/>
348
+						<line hits="1" number="159"/>
349
+						<line hits="1" number="160"/>
350
+						<line hits="1" number="173"/>
351
+						<line hits="1" number="174"/>
352 352
 						<line hits="1" number="191"/>
353
-						<line branch="true" condition-coverage="100% (2/2)" hits="1" number="192"/>
353
+						<line hits="1" number="192"/>
354 354
 						<line hits="1" number="193"/>
355
-						<line branch="true" condition-coverage="100% (2/2)" hits="1" number="194"/>
356
-						<line hits="1" number="195"/>
355
+						<line hits="1" number="194"/>
356
+						<line branch="true" condition-coverage="100% (2/2)" hits="1" number="195"/>
357 357
 						<line hits="1" number="196"/>
358
-						<line hits="1" number="197"/>
358
+						<line branch="true" condition-coverage="100% (2/2)" hits="1" number="197"/>
359 359
 						<line hits="1" number="198"/>
360 360
 						<line hits="1" number="199"/>
361
+						<line hits="1" number="200"/>
362
+						<line hits="1" number="201"/>
361 363
 						<line hits="1" number="202"/>
362
-						<line hits="1" number="203"/>
363
-						<line hits="1" number="204"/>
364
+						<line hits="1" number="205"/>
365
+						<line hits="1" number="206"/>
364 366
 						<line hits="1" number="207"/>
365 367
 						<line hits="1" number="208"/>
366 368
 						<line hits="1" number="209"/>
367 369
 						<line hits="1" number="210"/>
368
-						<line branch="true" condition-coverage="100% (2/2)" hits="1" number="211"/>
369
-						<line hits="1" number="212"/>
370 370
 						<line hits="1" number="213"/>
371 371
 						<line hits="1" number="214"/>
372 372
 						<line hits="1" number="215"/>
373 373
 						<line hits="1" number="216"/>
374
-						<line hits="1" number="217"/>
374
+						<line branch="true" condition-coverage="100% (2/2)" hits="1" number="217"/>
375 375
 						<line hits="1" number="218"/>
376 376
 						<line hits="1" number="219"/>
377
-						<line hits="1" number="220"/>
378
-						<line branch="true" condition-coverage="100% (2/2)" hits="1" number="221"/>
377
+						<line branch="true" condition-coverage="50% (1/2)" hits="1" missing-branches="221" number="220"/>
378
+						<line hits="0" number="221"/>
379 379
 						<line hits="1" number="222"/>
380 380
 						<line hits="1" number="223"/>
381 381
 						<line hits="1" number="224"/>
382
+						<line branch="true" condition-coverage="50% (1/2)" hits="1" missing-branches="226" number="225"/>
383
+						<line hits="0" number="226"/>
382 384
 						<line hits="1" number="227"/>
383 385
 						<line hits="1" number="228"/>
384 386
 						<line hits="1" number="229"/>
385 387
 						<line hits="1" number="230"/>
388
+						<line branch="true" condition-coverage="100% (2/2)" hits="1" number="231"/>
389
+						<line hits="1" number="232"/>
390
+						<line hits="1" number="233"/>
391
+						<line hits="1" number="234"/>
392
+						<line hits="1" number="237"/>
393
+						<line hits="1" number="238"/>
394
+						<line hits="1" number="239"/>
395
+						<line hits="1" number="240"/>
386 396
 					</lines>
387 397
 				</class>
388 398
 			</classes>

+ 2936
- 1501
_testresults_/unittest.json
Різницю між файлами не показано, бо вона завелика
Переглянути файл


BIN
_testresults_/unittest.pdf Переглянути файл


+ 15
- 5
metadata.py Переглянути файл

@@ -1,6 +1,7 @@
1 1
 import logging
2 2
 import os
3 3
 from PIL import Image
4
+import math
4 5
 import media
5 6
 import subprocess
6 7
 import time
@@ -129,7 +130,9 @@ def __get_exif_data__(full_path):
129 130
         for key in conv_key_dict:
130 131
             if key in exif:
131 132
                 tp, name = conv_key_dict[key]
132
-                value = tp(exif[key])
133
+                raw_value = exif[key]
134
+                logger.debug("Converting %s out of %s", name, repr(raw_value))
135
+                value = tp(raw_value)
133 136
                 if value is not None:
134 137
                     rv[name] = value
135 138
     return rv
@@ -200,20 +203,27 @@ def __int_conv__(value):
200 203
 
201 204
 
202 205
 def __num_denum_conv__(data):
203
-    num, denum = data
204
-    return num / denum
206
+    try:
207
+        return float(data)
208
+    except TypeError:
209
+        num, denum = data
210
+        return num / denum
205 211
 
206 212
 
207 213
 def __gps_conv__(data):
208 214
     def lat_lon_cal(lon_or_lat):
209 215
         lon_lat = 0.
210 216
         fac = 1.
211
-        for num, denum in lon_or_lat:
217
+        for data in lon_or_lat:
212 218
             try:
213
-                lon_lat += float(num) / float(denum) * fac
219
+                lon_lat += float(data[0]) / float(data[1]) * fac
220
+            except TypeError:
221
+                lon_lat += data * fac
214 222
             except ZeroDivisionError:
215 223
                 return 0.
216 224
             fac *= 1. / 60.
225
+        if math.isnan(lon_lat):
226
+            return 0.
217 227
         return lon_lat
218 228
     try:
219 229
         lon = lat_lon_cal(data[0x0004])

Завантаження…
Відмінити
Зберегти