31dff10636
Sharp's prebuilt libvips lacks HEIF codec support. Replace with heic-convert (pure JS decoder) for reliable HEIC conversion on all platforms. Existing HEIC files on disk will be converted on-the-fly when served via /api/files. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
16 lines
416 B
TypeScript
16 lines
416 B
TypeScript
// @ts-expect-error no type declarations available
|
|
import heicConvert from 'heic-convert'
|
|
|
|
/**
|
|
* Convert HEIC/HEIF buffer to JPEG.
|
|
* Uses heic-convert (pure JS) since sharp's prebuilt libvips lacks HEIF support.
|
|
*/
|
|
export async function convertHeicToJpeg(buffer: Buffer): Promise<Buffer> {
|
|
const result = await heicConvert({
|
|
buffer,
|
|
format: 'JPEG',
|
|
quality: 0.9,
|
|
})
|
|
return Buffer.from(result)
|
|
}
|