import { ByteVector } from "./byteVector"; import { IFileAbstraction } from "./fileAbstraction"; import { ILazy } from "./interfaces"; /** * The type of content appearing in an {@link IPicture} instance. */ export declare enum PictureType { /** * @summary The picture is of a type other than those specified. */ Other = 0, /** * @summary The picture is a 32x32 PNG image that should be used when displaying the file in a browser. */ FileIcon = 1, /** * @summary The picture is of an icon different from {@link FileIcon} */ OtherFileIcon = 2, /** * @summary The picture is of the front cover of the album. */ FrontCover = 3, /** * @summary The picture is of the back cover of the album. */ BackCover = 4, /** * @summary The picture is of a leaflet page including with the album. */ LeafletPage = 5, /** * @summary The picture is of the album or disc itself. */ Media = 6, /** * @summary The picture is of the lead artist or soloist. */ LeadArtist = 7, /** * @summary The picture is of the artist or performer. */ Artist = 8, /** * @summary The picture is of the conductor. */ Conductor = 9, /** * @summary The picture is of the band or orchestra. */ Band = 10, /** * @summary The picture is of the composer. */ Composer = 11, /** * @summary The picture is of the lyricist or text writer. */ Lyricist = 12, /** * @summary The picture is of the recording location or studio. */ RecordingLocation = 13, /** * @summary The picture is one taken during the track's recording. */ DuringRecording = 14, /** * @summary The picture is one taken during the track's performance. */ DuringPerformance = 15, /** * @summary The picture is a capture from a movie screen. */ MovieScreenCapture = 16, /** * @summary The picture is of a large, colored fish. */ ColoredFish = 17, /** * @summary The picture is an illustration related to the track. */ Illustration = 18, /** * @summary The picture contains the logo of the band or performer. */ BandLogo = 19, /** * @summary The picture is the logo of the publisher or record */ PublisherLogo = 20, /** * @summary In fact, this is not a Picture, but another file-type. */ NotAPicture = 255 } /** * Interface that provides generic information about a picture, including its contents, as used by * various formats. */ export interface IPicture { /** * Gets and sets the mime-type of the picture data stored in the current instance. */ mimeType: string; /** * Gets and sets the type of the content visible in the picture stored in the current instance. */ type: PictureType; /** * Gets and sets a filename of the picture stored in the current instance. Optional. */ filename: string; /** * Gets and sets a description of the picture stored in the current instance. Optional. */ description: string; /** * Gets and sets the picture data stored in the current instance. */ data: ByteVector; } /** * This class implements {@link IPicture} and provides a mechanism for loading pictures from files. */ export declare class Picture implements IPicture { private static readonly EXTENSION_TO_MIMETYPES; private constructor(); /** * Constructs and initializes a new instance from a file located at the provided path. The type * and description of the picture are determined by the extension of the file. The file is * loaded completely. * @param filePath Path to the file to use for the file */ static fromPath(filePath: string): Picture; /** * Constructs and initializes a new instance from the data provided. The data is processed to * discover the type of the picture. * @param data Raw bytes of the picture to store in the instance. Cannot be falsey */ static fromData(data: ByteVector): Picture; /** * Constructs a new instance with the data provided. No processing of the data is done. * @param data Raw bytes of the picture to store in the instance. Cannot be falsey * @param type Type of the picture. Cannot be null or undefined * @param mimeType MimeType of the picture. Cannot be falsey * @param description Description of the picture. Cannot be null or undefined */ static fromFullData(data: ByteVector, type: PictureType, mimeType: string, description: string): Picture; /** * Constructs and initializes a new instance from a file abstraction. The description and type * of the file are determined by the name of the abstraction. * @param abstraction File abstraction to load the picture from. */ static fromFileAbstraction(abstraction: IFileAbstraction): Picture; /** @inheritDoc */ data: ByteVector; /** @inheritDoc */ description: string; /** @inheritDoc */ filename: string; /** @inheritDoc */ mimeType: string; /** * Gets and sets the type of the content visible in the picture stored in the current instance. */ type: PictureType; /** * Retrieve a mimetype from raw file data by reading the first few bytes of the file. Less * accurate than {@link getExtensionFromMimeType} since this is limited to image file types. * @param data Bytes of the file to read to identify the extension * @returns * Extension of the file with dot at the beginning based on the first few bytes * of the data. If the extension cannot be determined, `undefined` is returned */ static getExtensionFromData(data: ByteVector): string; /** * Gets the file extension for a specific mimetype. * @param mime Mimetype to look up the extension for * @returns * Extension of the file based on the mimetype with a dot at the beginning. If * the extension cannot be determined, `undefined` is returned */ static getExtensionFromMimeType(mime: string): string; /** * Gets the mimetype of a file based on its extension. If the mimetype cannot be determined, it * is assumed to be a basic binary file. * @param name Filename with extension or just the extension of the file * @returns * Mimetype of the file based on the extension. If mimetype cannot be * determined, application/octet-stream is returned. */ static getMimeTypeFromFilename(name: string): string; } /** * This class implements {@link IPicture} and provides mechanisms for loading pictures from files. * Contrary to {@link Picture}, a reference to a file where the picture is located can be given and * the picture is lazily loaded from the file, meaning that it will be read from the file only when * needed. This saves time and memory if the picture loading is not required. */ export declare class PictureLazy implements IPicture, ILazy { private _data; private _description; private _file; private _filename; private _mimeType; private _streamOffset; private _streamSize; private _type; private constructor(); /** * Constructs a new picture using data that's already been read into memory. The content * will not be lazily loaded. * @param data ByteVector Object containing picture data */ static fromData(data: ByteVector): PictureLazy; /** * Constructs a new instance from a file abstraction. The content will be lazily loaded. * @param file File abstraction containing the file to read * @param offset Index into the file where the picture is located, must be a 32-bit integer * @param size Optionally, size of the picture in bytes. If omitted, all bytes of file will be * read when lazily loaded. Must be a 32-bit integer or `undefined` */ static fromFile(file: IFileAbstraction, offset: number, size?: number): PictureLazy; /** * Constructs a new instance that will be lazily loaded from the filePath provided. * @param filePath Path to the file to read */ static fromPath(filePath: string): PictureLazy; /** @inheritDoc */ get data(): ByteVector; /** @inheritDoc */ set data(value: ByteVector); /** @inheritDoc */ get description(): string; /** @inheritDoc */ set description(value: string); /** @inheritDoc */ get filename(): string; /** @inheritDoc */ set filename(value: string); /** @inheritDoc */ get isLoaded(): boolean; /** @inheritDoc */ get mimeType(): string; /** @inheritDoc */ set mimeType(value: string); /** @inheritDoc */ get type(): PictureType; /** @inheritDoc */ set type(value: PictureType); /** @inheritDoc */ load(): void; }