Skip to content

Commit 6c67c90

Browse files
authored
Add orientation handling and tests for Sony camera files (#9295)
* update sony Tag 9400c condition * feat(easyaccess): add SonyMisc3c.CameraOrientation for orientation * uploads test pics * test: add orientation test cases for Sony HIF (issue_9292) Add system tests verifying SonyMisc3c.CameraOrientation is correctly parsed for all 4 orientations (1/3/6/8) on Sony ILCE-7CM2 HIF files, and that the easyaccess orientation() function returns the expected values. * format code * test: remove $easyaccess_test
1 parent db40eb0 commit 6c67c90

7 files changed

Lines changed: 136 additions & 11 deletions

src/easyaccess.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,19 @@ ExifData::const_iterator findMetadatumSkip0inNikonLd4(const ExifData& ed, const
6161
namespace Exiv2 {
6262
ExifData::const_iterator orientation(const ExifData& ed) {
6363
static constexpr const char* keys[] = {
64-
"Exif.Image.Orientation", "Exif.Panasonic.Rotation", "Exif.PanasonicRaw.Orientation",
65-
"Exif.MinoltaCs5D.Rotation", "Exif.MinoltaCs5D.Rotation2", "Exif.MinoltaCs7D.Rotation",
66-
"Exif.Sony1MltCsA100.Rotation", "Exif.Sony1Cs.Rotation", "Exif.Sony2Cs.Rotation",
67-
"Exif.Sony1Cs2.Rotation", "Exif.Sony2Cs2.Rotation", "Exif.Sony1MltCsA100.Rotation",
64+
"Exif.Image.Orientation",
65+
"Exif.Panasonic.Rotation",
66+
"Exif.PanasonicRaw.Orientation",
67+
"Exif.MinoltaCs5D.Rotation",
68+
"Exif.MinoltaCs5D.Rotation2",
69+
"Exif.MinoltaCs7D.Rotation",
70+
"Exif.Sony1MltCsA100.Rotation",
71+
"Exif.Sony1Cs.Rotation",
72+
"Exif.Sony2Cs.Rotation",
73+
"Exif.Sony1Cs2.Rotation",
74+
"Exif.Sony2Cs2.Rotation",
75+
"Exif.Sony1MltCsA100.Rotation",
76+
"Exif.SonyMisc3c.CameraOrientation",
6877
};
6978
return findMetadatum(ed, keys, std::size(keys));
7079
}

src/makernote_int.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ int sonyMisc2bSelector(uint16_t /*tag*/, const byte* /*pData*/, size_t /*size*/,
10151015
}
10161016
int sonyMisc3cSelector(uint16_t /*tag*/, const byte* /*pData*/, size_t /*size*/, TiffComponent* pRoot) {
10171017
// For condition, see Exiftool (Tag 9400c):
1018-
// https://github.com/exiftool/exiftool/blob/7368629751669ba170511419b3d1e05bf0076d0e/lib/Image/ExifTool/Sony.pm#L1681
1018+
// https://github.com/exiftool/exiftool/blob/5a8b6b6ead12b39e3f32f978a4efd0233facbb01/lib/Image/ExifTool/Sony.pm#L1807
10191019

10201020
// Get the value from the image format that is being used
10211021
auto value = getExifValue(pRoot, 0x9400, Exiv2::IfdId::sony1Id);
@@ -1029,12 +1029,15 @@ int sonyMisc3cSelector(uint16_t /*tag*/, const byte* /*pData*/, size_t /*size*/,
10291029
return -1;
10301030

10311031
switch (value->toInt64()) {
1032-
case 35:
1033-
case 36:
1034-
case 38:
1035-
case 40:
1036-
case 49:
1037-
case 50:
1032+
case 35: // 0x23 for DSC-RX10/HX60V/HX350/HX400V/WX220/WX350, ILCE-7/7R/5000/6000, ILCA-68/77M2
1033+
case 36: // 0x24 for ILCA-99M2,ILCE-5100/6300/6500/7M2/7RM2/7S/7SM2/QX1,
1034+
// DSC-HX80/HX90V/QX30/RX0/RX100M3/RX100M4/RX100M5/RX10M2/RX10M3/RX1RM2/WX500
1035+
case 38: // 0x26 for ILCE-6100/6400/6600/7M3/7RM3/9, DSC-RX0M2/RX10M4/RX100M5A/RX100M6/HX95/HX99
1036+
case 40: // 0x28 for ILCE-7RM4/9M2, DSC-RX100M7, ZV-1/1F/1M2/E10
1037+
case 49: // 0x31 for ILCE-1/7M4/7SM3, ILME-FX3
1038+
case 50: // 0x32 for ILCE-7RM5, ILME-FX30
1039+
case 51: // 0x33 for ILCE-6700/7CM2/7CR/9M3, ZV-E1
1040+
case 65: // 0x41 for ILCE-7M5
10381041
return 0;
10391042
default:
10401043
break;
132 KB
Binary file not shown.
138 KB
Binary file not shown.
136 KB
Binary file not shown.
133 KB
Binary file not shown.
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# -*- coding: utf-8 -*-
2+
3+
import system_tests
4+
import unittest
5+
6+
# test needs system_tests.BT.vv['enable_bmff']=1
7+
bSkip = system_tests.BT.verbose_version().get("enable_bmff") != "1"
8+
if bSkip:
9+
raise unittest.SkipTest("*** requires enable_bmff=1 ***")
10+
11+
12+
###########################################################
13+
# Sony ILCE-7CM2 HIF orientation = 1 (top-left)
14+
###########################################################
15+
class issue_9292_sony_orientation_1(metaclass=system_tests.CaseMeta):
16+
url = "https://github.com/Exiv2/exiv2/issues/9292"
17+
filename = "$data_path/issue_9292_sony_1_top_left.HIF"
18+
19+
if bSkip:
20+
commands = []
21+
retval = []
22+
stdin = []
23+
stderr = []
24+
stdout = []
25+
print("*** test skipped. requires enable_bmff=1***")
26+
else:
27+
commands = [
28+
"$exiv2 -g SonyMisc3c.CameraOrientation $filename",
29+
]
30+
retval = [0] * len(commands)
31+
stderr = [""] * len(commands)
32+
stdin = [""] * len(commands)
33+
stdout = [
34+
"Exif.SonyMisc3c.CameraOrientation Byte 1 Horizontal (normal)\n",
35+
]
36+
37+
38+
###########################################################
39+
# Sony ILCE-7CM2 HIF orientation = 3 (bottom-right, 180°)
40+
###########################################################
41+
class issue_9292_sony_orientation_3(metaclass=system_tests.CaseMeta):
42+
url = "https://github.com/Exiv2/exiv2/issues/9292"
43+
filename = "$data_path/issue_9292_sony_3_bottom_right.HIF"
44+
45+
if bSkip:
46+
commands = []
47+
retval = []
48+
stdin = []
49+
stderr = []
50+
stdout = []
51+
print("*** test skipped. requires enable_bmff=1***")
52+
else:
53+
commands = [
54+
"$exiv2 -g SonyMisc3c.CameraOrientation $filename",
55+
]
56+
retval = [0] * len(commands)
57+
stderr = [""] * len(commands)
58+
stdin = [""] * len(commands)
59+
stdout = [
60+
"Exif.SonyMisc3c.CameraOrientation Byte 1 Rotate 180°\n",
61+
]
62+
63+
64+
###########################################################
65+
# Sony ILCE-7CM2 HIF orientation = 6 (right-top, 90° CW)
66+
###########################################################
67+
class issue_9292_sony_orientation_6(metaclass=system_tests.CaseMeta):
68+
url = "https://github.com/Exiv2/exiv2/issues/9292"
69+
filename = "$data_path/issue_9292_sony_6_right_top.HIF"
70+
71+
if bSkip:
72+
commands = []
73+
retval = []
74+
stdin = []
75+
stderr = []
76+
stdout = []
77+
print("*** test skipped. requires enable_bmff=1***")
78+
else:
79+
commands = [
80+
"$exiv2 -g SonyMisc3c.CameraOrientation $filename",
81+
]
82+
retval = [0] * len(commands)
83+
stderr = [""] * len(commands)
84+
stdin = [""] * len(commands)
85+
stdout = [
86+
"Exif.SonyMisc3c.CameraOrientation Byte 1 Rotate 90° CW\n",
87+
]
88+
89+
90+
###########################################################
91+
# Sony ILCE-7CM2 HIF orientation = 8 (left-bottom, 270° CW)
92+
###########################################################
93+
class issue_9292_sony_orientation_8(metaclass=system_tests.CaseMeta):
94+
url = "https://github.com/Exiv2/exiv2/issues/9292"
95+
filename = "$data_path/issue_9292_sony_8_left-bottom.HIF"
96+
97+
if bSkip:
98+
commands = []
99+
retval = []
100+
stdin = []
101+
stderr = []
102+
stdout = []
103+
print("*** test skipped. requires enable_bmff=1***")
104+
else:
105+
commands = [
106+
"$exiv2 -g SonyMisc3c.CameraOrientation $filename",
107+
]
108+
retval = [0] * len(commands)
109+
stderr = [""] * len(commands)
110+
stdin = [""] * len(commands)
111+
stdout = [
112+
"Exif.SonyMisc3c.CameraOrientation Byte 1 Rotate 270° CW\n",
113+
]

0 commit comments

Comments
 (0)