mirror of
https://github.com/xuthus83/pigallery2.git
synced 2025-01-14 14:43:17 +08:00
keywords decoding error fix
This commit is contained in:
parent
941fdf509e
commit
3cd9ef7b1a
@ -81,7 +81,38 @@ export class DiskManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
UTF8 = {
|
||||||
|
|
||||||
|
encode: function(s){
|
||||||
|
|
||||||
|
for(var c, i = -1, l = (s = s.split("")).length, o = String.fromCharCode; ++i < l;
|
||||||
|
|
||||||
|
s[i] = (c = s[i].charCodeAt(0)) >= 127 ? o(0xc0 | (c >>> 6)) + o(0x80 | (c & 0x3f)) : s[i]
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
return s.join("");
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
decode: function(s){
|
||||||
|
|
||||||
|
for(var a, b, i = -1, l = (s = s.split("")).length, o = String.fromCharCode, c = "charCodeAt"; ++i < l;
|
||||||
|
|
||||||
|
((a = s[i][c](0)) & 0x80) &&
|
||||||
|
|
||||||
|
(s[i] = (a & 0xfc) == 0xc0 && ((b = s[i + 1][c](0)) & 0xc0) == 0x80 ?
|
||||||
|
|
||||||
|
o(((a & 0x03) << 6) + (b & 0x3f)) : o(128), s[++i] = "")
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
return s.join("");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};*/
|
||||||
private static loadPhotoMetadata(fullPath):Promise<PhotoMetadata> {
|
private static loadPhotoMetadata(fullPath):Promise<PhotoMetadata> {
|
||||||
return new Promise<PhotoMetadata>((resolve:(metadata:PhotoMetadata)=>void, reject) => {
|
return new Promise<PhotoMetadata>((resolve:(metadata:PhotoMetadata)=>void, reject) => {
|
||||||
fs.readFile(fullPath, function (err, data) {
|
fs.readFile(fullPath, function (err, data) {
|
||||||
@ -115,8 +146,22 @@ export class DiskManager {
|
|||||||
city: iptcData.city
|
city: iptcData.city
|
||||||
};
|
};
|
||||||
|
|
||||||
let keywords:[string] = iptcData.keywords;
|
//Decode characters to UTF8
|
||||||
|
let decode = (s)=> {
|
||||||
|
for (var a, b, i = -1, l = (s = s.split("")).length, o = String.fromCharCode, c = "charCodeAt"; ++i < l;
|
||||||
|
|
||||||
|
((a = s[i][c](0)) & 0x80) &&
|
||||||
|
|
||||||
|
(s[i] = (a & 0xfc) == 0xc0 && ((b = s[i + 1][c](0)) & 0xc0) == 0x80 ?
|
||||||
|
|
||||||
|
o(((a & 0x03) << 6) + (b & 0x3f)) : o(128), s[++i] = "")
|
||||||
|
);
|
||||||
|
return s.join("");
|
||||||
|
};
|
||||||
|
|
||||||
|
let keywords:[string] = iptcData.keywords.map(s => decode(s));
|
||||||
let creationDate:Date = iptcData.date_time;
|
let creationDate:Date = iptcData.date_time;
|
||||||
|
console.log(keywords);
|
||||||
|
|
||||||
|
|
||||||
let metadata:PhotoMetadata = new PhotoMetadata(keywords, cameraData, positionData, imageSize, creationDate);
|
let metadata:PhotoMetadata = new PhotoMetadata(keywords, cameraData, positionData, imageSize, creationDate);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user