| Conditions | 3 |
| Total Lines | 15 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import * as fs from "fs" |
||
| 3 | |||
| 4 | function getPictureMimeTypeFromBuffer(pictureBuffer: Buffer) { |
||
| 5 | if ( |
||
| 6 | pictureBuffer.length > 3 && |
||
| 7 | pictureBuffer.compare(Buffer.from([0xff, 0xd8, 0xff]), 0, 3, 0, 3) === 0 |
||
| 8 | ) { |
||
| 9 | return "image/jpeg" |
||
| 10 | } |
||
| 11 | if ( |
||
| 12 | pictureBuffer.length > 8 && |
||
| 13 | pictureBuffer.compare(Buffer.from([0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]), 0, 8, 0, 8) === 0 |
||
| 14 | ) { |
||
| 15 | return "image/png" |
||
| 16 | } |
||
| 17 | return "" |
||
| 18 | } |
||
| 37 |