Use heic-convert for HEIC-to-JPEG conversion
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>
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
// @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)
|
||||
}
|
||||
Reference in New Issue
Block a user