( context: ImageCompressionContext, sharp: SharpFunction, )
| 745 | } |
| 746 | |
| 747 | async function createUltraCompressedJPEG( |
| 748 | context: ImageCompressionContext, |
| 749 | sharp: SharpFunction, |
| 750 | ): Promise<CompressedImageResult> { |
| 751 | const ultraCompressedBuffer = await sharp(context.imageBuffer) |
| 752 | .resize(400, 400, { |
| 753 | fit: 'inside', |
| 754 | withoutEnlargement: true, |
| 755 | }) |
| 756 | .jpeg({ quality: 20 }) |
| 757 | .toBuffer() |
| 758 | |
| 759 | return createCompressedImageResult( |
| 760 | ultraCompressedBuffer, |
| 761 | 'jpeg', |
| 762 | context.originalSize, |
| 763 | ) |
| 764 | } |
| 765 | |
| 766 | /** |
| 767 | * Detect image format from a buffer using magic bytes |
no test coverage detected