Interface MediaFormatHandler


  • @ProviderType
    public interface MediaFormatHandler
    Media format handling.

    The interface is implemented by a Sling Model. You can adapt from SlingHttpServletRequest or Resource to get a context-specific handler instance.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static double RATIO_TOLERANCE
      When comparing the ratio's of different media formats for automatic rendition generation, use this value as tolerance barrier when comparing ratios of different media formats.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      @Nullable MediaFormat detectMediaFormat​(@Nullable java.lang.String extension, long fileSize, long width, long height)
      Detect matching media format.
      @NotNull java.util.SortedSet<MediaFormat> detectMediaFormats​(@Nullable java.lang.String extension, long fileSize, long width, long height)
      Detect all matching media formats.
      @Nullable MediaFormat getMediaFormat​(@NotNull java.lang.String mediaFormatName)
      Resolves media format name to media format object.
      @NotNull java.util.SortedSet<MediaFormat> getMediaFormats()
      Get media formats defined by a CMS application that is responsible for the given media library path.
      @NotNull java.util.SortedSet<MediaFormat> getMediaFormats​(@NotNull java.util.Comparator<MediaFormat> comparator)
      Get media formats defined by a CMS application that is responsible for the given media library path.
      @NotNull java.util.SortedSet<MediaFormat> getSameBiggerMediaFormats​(@NotNull MediaFormat mediaFormatRequested, boolean filterRenditionGroup)
      Get list of media formats that have the same (or bigger) resolution as the requested media format and (nearly) the same aspect ratio.
      @NotNull java.util.SortedSet<MediaFormat> getSameSmallerMediaFormats​(@NotNull MediaFormat mediaFormatRequested, boolean filterRenditionGroup)
      Get list of possible media formats that can be rendered from the given media format, i.e.
    • Field Detail

      • RATIO_TOLERANCE

        static final double RATIO_TOLERANCE
        When comparing the ratio's of different media formats for automatic rendition generation, use this value as tolerance barrier when comparing ratios of different media formats.
        See Also:
        Constant Field Values
    • Method Detail

      • getMediaFormat

        @Nullable
        @Nullable MediaFormat getMediaFormat​(@NotNull
                                             @NotNull java.lang.String mediaFormatName)
        Resolves media format name to media format object.
        Parameters:
        mediaFormatName - Media format name
        Returns:
        Media format or null if no match found
      • getMediaFormats

        @NotNull
        @NotNull java.util.SortedSet<MediaFormat> getMediaFormats()
        Get media formats defined by a CMS application that is responsible for the given media library path.
        Returns:
        Media formats sorted by combined title
      • getMediaFormats

        @NotNull
        @NotNull java.util.SortedSet<MediaFormat> getMediaFormats​(@NotNull
                                                                  @NotNull java.util.Comparator<MediaFormat> comparator)
        Get media formats defined by a CMS application that is responsible for the given media library path.
        Parameters:
        comparator - Comparator for set
        Returns:
        Media formats
      • getSameBiggerMediaFormats

        @NotNull
        @NotNull java.util.SortedSet<MediaFormat> getSameBiggerMediaFormats​(@NotNull
                                                                            @NotNull MediaFormat mediaFormatRequested,
                                                                            boolean filterRenditionGroup)
        Get list of media formats that have the same (or bigger) resolution as the requested media format and (nearly) the same aspect ratio.
        Parameters:
        mediaFormatRequested - Requested media format
        filterRenditionGroup - Only check media formats of the same rendition group.
        Returns:
        Matching media formats, sorted by size (biggest first), ranking, name
      • getSameSmallerMediaFormats

        @NotNull
        @NotNull java.util.SortedSet<MediaFormat> getSameSmallerMediaFormats​(@NotNull
                                                                             @NotNull MediaFormat mediaFormatRequested,
                                                                             boolean filterRenditionGroup)
        Get list of possible media formats that can be rendered from the given media format, i.e. same size or smaller and (nearly) the same aspect ratio.
        Parameters:
        mediaFormatRequested - Available media format
        filterRenditionGroup - Only check media formats of the same rendition group.
        Returns:
        Matching media formats, sorted by size (biggest first), ranking, name
      • detectMediaFormat

        @Nullable
        @Nullable MediaFormat detectMediaFormat​(@Nullable
                                                @Nullable java.lang.String extension,
                                                long fileSize,
                                                long width,
                                                long height)
        Detect matching media format.
        Parameters:
        extension - File extension
        fileSize - File size
        width - Image width (or 0 if not image)
        height - Image height (or 0 if not image)
        Returns:
        Media format or null if no matching media format found
      • detectMediaFormats

        @NotNull
        @NotNull java.util.SortedSet<MediaFormat> detectMediaFormats​(@Nullable
                                                                     @Nullable java.lang.String extension,
                                                                     long fileSize,
                                                                     long width,
                                                                     long height)
        Detect all matching media formats.
        Parameters:
        extension - File extension
        fileSize - File size
        width - Image width (or 0 if not image)
        height - Image height (or 0 if not image)
        Returns:
        Matching media formats sorted by their ranking or an empty list if no matching format was found