( context: ImageCompressionContext, sharp: SharpFunction, )
| 758 | } |
| 759 | |
| 760 | async function createUltraCompressedJPEG( |
| 761 | context: ImageCompressionContext, |
| 762 | sharp: SharpFunction, |
| 763 | ): Promise<CompressedImageResult> { |
| 764 | const ultraCompressedBuffer = await sharp(context.imageBuffer) |
| 765 | .resize(400, 400, { |
| 766 | fit: 'inside', |
| 767 | withoutEnlargement: true, |
| 768 | }) |
| 769 | .jpeg({ quality: 20 }) |
| 770 | .toBuffer() |
| 771 | |
| 772 | return createCompressedImageResult( |
| 773 | ultraCompressedBuffer, |
| 774 | 'jpeg', |
| 775 | context.originalSize, |
| 776 | ) |
| 777 | } |
| 778 | |
| 779 | /** |
| 780 | * Detect image format from a buffer using magic bytes |
no test coverage detected