File tree 2 files changed +28
-0
lines changed
2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,20 @@ def transform(self, record: SourceRecord) -> dict:
66
66
"file" : identifiers [0 ],
67
67
}
68
68
69
+ # add the orientation tag data from exif if specified
70
+ tags = record .get_all_values ("ExiTag" , reduce = False )
71
+ tag_values = record .get_all_values ("ExiValue" , reduce = False )
72
+ if tags and tag_values :
73
+ try :
74
+ # the orientation tag is 274 (0x0112), so look up the index of that in
75
+ # the tags tuple and then the value will be at the same index in the
76
+ # values tuple. Because EMu, the value can be either a number or the
77
+ # text version, e.g. "7" or "Rotate 270 CW"
78
+ data ["orientation" ] = tag_values [tags .index ("274" )]
79
+ except ValueError :
80
+ # no orientation in the tags so there's nothing to do
81
+ pass
82
+
69
83
# add old MAM asset IDs if found
70
84
old_asset_id = record .get_first_value ("GenDigitalMediaId" )
71
85
if old_asset_id and old_asset_id != "Pending" :
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ def test_transform(mss_view: MSSView):
39
39
"file" : "BM000019319.tif" ,
40
40
"width" : 6638 ,
41
41
"height" : 10199 ,
42
+ "orientation" : "Horizontal (normal)" ,
42
43
"derivatives" : [
43
44
{"file" : "BM000019319.thumb.jpg" , "width" : 59 , "height" : 90 },
44
45
{"file" : "BM000019319.120x10199.jpeg" , "width" : 120 , "height" : 184 },
@@ -67,3 +68,16 @@ def test_transform_no_derivatives(mss_view: MSSView):
67
68
"width" : 6638 ,
68
69
"height" : 10199 ,
69
70
}
71
+
72
+
73
+ def test_transform_no_orientation (mss_view : MSSView ):
74
+ data = SAMPLE_IMAGE_DATA .copy ()
75
+ # remove the exif tag in our sample data which stores the orientation value (and all
76
+ # the associated tag and tag name bits EMu exports)
77
+ for field in ["ExiTag" , "ExiName" , "ExiValue" ]:
78
+ # in the test data the orientation tag is the 8th element of the exif lists
79
+ del data [field ][8 ]
80
+ record = SourceRecord (SAMPLE_IMAGE_ID , data , "test" )
81
+
82
+ data = mss_view .transform (record )
83
+ assert "orientation" not in data
You can’t perform that action at this time.
0 commit comments