Browse Source

Release 2f1c613a70 - Pillow and ffmpeg adaptions

master
Dirk Alders 4 years ago
parent
commit
0a67ebeb48
5 changed files with 3018 additions and 1563 deletions
  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 View File

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

+ 66
- 56
_testresults_/coverage.xml View File

1
 <?xml version="1.0" ?>
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
 	<!-- Generated by coverage.py: https://coverage.readthedocs.io -->
3
 	<!-- Generated by coverage.py: https://coverage.readthedocs.io -->
4
 	<!-- Based on https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd -->
4
 	<!-- Based on https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd -->
5
 	<sources/>
5
 	<sources/>
6
 	<packages>
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
 			<classes>
8
 			<classes>
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">
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
 					<methods/>
10
 					<methods/>
218
 						<line hits="1" number="35"/>
218
 						<line hits="1" number="35"/>
219
 					</lines>
219
 					</lines>
220
 				</class>
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
 					<methods/>
222
 					<methods/>
223
 					<lines>
223
 					<lines>
224
 						<line hits="1" number="1"/>
224
 						<line hits="1" number="1"/>
227
 						<line hits="1" number="4"/>
227
 						<line hits="1" number="4"/>
228
 						<line hits="1" number="5"/>
228
 						<line hits="1" number="5"/>
229
 						<line hits="1" number="6"/>
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
 						<line hits="1" number="13"/>
232
 						<line hits="1" number="13"/>
233
-						<line hits="1" number="16"/>
233
+						<line hits="1" number="14"/>
234
 						<line hits="1" number="17"/>
234
 						<line hits="1" number="17"/>
235
 						<line hits="1" number="18"/>
235
 						<line hits="1" number="18"/>
236
 						<line hits="1" number="19"/>
236
 						<line hits="1" number="19"/>
247
 						<line hits="1" number="30"/>
247
 						<line hits="1" number="30"/>
248
 						<line hits="1" number="31"/>
248
 						<line hits="1" number="31"/>
249
 						<line hits="1" number="32"/>
249
 						<line hits="1" number="32"/>
250
-						<line hits="1" number="35"/>
250
+						<line hits="1" number="33"/>
251
 						<line hits="1" number="36"/>
251
 						<line hits="1" number="36"/>
252
 						<line hits="1" number="37"/>
252
 						<line hits="1" number="37"/>
253
 						<line hits="1" number="38"/>
253
 						<line hits="1" number="38"/>
257
 						<line hits="1" number="42"/>
257
 						<line hits="1" number="42"/>
258
 						<line hits="1" number="43"/>
258
 						<line hits="1" number="43"/>
259
 						<line hits="1" number="44"/>
259
 						<line hits="1" number="44"/>
260
-						<line hits="1" number="47"/>
260
+						<line hits="1" number="45"/>
261
 						<line hits="1" number="48"/>
261
 						<line hits="1" number="48"/>
262
-						<line hits="1" number="51"/>
262
+						<line hits="1" number="49"/>
263
 						<line hits="1" number="52"/>
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
 						<line hits="1" number="56"/>
266
 						<line hits="1" number="56"/>
267
 						<line hits="1" number="57"/>
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
 						<line branch="true" condition-coverage="100% (2/2)" hits="1" number="60"/>
269
 						<line branch="true" condition-coverage="100% (2/2)" hits="1" number="60"/>
270
 						<line branch="true" condition-coverage="100% (2/2)" hits="1" number="61"/>
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
 						<line hits="1" number="64"/>
272
 						<line hits="1" number="64"/>
273
-						<line hits="1" number="66"/>
273
+						<line hits="1" number="65"/>
274
 						<line hits="1" number="67"/>
274
 						<line hits="1" number="67"/>
275
-						<line hits="1" number="69"/>
275
+						<line hits="1" number="68"/>
276
 						<line hits="1" number="70"/>
276
 						<line hits="1" number="70"/>
277
 						<line hits="1" number="71"/>
277
 						<line hits="1" number="71"/>
278
-						<line hits="1" number="74"/>
278
+						<line hits="1" number="72"/>
279
 						<line hits="1" number="75"/>
279
 						<line hits="1" number="75"/>
280
 						<line hits="1" number="76"/>
280
 						<line hits="1" number="76"/>
281
-						<line hits="1" number="78"/>
281
+						<line hits="1" number="77"/>
282
 						<line hits="1" number="79"/>
282
 						<line hits="1" number="79"/>
283
-						<line hits="1" number="81"/>
283
+						<line hits="1" number="80"/>
284
 						<line hits="1" number="82"/>
284
 						<line hits="1" number="82"/>
285
 						<line hits="1" number="83"/>
285
 						<line hits="1" number="83"/>
286
 						<line hits="1" number="84"/>
286
 						<line hits="1" number="84"/>
287
 						<line hits="1" number="85"/>
287
 						<line hits="1" number="85"/>
288
-						<line hits="0" number="86"/>
288
+						<line hits="1" number="86"/>
289
 						<line hits="0" number="87"/>
289
 						<line hits="0" number="87"/>
290
 						<line hits="0" number="88"/>
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
 						<line hits="1" number="95"/>
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
 						<line hits="1" number="99"/>
299
 						<line hits="1" number="99"/>
300
 						<line hits="1" number="100"/>
300
 						<line hits="1" number="100"/>
301
 						<line hits="1" number="101"/>
301
 						<line hits="1" number="101"/>
302
 						<line hits="1" number="102"/>
302
 						<line hits="1" number="102"/>
303
 						<line hits="1" number="103"/>
303
 						<line hits="1" number="103"/>
304
-						<line hits="1" number="106"/>
304
+						<line hits="1" number="104"/>
305
 						<line hits="1" number="107"/>
305
 						<line hits="1" number="107"/>
306
 						<line hits="1" number="108"/>
306
 						<line hits="1" number="108"/>
307
 						<line hits="1" number="109"/>
307
 						<line hits="1" number="109"/>
308
 						<line hits="1" number="110"/>
308
 						<line hits="1" number="110"/>
309
 						<line hits="1" number="111"/>
309
 						<line hits="1" number="111"/>
310
 						<line hits="1" number="112"/>
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
 						<line hits="1" number="117"/>
313
 						<line hits="1" number="117"/>
314
 						<line hits="1" number="118"/>
314
 						<line hits="1" number="118"/>
315
 						<line hits="1" number="119"/>
315
 						<line hits="1" number="119"/>
322
 						<line hits="1" number="126"/>
322
 						<line hits="1" number="126"/>
323
 						<line hits="1" number="127"/>
323
 						<line hits="1" number="127"/>
324
 						<line hits="1" number="128"/>
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
 						<line branch="true" condition-coverage="100% (2/2)" hits="1" number="130"/>
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
 						<line hits="1" number="132"/>
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
 						<line hits="1" number="134"/>
330
 						<line hits="1" number="134"/>
331
 						<line hits="1" number="135"/>
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
 						<line hits="1" number="144"/>
337
 						<line hits="1" number="144"/>
336
-						<line hits="1" number="145"/>
337
-						<line hits="1" number="146"/>
338
 						<line hits="1" number="147"/>
338
 						<line hits="1" number="147"/>
339
 						<line hits="1" number="148"/>
339
 						<line hits="1" number="148"/>
340
 						<line hits="1" number="149"/>
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
 						<line hits="1" number="151"/>
342
 						<line hits="1" number="151"/>
343
 						<line hits="1" number="152"/>
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
 						<line hits="1" number="156"/>
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
 						<line hits="1" number="191"/>
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
 						<line hits="1" number="193"/>
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
 						<line hits="1" number="196"/>
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
 						<line hits="1" number="198"/>
359
 						<line hits="1" number="198"/>
360
 						<line hits="1" number="199"/>
360
 						<line hits="1" number="199"/>
361
+						<line hits="1" number="200"/>
362
+						<line hits="1" number="201"/>
361
 						<line hits="1" number="202"/>
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
 						<line hits="1" number="207"/>
366
 						<line hits="1" number="207"/>
365
 						<line hits="1" number="208"/>
367
 						<line hits="1" number="208"/>
366
 						<line hits="1" number="209"/>
368
 						<line hits="1" number="209"/>
367
 						<line hits="1" number="210"/>
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
 						<line hits="1" number="213"/>
370
 						<line hits="1" number="213"/>
371
 						<line hits="1" number="214"/>
371
 						<line hits="1" number="214"/>
372
 						<line hits="1" number="215"/>
372
 						<line hits="1" number="215"/>
373
 						<line hits="1" number="216"/>
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
 						<line hits="1" number="218"/>
375
 						<line hits="1" number="218"/>
376
 						<line hits="1" number="219"/>
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
 						<line hits="1" number="222"/>
379
 						<line hits="1" number="222"/>
380
 						<line hits="1" number="223"/>
380
 						<line hits="1" number="223"/>
381
 						<line hits="1" number="224"/>
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
 						<line hits="1" number="227"/>
384
 						<line hits="1" number="227"/>
383
 						<line hits="1" number="228"/>
385
 						<line hits="1" number="228"/>
384
 						<line hits="1" number="229"/>
386
 						<line hits="1" number="229"/>
385
 						<line hits="1" number="230"/>
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
 					</lines>
396
 					</lines>
387
 				</class>
397
 				</class>
388
 			</classes>
398
 			</classes>

+ 2936
- 1501
_testresults_/unittest.json
File diff suppressed because it is too large
View File


BIN
_testresults_/unittest.pdf View File


+ 15
- 5
metadata.py View File

1
 import logging
1
 import logging
2
 import os
2
 import os
3
 from PIL import Image
3
 from PIL import Image
4
+import math
4
 import media
5
 import media
5
 import subprocess
6
 import subprocess
6
 import time
7
 import time
129
         for key in conv_key_dict:
130
         for key in conv_key_dict:
130
             if key in exif:
131
             if key in exif:
131
                 tp, name = conv_key_dict[key]
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
                 if value is not None:
136
                 if value is not None:
134
                     rv[name] = value
137
                     rv[name] = value
135
     return rv
138
     return rv
200
 
203
 
201
 
204
 
202
 def __num_denum_conv__(data):
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
 def __gps_conv__(data):
213
 def __gps_conv__(data):
208
     def lat_lon_cal(lon_or_lat):
214
     def lat_lon_cal(lon_or_lat):
209
         lon_lat = 0.
215
         lon_lat = 0.
210
         fac = 1.
216
         fac = 1.
211
-        for num, denum in lon_or_lat:
217
+        for data in lon_or_lat:
212
             try:
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
             except ZeroDivisionError:
222
             except ZeroDivisionError:
215
                 return 0.
223
                 return 0.
216
             fac *= 1. / 60.
224
             fac *= 1. / 60.
225
+        if math.isnan(lon_lat):
226
+            return 0.
217
         return lon_lat
227
         return lon_lat
218
     try:
228
     try:
219
         lon = lat_lon_cal(data[0x0004])
229
         lon = lat_lon_cal(data[0x0004])

Loading…
Cancel
Save