Handle null exif.tags in getOffsetFromExif (#389)
Handle null exif.tags in getOffsetFromExif
`Object.values()` throws "Cannot convert undefined or null to object"
when `exif.tags` or `exifr` is null/undefined. This occurs when
uploading images that lack EXIF data (e.g., AI-generated images,
screenshots, or graphics). The issue is reproducible on Chrome but
not on Safari, likely due to differences in how each browser's
EXIF parsing pipeline populates these values.
This fix adds nullish coalescing fallbacks (`?? {}`) so that
`Object.values()` always receives a valid object.
* Fix optional chaining in getOffsetFromExif
If `exif` itself is null/undefined,
accessing `exif.tags` would throw before the `??` fallback kicks in.
This commit is contained in:
parent
da6c6ef09c
commit
a8b7c05e0c
@ -16,8 +16,8 @@ export const getOffsetFromExif = (
|
|||||||
exif: ExifData,
|
exif: ExifData,
|
||||||
exifr: any,
|
exifr: any,
|
||||||
) => (
|
) => (
|
||||||
Object.values(exif.tags as any).find(isValueOffset) ||
|
Object.values(exif?.tags ?? {}).find(isValueOffset) ||
|
||||||
Object.values(exifr).find(isValueOffset)
|
Object.values(exifr ?? {}).find(isValueOffset)
|
||||||
) as string | undefined;
|
) as string | undefined;
|
||||||
|
|
||||||
export const getDimensionsFromExif = (
|
export const getDimensionsFromExif = (
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user