2026-02-14 00:59:57 +01:00
|
|
|
/**
|
|
|
|
|
* EXIF metadata API route — returns camera/lens/settings info for an asset.
|
|
|
|
|
* Called on-demand by the lightbox when the user clicks "Info".
|
|
|
|
|
*
|
|
|
|
|
* The :token is an encoded asset ID (not a raw UUID).
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { NextResponse } from 'next/server';
|
|
|
|
|
import { immich } from '@/lib/immich';
|
|
|
|
|
import { decodeAssetId } from '@/lib/tokens';
|
|
|
|
|
|
2026-02-14 11:47:26 +01:00
|
|
|
export async function GET(_request: Request, { params }: { params: Promise<{ id: string }> }) {
|
|
|
|
|
const { id: token } = await params;
|
2026-02-14 00:59:57 +01:00
|
|
|
|
2026-02-14 11:47:26 +01:00
|
|
|
// Decode the opaque token back to an Immich asset ID
|
|
|
|
|
const assetId = decodeAssetId(token);
|
|
|
|
|
if (!assetId) {
|
|
|
|
|
return NextResponse.json({ error: 'Invalid token' }, { status: 400 });
|
|
|
|
|
}
|
2026-02-14 00:59:57 +01:00
|
|
|
|
2026-02-14 11:47:26 +01:00
|
|
|
const asset = await immich.getAssetInfo(assetId);
|
|
|
|
|
if (!asset?.exifInfo) {
|
|
|
|
|
return NextResponse.json({ error: 'No EXIF data' }, { status: 404 });
|
|
|
|
|
}
|
2026-02-14 00:59:57 +01:00
|
|
|
|
2026-02-14 11:47:26 +01:00
|
|
|
const exif = asset.exifInfo;
|
|
|
|
|
return NextResponse.json({
|
|
|
|
|
make: exif.make,
|
|
|
|
|
model: exif.model,
|
|
|
|
|
lensModel: exif.lensModel,
|
|
|
|
|
focalLength: exif.focalLength,
|
|
|
|
|
fNumber: exif.fNumber,
|
|
|
|
|
exposureTime: exif.exposureTime,
|
|
|
|
|
iso: exif.iso,
|
|
|
|
|
city: exif.city,
|
|
|
|
|
country: exif.country,
|
|
|
|
|
});
|
2026-02-14 00:59:57 +01:00
|
|
|
}
|