( buffer: Buffer, mediaType: string, originalSize: number, )
| 630 | // Helper functions for compression pipeline |
| 631 | |
| 632 | function createCompressedImageResult( |
| 633 | buffer: Buffer, |
| 634 | mediaType: string, |
| 635 | originalSize: number, |
| 636 | ): CompressedImageResult { |
| 637 | const normalizedMediaType = mediaType === 'jpg' ? 'jpeg' : mediaType |
| 638 | return { |
| 639 | base64: buffer.toString('base64'), |
| 640 | mediaType: |
| 641 | `image/${normalizedMediaType}` as Base64ImageSource['media_type'], |
| 642 | originalSize, |
| 643 | } |
| 644 | } |
| 645 | |
| 646 | async function tryProgressiveResizing( |
| 647 | context: ImageCompressionContext, |
no test coverage detected