Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expanded try catch around extracting metadata #10497

Merged
merged 4 commits into from
Dec 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 14 additions & 9 deletions api/src/services/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,19 @@ export class FilesService extends ItemsService {

if (['image/jpeg', 'image/png', 'image/webp', 'image/gif', 'image/tiff'].includes(payload.type)) {
const buffer = await storage.disk(data.storage).getBuffer(payload.filename_disk);
const meta = await sharp(buffer.content, {}).metadata();

if (meta.orientation && meta.orientation >= 5) {
payload.height = meta.width;
payload.width = meta.height;
} else {
payload.width = meta.width;
payload.height = meta.height;
try {
const meta = await sharp(buffer.content, {}).metadata();

if (meta.orientation && meta.orientation >= 5) {
payload.height = meta.width;
payload.width = meta.height;
} else {
payload.width = meta.width;
payload.height = meta.height;
}
} catch (err: any) {
logger.warn(`Couldn't extract sharp metadata from file`);
logger.warn(err);
}

payload.metadata = {};
Expand All @@ -107,7 +112,7 @@ export class FilesService extends ItemsService {
payload.tags = payload.metadata.iptc.Keywords;
}
} catch (err: any) {
logger.warn(`Couldn't extract metadata from file`);
logger.warn(`Couldn't extract EXIF metadata from file`);
logger.warn(err);
}
}
Expand Down