static imageStreamToTrack(stream) {
    const ContentType = shaka.util.ManifestParserUtils.ContentType;

    let width = stream.width || null;
    let height = stream.height || null;

    // The stream width and height represent the size of the entire thumbnail
    // sheet, so divide by the layout.
    let reference = null;
    // Note: segmentIndex is built by default for HLS, but not for DASH, but
    // in DASH this information comes at the stream level and not at the
    // segment level.
    if (stream.segmentIndex) {
      reference = stream.segmentIndex.earliestReference();
    }
    let layout = stream.tilesLayout;
    if (reference) {
      layout = reference.getTilesLayout() || layout;
    }
    if (layout && width != null) {
      width /= Number(layout.split('x')[0]);
    }
    if (layout && height != null) {
      height /= Number(layout.split('x')[1]);
    }
    // TODO: What happens if there are multiple grids, with different
    // layout sizes, inside this image stream?

    /** @type {shaka.extern.ImageTrack} */
    const track = {
      id: stream.id,
      type: ContentType.IMAGE,
      bandwidth: stream.bandwidth || 0,
      width,
      height,
      mimeType: stream.mimeType,
      codecs: stream.codecs || null,
      tilesLayout: layout || null,
      originalImageId: stream.originalId,
    };

    return track;
  }
@param {shaka.extern.Stream} stream
@return {shaka.extern.ImageTrack}