Class: Picture

March 10, 2023 · View on GitHub

node-taglib-sharp / Exports / Picture

Class: Picture

This class implements IPicture and provides a mechanism for loading pictures from files.

Implements

Table of contents

Properties

Methods

Properties

data

data: ByteVector

Gets and sets the picture data stored in the current instance.

Implementation of

IPicture.data


description

description: string

Gets and sets a description of the picture stored in the current instance. Optional.

Implementation of

IPicture.description


filename

filename: string

Gets and sets a filename of the picture stored in the current instance. Optional.

Implementation of

IPicture.filename


mimeType

mimeType: string

Gets and sets the mime-type of the picture data stored in the current instance.

Implementation of

IPicture.mimeType


type

type: PictureType

Gets and sets the type of the content visible in the picture stored in the current instance.

Implementation of

IPicture.type

Methods

fromData

Static fromData(data): Picture

Constructs and initializes a new instance from the data provided. The data is processed to discover the type of the picture.

Parameters

NameTypeDescription
dataByteVectorRaw bytes of the picture to store in the instance. Cannot be falsey

Returns

Picture


fromFileAbstraction

Static fromFileAbstraction(abstraction): 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.

Parameters

NameTypeDescription
abstractionIFileAbstractionFile abstraction to load the picture from.

Returns

Picture


fromFullData

Static fromFullData(data, type, mimeType, description): Picture

Constructs a new instance with the data provided. No processing of the data is done.

Parameters

NameTypeDescription
dataByteVectorRaw bytes of the picture to store in the instance. Cannot be falsey
typePictureTypeType of the picture. Cannot be null or undefined
mimeTypestringMimeType of the picture. Cannot be falsey
descriptionstringDescription of the picture. Cannot be null or undefined

Returns

Picture


fromPath

Static fromPath(filePath): Picture

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.

Parameters

NameTypeDescription
filePathstringPath to the file to use for the file

Returns

Picture


getExtensionFromData

Static getExtensionFromData(data): string

Retrieve a mimetype from raw file data by reading the first few bytes of the file. Less accurate than getExtensionFromMimeType since this is limited to image file types.

Parameters

NameTypeDescription
dataByteVectorBytes of the file to read to identify the extension

Returns

string

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


getExtensionFromMimeType

Static getExtensionFromMimeType(mime): string

Gets the file extension for a specific mimetype.

Parameters

NameTypeDescription
mimestringMimetype to look up the extension for

Returns

string

Extension of the file based on the mimetype with a dot at the beginning. If the extension cannot be determined, undefined is returned


getMimeTypeFromFilename

Static getMimeTypeFromFilename(name): 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.

Parameters

NameTypeDescription
namestringFilename with extension or just the extension of the file

Returns

string

Mimetype of the file based on the extension. If mimetype cannot be determined, application/octet-stream is returned.