( image: SharpInstance, format: string, )
| 682 | } |
| 683 | |
| 684 | function applyFormatOptimizations( |
| 685 | image: SharpInstance, |
| 686 | format: string, |
| 687 | ): SharpInstance { |
| 688 | switch (format) { |
| 689 | case 'png': |
| 690 | return image.png({ |
| 691 | compressionLevel: 9, |
| 692 | palette: true, |
| 693 | }) |
| 694 | case 'jpeg': |
| 695 | case 'jpg': |
| 696 | return image.jpeg({ quality: 80 }) |
| 697 | case 'webp': |
| 698 | return image.webp({ quality: 80 }) |
| 699 | default: |
| 700 | return image |
| 701 | } |
| 702 | } |
| 703 | |
| 704 | async function tryPalettePNG( |
| 705 | context: ImageCompressionContext, |
no outgoing calls
no test coverage detected