Class CoverArt

java.lang.Object
org.apache.tika.parser.audio.CoverArt

public final class CoverArt extends Object
Picks the picture that stands for an audio file among its embedded pictures and sends them all to the embedded document extractor. That picture is emitted as a TikaCoreProperties.EmbeddedResourceType.THUMBNAIL, like the preview image of the document container formats, so a client can find the representative image of any file the same way; the other pictures are TikaCoreProperties.EmbeddedResourceType.INLINE. See TIKA-4850.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
    One embedded picture of an audio file.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The ID3v2 APIC picture type of the front cover, shared by the FLAC and Vorbis picture blocks.
    static final int
    The ID3v2 APIC picture type "Other".
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Sends the pictures of one audio file to the embedded document extractor: the one thumbnailIndex(List) picks as the THUMBNAIL, the others as INLINE pictures.
    resourceType(int index, int thumbnailIndex)
    The resource type of the picture at the given index.
    static int
    thumbnailIndex(List<Integer> pictureTypes)
    Returns the index of the picture to mark as the thumbnail: the first front cover; else the first picture whose type is "Other" or unknown, which is where taggers put the main art when they do not classify it, rather than e.g. a back cover or a leaflet that happens to come first; else the first picture.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • FRONT_COVER

      public static final int FRONT_COVER
      The ID3v2 APIC picture type of the front cover, shared by the FLAC and Vorbis picture blocks.
      See Also:
    • OTHER

      public static final int OTHER
      The ID3v2 APIC picture type "Other". Many taggers store the main cover art with this type instead of marking it a front cover.
      See Also:
  • Method Details

    • thumbnailIndex

      public static int thumbnailIndex(List<Integer> pictureTypes)
      Returns the index of the picture to mark as the thumbnail: the first front cover; else the first picture whose type is "Other" or unknown, which is where taggers put the main art when they do not classify it, rather than e.g. a back cover or a leaflet that happens to come first; else the first picture.
      Parameters:
      pictureTypes - the picture types in file order; a negative value for a picture whose type is unknown
      Returns:
      the index, or -1 if there are no pictures
    • resourceType

      public static TikaCoreProperties.EmbeddedResourceType resourceType(int index, int thumbnailIndex)
      The resource type of the picture at the given index.
    • extractPictures

      public static void extractPictures(List<CoverArt.Picture> pictures, XHTMLContentHandler xhtml, ParseContext context) throws IOException, SAXException
      Sends the pictures of one audio file to the embedded document extractor: the one thumbnailIndex(List) picks as the THUMBNAIL, the others as INLINE pictures. The pictures only become embedded documents, no metadata is recorded on the audio document itself. Call once per file, with all of its pictures, so exactly one of them is the thumbnail.
      Throws:
      IOException
      SAXException