You've already forked pigallery2
mirror of
https://github.com/bpatrik/pigallery2.git
synced 2025-12-01 22:52:06 +02:00
improving utf8 image metadata support
This commit is contained in:
@@ -116,7 +116,6 @@ export class AuthenticationMWs {
|
||||
(typeof req.body.loginCredential.password === 'undefined')) {
|
||||
return next(new ErrorDTO(ErrorCodes.INPUT_ERROR));
|
||||
}
|
||||
//TODO: implement remember me
|
||||
try {
|
||||
//lets find the user
|
||||
const user = Utils.clone(await ObjectManagerRepository.getInstance().UserManager.findOne({
|
||||
|
||||
@@ -4,7 +4,7 @@ import {CameraMetadata, GPSMetadata, ImageSize, PhotoDTO, PhotoMetadata} from ".
|
||||
import {Logger} from "../../Logger";
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
import * as iptc from "node-iptc";
|
||||
import {IptcParser} from "ts-node-iptc";
|
||||
import * as exif_parser from "exif-parser";
|
||||
import {ProjectPath} from "../../ProjectPath";
|
||||
|
||||
@@ -53,7 +53,7 @@ export class DiskMangerWorker {
|
||||
const exif = exif_parser.create(data).parse();
|
||||
metadata.cameraData = <CameraMetadata> {
|
||||
ISO: exif.tags.ISO,
|
||||
model: exif.tags.Model.toString("utf8"),
|
||||
model: exif.tags.Model,
|
||||
make: exif.tags.Make,
|
||||
fStop: exif.tags.FNumber,
|
||||
exposure: exif.tags.ExposureTime,
|
||||
@@ -76,18 +76,7 @@ export class DiskMangerWorker {
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
const iptcData = iptc(data);
|
||||
//Decode characters to UTF8
|
||||
const decode = (s: any) => {
|
||||
for (let 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("");
|
||||
};
|
||||
|
||||
const iptcData = IptcParser.parse(data);
|
||||
if (iptcData.country_or_primary_location_name || iptcData.province_or_state || iptcData.city) {
|
||||
metadata.positionData = metadata.positionData || {};
|
||||
metadata.positionData.country = iptcData.country_or_primary_location_name;
|
||||
@@ -95,11 +84,10 @@ export class DiskMangerWorker {
|
||||
metadata.positionData.city = iptcData.city;
|
||||
}
|
||||
|
||||
|
||||
metadata.keywords = <string[]> (iptcData.keywords || []).map((s: string) => decode(s));
|
||||
metadata.creationDate = <number> iptcData.date_time ? iptcData.date_time.getTime() : 0;
|
||||
metadata.keywords = <string[]> (iptcData.keywords || []);
|
||||
metadata.creationDate = <number> (iptcData.date_time ? iptcData.date_time.getTime() : 0);
|
||||
} catch (err) {
|
||||
Logger.info(LOG_TAG, "Error parsing iptc data", fullPath);
|
||||
Logger.info(LOG_TAG, "Error parsing iptc data", fullPath, err);
|
||||
}
|
||||
|
||||
return resolve(metadata);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import * as _express from "express";
|
||||
import * as _session from "cookie-session";
|
||||
import * as _bodyParser from "body-parser";
|
||||
import * as _http from "http";
|
||||
import {PublicRouter} from "./routes/PublicRouter";
|
||||
@@ -17,6 +16,7 @@ import {ThumbnailGeneratorMWs} from "./middlewares/thumbnail/ThumbnailGeneratorM
|
||||
import {DiskManager} from "./model/DiskManger";
|
||||
import {NotificationRouter} from "./routes/NotificationRouter";
|
||||
import {ConfigDiagnostics} from "./model/ConfigDiagnostics";
|
||||
import _session = require('cookie-session');
|
||||
|
||||
const LOG_TAG = "[server]";
|
||||
export class Server {
|
||||
|
||||
Reference in New Issue
Block a user