( buffer: Buffer, mediaType: string, originalSize: number, )
| 645 | // Helper functions for compression pipeline |
| 646 | |
| 647 | function createCompressedImageResult( |
| 648 | buffer: Buffer, |
| 649 | mediaType: string, |
| 650 | originalSize: number, |
| 651 | ): CompressedImageResult { |
| 652 | const normalizedMediaType = mediaType === 'jpg' ? 'jpeg' : mediaType |
| 653 | return { |
| 654 | base64: buffer.toString('base64'), |
| 655 | mediaType: |
| 656 | `image/${normalizedMediaType}` as Base64ImageSource['media_type'], |
| 657 | originalSize, |
| 658 | } |
| 659 | } |
| 660 | |
| 661 | async function tryProgressiveResizing( |
| 662 | context: ImageCompressionContext, |
no test coverage detected