mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-22 14:51:45 +00:00
da3cba2de3
* fix(mcp): replace relative oauth constent redirect by absolute redirect derived from APP_URL (#987) * feat(journey): convert HEIC/HEIF uploads to JPEG for cross-platform compatibility HEIC is an Apple-only format not recognised as an image by many browsers and platforms. heic-to (lazy-loaded) now converts HEIC/HEIF files to JPEG before upload in both the gallery and entry editor photo pickers. Embedded metadata (EXIF, GPS) may be lost during conversion — documented in the Journey Journal wiki page. * fix(journey): skip heic-to import for non-HEIC files to avoid test env failures * fix(notifications): prevent double-escaping HTML in password reset emails buildPasswordResetHtml passed a pre-built HTML block to buildEmailHtml, which then escaped it again — rendering raw tags as plain text in the email.
18 lines
776 B
TypeScript
18 lines
776 B
TypeScript
function looksLikeHeic(file: File): boolean {
|
|
const ext = file.name.split('.').pop()?.toLowerCase() ?? ''
|
|
return ext === 'heic' || ext === 'heif' || file.type === 'image/heic' || file.type === 'image/heif'
|
|
}
|
|
|
|
export async function normalizeImageFile(file: File): Promise<File> {
|
|
if (!looksLikeHeic(file)) return file
|
|
const { isHeic, heicTo } = await import('heic-to')
|
|
if (!(await isHeic(file))) return file
|
|
const blob = await heicTo({ blob: file, type: 'image/jpeg', quality: 0.92 })
|
|
const jpegName = file.name.replace(/\.(heic|heif)$/i, '.jpg')
|
|
return new File([blob], jpegName, { type: 'image/jpeg' })
|
|
}
|
|
|
|
export async function normalizeImageFiles(files: FileList | File[]): Promise<File[]> {
|
|
return Promise.all(Array.from(files).map(normalizeImageFile))
|
|
}
|