Return exif in info call
parent
1d65a6dabe
commit
0fbe35db7d
|
@ -52,7 +52,8 @@ class ImageController extends ApiBase
|
||||||
$file = $file[0];
|
$file = $file[0];
|
||||||
|
|
||||||
// Get the image info
|
// Get the image info
|
||||||
$info = $this->timelineQuery->getInfoById($file->getId());
|
$basic = false !== $this->request->getParam('basic', false);
|
||||||
|
$info = $this->timelineQuery->getInfoById($file->getId(), $basic);
|
||||||
|
|
||||||
return new JSONResponse($info, Http::STATUS_OK);
|
return new JSONResponse($info, Http::STATUS_OK);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,14 +48,18 @@ class TimelineQuery
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInfoById(int $id): array
|
public function getInfoById(int $id, bool $basic): array
|
||||||
{
|
{
|
||||||
$qb = $this->connection->getQueryBuilder();
|
$qb = $this->connection->getQueryBuilder();
|
||||||
$qb->select('fileid', 'dayid', 'datetaken')
|
$qb->select('fileid', 'dayid', 'datetaken', 'w', 'h')
|
||||||
->from('memories')
|
->from('memories')
|
||||||
->where($qb->expr()->eq('fileid', $qb->createNamedParameter($id, \PDO::PARAM_INT)))
|
->where($qb->expr()->eq('fileid', $qb->createNamedParameter($id, \PDO::PARAM_INT)))
|
||||||
;
|
;
|
||||||
|
|
||||||
|
if (!$basic) {
|
||||||
|
$qb->addSelect('exif');
|
||||||
|
}
|
||||||
|
|
||||||
$result = $qb->executeQuery();
|
$result = $qb->executeQuery();
|
||||||
$row = $result->fetch();
|
$row = $result->fetch();
|
||||||
$result->closeCursor();
|
$result->closeCursor();
|
||||||
|
@ -72,6 +76,9 @@ class TimelineQuery
|
||||||
'fileid' => (int) $row['fileid'],
|
'fileid' => (int) $row['fileid'],
|
||||||
'dayid' => (int) $row['dayid'],
|
'dayid' => (int) $row['dayid'],
|
||||||
'datetaken' => $utcTs,
|
'datetaken' => $utcTs,
|
||||||
|
'w' => (int) $row['w'],
|
||||||
|
'h' => (int) $row['h'],
|
||||||
|
'exif' => $basic ? [] : json_decode($row['exif'], true),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,20 +99,12 @@ class TimelineWrite
|
||||||
|
|
||||||
// Store raw metadata in the database
|
// Store raw metadata in the database
|
||||||
// We need to remove blacklisted fields to prevent leaking info
|
// We need to remove blacklisted fields to prevent leaking info
|
||||||
unset($exif['SourceFile']);
|
unset($exif['SourceFile'], $exif['FileName'], $exif['ExifToolVersion'], $exif['Directory'], $exif['FileSize'], $exif['FileModifyDate'], $exif['FileAccessDate'], $exif['FileInodeChangeDate'], $exif['FilePermissions']);
|
||||||
unset($exif['FileName']);
|
|
||||||
unset($exif['ExifToolVersion']);
|
|
||||||
unset($exif['Directory']);
|
|
||||||
unset($exif['FileSize']);
|
|
||||||
unset($exif['FileModifyDate']);
|
|
||||||
unset($exif['FileAccessDate']);
|
|
||||||
unset($exif['FileInodeChangeDate']);
|
|
||||||
unset($exif['FilePermissions']);
|
|
||||||
|
|
||||||
// Truncate any fields >2048 chars
|
// Truncate any fields >2048 chars
|
||||||
foreach ($exif as $key => &$value) {
|
foreach ($exif as $key => &$value) {
|
||||||
if (\is_string($value) && \strlen($value) > 2048) {
|
if (\is_string($value) && \strlen($value) > 2048) {
|
||||||
$exif[$key] = \substr($value, 0, 2048);
|
$exif[$key] = substr($value, 0, 2048);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -186,7 +186,7 @@ export default class EditDate extends Mixins(GlobalMixin) {
|
||||||
const calls = photos.map((p) => async () => {
|
const calls = photos.map((p) => async () => {
|
||||||
try {
|
try {
|
||||||
const res = await axios.get<any>(
|
const res = await axios.get<any>(
|
||||||
generateUrl(INFO_API_URL, { id: p.fileid })
|
generateUrl(INFO_API_URL, { id: p.fileid }) + "?basic=1"
|
||||||
);
|
);
|
||||||
if (typeof res.data.datetaken !== "number") {
|
if (typeof res.data.datetaken !== "number") {
|
||||||
console.error("Invalid date for", p.fileid);
|
console.error("Invalid date for", p.fileid);
|
||||||
|
|
Loading…
Reference in New Issue