Package org.apache.tika.parser.audio
Class CoverArt
java.lang.Object
org.apache.tika.parser.audio.CoverArt
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 ClassesModifier and TypeClassDescriptionstatic final recordOne embedded picture of an audio file. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe ID3v2 APIC picture type of the front cover, shared by the FLAC and Vorbis picture blocks.static final intThe ID3v2 APIC picture type "Other". -
Method Summary
Modifier and TypeMethodDescriptionstatic voidextractPictures(List<CoverArt.Picture> pictures, XHTMLContentHandler xhtml, ParseContext context) Sends the pictures of one audio file to the embedded document extractor: the onethumbnailIndex(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 intthumbnailIndex(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.
-
Field Details
-
FRONT_COVER
public static final int FRONT_COVERThe ID3v2 APIC picture type of the front cover, shared by the FLAC and Vorbis picture blocks.- See Also:
-
OTHER
public static final int OTHERThe 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
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
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 onethumbnailIndex(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:
IOExceptionSAXException
-