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
- fromData
- fromFileAbstraction
- fromFullData
- fromPath
- getExtensionFromData
- getExtensionFromMimeType
- getMimeTypeFromFilename
Properties
data
• data: ByteVector
Gets and sets the picture data stored in the current instance.
Implementation of
description
• description: string
Gets and sets a description of the picture stored in the current instance. Optional.
Implementation of
filename
• filename: string
Gets and sets a filename of the picture stored in the current instance. Optional.
Implementation of
mimeType
• mimeType: string
Gets and sets the mime-type of the picture data stored in the current instance.
Implementation of
type
• type: PictureType
Gets and sets the type of the content visible in the picture stored in the current instance.
Implementation of
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
| Name | Type | Description |
|---|---|---|
data | ByteVector | Raw bytes of the picture to store in the instance. Cannot be falsey |
Returns
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
| Name | Type | Description |
|---|---|---|
abstraction | IFileAbstraction | File abstraction to load the picture from. |
Returns
fromFullData
▸ Static fromFullData(data, type, mimeType, description): Picture
Constructs a new instance with the data provided. No processing of the data is done.
Parameters
| Name | Type | Description |
|---|---|---|
data | ByteVector | Raw bytes of the picture to store in the instance. Cannot be falsey |
type | PictureType | Type of the picture. Cannot be null or undefined |
mimeType | string | MimeType of the picture. Cannot be falsey |
description | string | Description of the picture. Cannot be null or undefined |
Returns
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
| Name | Type | Description |
|---|---|---|
filePath | string | Path to the file to use for the file |
Returns
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
| Name | Type | Description |
|---|---|---|
data | ByteVector | Bytes 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
| Name | Type | Description |
|---|---|---|
mime | string | Mimetype 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
| Name | Type | Description |
|---|---|---|
name | string | Filename 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.