(images)
| 310 | var sizesCache = {}; |
| 311 | |
| 312 | async function getSizes(images) |
| 313 | { |
| 314 | await loadSharp(); |
| 315 | |
| 316 | const sizes = []; |
| 317 | const promises = []; |
| 318 | const len = images.length; |
| 319 | |
| 320 | for(let i = 0; i < len; i++) |
| 321 | { |
| 322 | sizes.push(false); |
| 323 | |
| 324 | const image = images[i]; |
| 325 | |
| 326 | if(!image.image || image.folder) |
| 327 | continue; |
| 328 | |
| 329 | const sha = image.sha || sha1(image.path); |
| 330 | |
| 331 | if(sizesCache[sha]) |
| 332 | { |
| 333 | sizes[i] = sizesCache[sha]; |
| 334 | continue; |
| 335 | } |
| 336 | |
| 337 | promises.push(threads.job('getImageSizes', {useThreads: 1}, async function() { |
| 338 | |
| 339 | let size = { |
| 340 | width: 1, |
| 341 | height: 1, |
| 342 | }; |
| 343 | |
| 344 | try |
| 345 | { |
| 346 | |
| 347 | const path = fileManager.realPath(image.path, -1); |
| 348 | const extension = app.extname(image.image); |
| 349 | const pathExtension = app.extname(path); |
| 350 | |
| 351 | if(compatible.image.heic.has(pathExtension)) |
| 352 | { |
| 353 | if(heic === false) |
| 354 | heic = require('heic-decode'); |
| 355 | |
| 356 | const buffer = await fsp.readFile(path); |
| 357 | const images = await heic.all({buffer}); |
| 358 | const properties = images[0] || {width: 1, height: 1}; |
| 359 | images.dispose(); |
| 360 | |
| 361 | size = { |
| 362 | width: properties.width, |
| 363 | height: properties.height, |
| 364 | }; |
| 365 | } |
| 366 | else if(compatible.image.jp2.has(pathExtension)) |
| 367 | { |
| 368 | if(pdfjsDecoders === false) |
| 369 | await loadPdfjsDecoders(); |
nothing calls this directly
no test coverage detected