| 10 | } |
| 11 | |
| 12 | async function resize(fromImage, toImage, config = {}) |
| 13 | { |
| 14 | await loadSharp(); |
| 15 | |
| 16 | if(!inChildFork) |
| 17 | { |
| 18 | fromImage = app.shortWindowsPath(fromImage); |
| 19 | fileManager.macosStartAccessingSecurityScopedResource(fromImage); |
| 20 | |
| 21 | const extension = app.extname(fromImage); |
| 22 | |
| 23 | if(/*compatible.image.ico.has(extension)/* || */compatible.image.ico.has(extension)) // Unsupported images format for resize |
| 24 | throw new Error({}); |
| 25 | } |
| 26 | |
| 27 | config = { |
| 28 | width: 200, |
| 29 | fit: sharp.fit.inside, |
| 30 | quality: 95, |
| 31 | background: 'white', |
| 32 | ...config, |
| 33 | }; |
| 34 | |
| 35 | return _resize(fromImage, toImage, config); |
| 36 | } |
| 37 | |
| 38 | async function _resize(fromImage, toImage, config = {}, deep = 0) |
| 39 | { |