createFallbackJpgWriter = (storage, imageResizer) => async ({width, height, data}, maxSize, dst) => {
  const t0 = Date.now()
  const result = jpegJs.encode({width, height, data}, sharpJpgOptions.quality)
  log.debug(t0, `Encoded raw image data (${width}x${height}) to JPEG via jpeg-js`)
  if (Math.max(width, height) <= maxSize) {
    return fs.writeFile(dst, result.data)
  }

  const t1 = Date.now()
  const localDir = await storage.createLocalDir()
  const tmpFile = path.resolve(localDir.dir, 'heic-resize.jpg')
  return fs.writeFile(tmpFile, result.data)
    .then(() => imageResizer(tmpFile, dst, maxSize))
    .then(() => {
      log.debug(t1, `Resized heic preview to ${maxSize}`)
    })
    .finally(() => localDir.release())
}
@param {import('@home-gallery/types').TStorage} storage
@param {import('./image-resizer.js').ImageResizer} imageResizer