async function heicPreview(storage, imagePreviewSizes, jpgWriter) {

  const test = entry => {
    if (!imageTypes.includes(entry.type) || hasJpg(entry) || storage.hasFile(entry, rawPreviewSuffix)) {
      return false
    }
    if (hasHeic(entry)) {
      return true
    }
    return false
  }

  const task = async (entry) => {
    const t0 = Date.now()

    const heicEntry = findHeicEntry(entry)
    const src = await heicEntry.getFile()
    const localFile = await storage.createLocalFile(entry, rawPreviewSuffix)
    const maxSize = Math.max(...imagePreviewSizes) || 1920
    return convertHeic(src, maxSize, localFile.file, jpgWriter)
      .then(() => localFile.commit())
      .then(() => {
        log.debug(t0, `Created jpg preview image from heic image of ${entry}`)
      })
      .catch(err => {
        return localFile.release()
          .finally(() => {
            log.error(err, `Failed to convert heic image of ${entry}`)
          })
      })
  }

  return {
    test,
    task
  }
}
@param {import('@home-gallery/types').TStorage} storage
@param {number[]} imagePreviewSizes
@param {TJpgWriter} jpgWriter
@returns {import('stream').Transform}