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