-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
186 lines (161 loc) · 7.18 KB
/
Copy pathindex.html
File metadata and controls
186 lines (161 loc) · 7.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<!-- coded with AI. NO WARRANTY -->
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ultra HDR viewer</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
.image-container {
display: flex;
flex-wrap: wrap;
gap: 20px;
margin-top: 20px;
}
.image-container>div {
flex: 1;
min-width: 300px;
}
img {
max-width: 100%;
height: auto;
}
table {
border-collapse: collapse;
width: 100%;
}
th,
td {
border: 1px solid #ddd;
padding: 8px;
text-align: left;
}
th {
background-color: #f2f2f2;
}
canvas {
max-width: 100%;
height: auto;
}
</style>
</head>
<body>
<h1>Ultra HDR Data Viewer</h1>
<input type="file" id="fileInput" accept=".jpg,.jpeg">
<div class="image-container">
<div>
<h2>HDR</h2>
<img id="firstImage" alt="First Image">
</div>
<div>
<h2>Gainmap</h2>
<img id="secondImage" alt="Second Image">
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/exifreader@4.23.3/dist/exif-reader.min.js"></script>
<script>
document.getElementById('fileInput').addEventListener('change', function (e) {
const file = e.target.files[0];
processImage(file);
});
function processImage(file) {
ExifReader.load(file, { async: true, expanded: true }).then((tags) => {
// process first image
displayImage(file, 'firstImage');
const xmpData = tags['xmp'];
var possiblySecondMapLength = 0;
/* Sample:
<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 5.5.0">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about=""
xmlns:hdrgm="http://ns.adobe.com/hdr-gain-map/1.0/"
xmlns:Container="http://ns.google.com/photos/1.0/container/"
xmlns:Item="http://ns.google.com/photos/1.0/container/item/" hdrgm:Version="1.0">
<Container:Directory>
<rdf:Bag>
<rdf:li rdf:parseType="Resource">
<Container:Item Item:Mime="image/jpeg" Item:Semantic="Primary" Item:Length="0" Item:Padding="0"/>
</rdf:li>
<rdf:li rdf:parseType="Resource">
<Container:Item Item:Mime="image/jpeg" Item:Semantic="Gainmap" Item:Length="64540" Item:Padding="0"/>
</rdf:li>
</rdf:Bag>
</Container:Directory>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta><?xpacket end="w"?>
*/
if (xmpData) {
console.log('1st XMP:', xmpData);
possiblySecondMapLength = Number(xmpData.Directory.value[1].Item.value.Length.value);
// console.log('1st size:', tags['Image Width'], 'x', tags['Image Height']);
}
var has_second_image = false;
var secondImageOffset = 0;
var secondImageLength = 0;
const mpfData = tags['mpf'];
if (mpfData) {
// console.log('1st MPF:'. mpfData); mpfData.Images[0].ImageOffset
secondImageOffset = mpfData.Images[1].ImageOffset.value;
secondImageLength = mpfData.Images[1].ImageSize.value;
if (secondImageLength !=0 & secondImageOffset!=0)
has_second_image = true
}
// process second image
if (has_second_image) {
const reader = new FileReader();
reader.onload = function (e, offset=secondImageOffset, length=secondImageLength) {
const buffer = e.target.result;
// if(offset == -1) {
// offset = buffer.byteLength - length;
// }
const secondImageBuffer = e.target.result.slice(offset);
const secondImageBlob = new Blob([secondImageBuffer], { type: 'image/jpeg' });
displayImage(secondImageBlob, 'secondImage');
// 2nd Exif
ExifReader.load(secondImageBuffer, { async: true, expanded: true }).then((tags) => {
// APP1 XMP
const xmpData = tags['xmp'];
/* Sample
<x:xmpmeta xmlns:x=\"adobe:ns:meta/\" x:xmptk=\"Adobe XMP Core 5.5.0\">
<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">
<rdf:Description rdf:about=\"\"
xmlns:hdrgm=\"http://ns.adobe.com/hdr-gain-map/1.0/\"
hdrgm:Version=\"1.0\"
hdrgm:GainMapMin=\"0.000000\"
hdrgm:GainMapMax=\"2.500000\"
hdrgm:Gamma=\"1.000000\"
hdrgm:OffsetSDR=\"0.000000\"
hdrgm:OffsetHDR=\"0.000000\"
hdrgm:HDRCapacityMin=\"0.000000\"
hdrgm:HDRCapacityMax=\"2.300000\"
hdrgm:BaseRenditionIsHDR=\"False\"/>
</rdf:RDF>
</x:xmpmeta>
*/
if (xmpData) {
console.log('2nd XMP:', xmpData);
}
// console.log('2nd size:', tags['Image Width'], 'x', tags['Image Height']);
}).catch((error) => {
console.error('Exif error (2nd):', error);
});
}
reader.readAsArrayBuffer(file);
}
}).catch((error) => {
console.error('Exif error (1st):', error);
});
};
function displayImage(blob, elementId) {
const url = URL.createObjectURL(blob);
document.getElementById(elementId).src = url;
}
</script>
</body>
</html>