Skip to content

Artwork API ​

Methods for reading and resolving embedded and external album artwork, supporting fb2k:// protocol URLs, Base64 Data URLs, batch lookups, and scaling.

Artwork retrieval comparison ​

MethodReturn formatTypical use caseRecommendation
artwork.getFb2kUrl()fb2k:// URLCurrently playing track★★★★★
artwork.getFb2kUrlByPath()fb2k:// URLLazy loading for any track★★★★★
artwork.getFb2kUrlByPathBatch()fb2k:// URL arrayBatch cover retrieval★★★★★
artwork.getCurrent()Base64 Data URLImmediate inline rendering★★★
artwork.getForTrack()Base64 Data URLSingle track cover by path★★★

artwork ​

artwork.getAvailableArtwork ​

Report which picture types a file embeds and which cover files sit next to it. A file that is only in the cloud and not yet downloaded is not opened, so it embeds no pictures.

ParameterTypeRequiredDescription
pathstringYesTrack path; a |subsong:N suffix is dropped. Must not be empty.

Returns

FieldTypeDescription
availablebooleanWhether the file embeds at least one picture.
artworksArtworkAvailableEntry[]The embedded pictures, in probe order.
artworks[].typestringPicture type.
artworks[].sourcestringWhere it comes from; always embedded, since only embedded pictures are listed.
sourcesstring[]embedded once when any picture is embedded, then folder:<name> for each cover file (cover, folder, front, album as .jpg or .png) found next to the file.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const res = await fb2k.invoke('artwork.getAvailableArtwork', {
	path: 'C:\\Music\\song.flac',
});
if (res.success === false) throw new Error(res.error);
const { artworks, sources } = res;

artwork.getAvailableTypes ​

List the picture types embedded in a file, in the fixed probe order front, back, disc, icon, artist. Without path the playing track is used; with nothing playing the call fails with NO_ACTIVE_ITEM. A file that is missing, cannot be read or has a format without embedded pictures is not an error: it lists no types. A file that is only in the cloud and not yet downloaded is not opened and lists no types either.

ParameterTypeRequiredDescription
pathstringNoTrack path; omitted for the playing track.

Returns

FieldTypeDescription
typesstring[]The embedded picture types, in probe order.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const res = await fb2k.invoke('artwork.getAvailableTypes', {
	path: 'C:\\Music\\song.flac',
});
if (res.success === false) throw new Error(res.error);
const { types } = res;

artwork.getBatch ​

Read one picture type from several files with the album art extractor, one row per path in the given order; a file without the picture gets a row with available: false, as does a file that is only in the cloud and not yet downloaded, which is not opened.

ParameterTypeRequiredDescription
pathsstring[]YesTrack paths; a |subsong:N suffix is dropped.
type"front" | "cover_front" | "back" | "cover_back" | "disc" | "icon" | "artist"NoPicture type for every path. Default: "front".

Returns

FieldTypeDescription
artworksArtworkBatchRow[]One row per path, in the given order.
artworks[].pathstringThe path as given.
artworks[].availablebooleanWhether the file has the picture.
artworks[].mimeTypestringMIME type detected from the bytes.
artworks[].sizeintegerPicture size in bytes.
artworks[].dataUrlstringdata:<mime>;base64,... URL of the picture.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const res = await fb2k.invoke('artwork.getBatch', {
	paths: ['C:\\Music\\a.flac', 'C:\\Music\\b.flac'],
});
if (res.success === false) throw new Error(res.error);
const { artworks } = res;

artwork.getByPath ​

Read a picture straight from the file at path with the album art extractor. The |subsong:N suffix is dropped, since pictures belong to the file; a file-relative:// path is refused with INVALID_PATH, because only a playlist row can resolve it. A file that is only in the cloud and not yet downloaded is not opened and has no picture.

ParameterTypeRequiredDescription
pathstringYesTrack path: native, file://, or with a |subsong:N suffix. Must not be empty.
type"front" | "cover_front" | "back" | "cover_back" | "disc" | "icon" | "artist"NoPicture type. Default: "front".

Returns

FieldTypeDescription
availablebooleanWhether the file has the picture.
typestringThe requested type.
pathstringThe path as given.
mimeTypestringMIME type detected from the bytes.
sizeintegerPicture size in bytes.
dataUrlstringdata:<mime>;base64,... URL of the picture.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const res = await fb2k.invoke('artwork.getByPath', {
	path: 'C:\\Music\\song.flac',
});
if (res.success === false) throw new Error(res.error);
const { available, dataUrl } = res;

Path Contract

  • Supported: Native paths, file:// prefixes, and path|subsong:N (subsong is stripped; extractor operates at file level)
  • Rejected: file-relative:// paths return an explicit error; use artwork.getByPlaylistItem instead
  • Paths are normalized to canonical paths internally

artwork.getByPlaylistItem ​

Read the picture of a playlist row through the album art manager. A negative playlist means the active playlist and a negative index means the first row. A row past the end, an empty playlist included, fails with NOT_FOUND. A playlist index past the last playlist fails with INVALID_INDEX, a playlistGuid no playlist has with NOT_FOUND, and no active playlist when the active one is meant with NO_ACTIVE_ITEM. A row without the picture is a success with available false; so is a row whose file is only in the cloud and not yet downloaded, which is not opened.

ParameterTypeRequiredDescription
playlistintegerNoPlaylist index; negative for the active playlist. An index past the last playlist fails with INVALID_INDEX. Default: -1.
playlistGuidstringNoPersistent unique identifier of a playlist (bracketed GUID, case-insensitive), used in place of a mutable index. Mutually exclusive with playlist; passing both or an invalid format fails with INVALID_PARAMS. Fails with NOT_FOUND if the playlist does not exist, never falling back. Invalid-format and not-found failures return the given GUID in details.playlistGuid.
indexintegerNoRow index; negative for the first row. Default: -1.
type"front" | "cover_front" | "back" | "cover_back" | "disc" | "icon" | "artist"NoPicture type. Default: "front".

Returns

FieldTypeDescription
availablebooleanWhether a picture was found.
typestringThe requested type.
playlistintegerThe playlist actually read.
playlistGuidstringUnique identifier of the playlist, formatted as {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}. Pass as playlistGuid to reliably target this playlist.
indexintegerThe row actually read.
mimeTypestringMIME type detected from the bytes.
sizeintegerPicture size in bytes.
dataUrlstringdata:<mime>;base64,... URL of the picture.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const res = await fb2k.invoke('artwork.getByPlaylistItem', {
	index: 3,
});
if (res.success === false) throw new Error(res.error);
const { available, dataUrl } = res;

artwork.getCurrent ​

Read the picture of the playing track. Three lookups are tried in order and source names the one that answered; available: false with reason: "no_track" when nothing is playing and reason: "not_found" when none of them had a picture. A file that is only in the cloud and not yet downloaded is not opened, so the file lookups find nothing.

ParameterTypeRequiredDescription
type"front" | "cover_front" | "back" | "cover_back" | "disc" | "icon" | "artist"NoPicture type. Default: "front".

Returns

FieldTypeDescription
availablebooleanWhether a picture was found.
typestringThe requested type.
source"now_playing_manager" | "album_art_manager_v2" | "extractor"Lookup that answered: the now-playing cache, the album art manager, or the extractor.
mimeTypestringMIME type detected from the bytes.
sizeintegerPicture size in bytes.
dataUrlstringdata:<mime>;base64,... URL of the picture.
reason"no_track" | "not_found"Why no picture was found.
pathstringPath of the playing track; reported when no picture was found for it.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

source valueMeaning
now_playing_managerCached current front-cover artwork.
album_art_manager_v2Artwork resolved by the album-art manager fallback.
extractorArtwork resolved directly by the file extractor fallback.
js
const res = await fb2k.invoke('artwork.getCurrent');
if (res.success === false) throw new Error(res.error);
const { available, dataUrl, source } = res;

artwork.getFb2kUrl ​

Build the fb2k://artwork/ URL of the playing track's picture; the resource handler reads and scales the picture when the page loads the URL. available: false with reason: "no_track" when nothing is playing.

ParameterTypeRequiredDescription
type"front" | "cover_front" | "back" | "cover_back" | "disc" | "icon" | "artist"NoPicture type. Default: "front".
maxSizeintegerNoLongest side in pixels the handler scales the picture down to; omitted or 0 keeps the original size.

Returns

FieldTypeDescription
availablebooleanWhether a track is playing.
typestringThe type the URL carries: front or back for their cover_ spellings.
dataUrlstringThe fb2k://artwork/?path=... URL; not a data URL, only the component's WebView2 resource handler resolves it.
reason"no_track" | "not_found"Why there is no URL; only no_track occurs here.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const res = await fb2k.invoke('artwork.getFb2kUrl', {
	maxSize: 300,
});
if (res.success === false) throw new Error(res.error);
const { available, dataUrl } = res;

artwork.getFb2kUrlByPath ​

Build the fb2k://artwork/ URL for a path. Only a string is built: the file is not opened, so a path with no file behind it is still reported available.

ParameterTypeRequiredDescription
pathstringYesTrack path. Must not be empty.
type"front" | "cover_front" | "back" | "cover_back" | "disc" | "icon" | "artist"NoPicture type. Default: "front".
maxSizeintegerNoLongest side in pixels the handler scales the picture down to; omitted or 0 keeps the original size.

Returns

FieldTypeDescription
availablebooleanAlways true: the URL is built without opening the file.
typestringThe type the URL carries: front or back for their cover_ spellings.
pathstringThe path as given.
dataUrlstringThe fb2k://artwork/?path=... URL; not a data URL, only the component's WebView2 resource handler resolves it.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const res = await fb2k.invoke('artwork.getFb2kUrlByPath', {
	path: 'C:\\Music\\song.flac',
	maxSize: 300,
});
if (res.success === false) throw new Error(res.error);
const { available, dataUrl } = res;

artwork.getFb2kUrlByPathBatch ​

Build fb2k://artwork/ URLs for up to 100 entries given as exactly one of paths or items; giving both or neither fails with INVALID_PARAMS. Each row reports its own outcome, so a bad entry does not fail the call.

ParameterTypeRequiredDescription
pathsstring[]NoTrack paths; exactly one of paths and items.
itemsArtworkBatchItem[]NoEntries with their own type or scale limit; exactly one of paths and items.
items[].pathstringYesTrack path.
items[].type"front" | "cover_front" | "back" | "cover_back" | "disc" | "icon" | "artist"NoPicture type for this entry; the batch-wide type when omitted.
items[].maxSizeintegerNoScale limit for this entry; the batch-wide maxSize when omitted.
type"front" | "cover_front" | "back" | "cover_back" | "disc" | "icon" | "artist"NoPicture type for entries that do not name their own. Default: "front".
maxSizeintegerNoLongest side in pixels for entries that do not name their own; omitted or 0 keeps the original size.

Returns

FieldTypeDescription
artworksArtworkUrlRow[]One row per entry, in the given order.
artworks[].pathstringThe entry's path.
artworks[].availablebooleanWhether a URL was built.
artworks[].typestringThe type the URL carries.
artworks[].dataUrlstringThe fb2k://artwork/?path=... URL.
artworks[].errorstringWhy no URL was built, as the URL builder's error name such as invalid_type.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('artwork.getFb2kUrlByPathBatch', {
    paths: ['C:\\Music\\a.flac', 'C:\\Music\\b.flac'],
    type: 'front',
});
ScenariomaxSizeTypical size
Playlist thumbnail50–1002–5 KB
Sidebar card200–30010–20 KB
Main player cover400–60030–60 KB
Fullscreen / modal view1000+100–500 KB

Path Parameter Encoding

Pass the track path in the query string path parameter to prevent Chromium URL canonicalization from decoding %5C / %2F and corrupting Windows paths. The legacy format fb2k://artwork/{encodedPath}?type=... remains supported for backward compatibility.

artwork.getFolderImages ​

List the image files (.jpg, .jpeg, .png, .gif, .bmp, .webp) directly inside a directory. A directory that is missing, is a file or cannot be listed is not an error: it lists no images.

ParameterTypeRequiredDescription
directorystringYesDirectory to list. Must not be empty.

Returns

FieldTypeDescription
imagesArtworkFolderImage[]The image files, in directory order.
images[].namestringFile name.
images[].pathstringFull path.
images[].sizeintegerFile size in bytes.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const res = await fb2k.invoke('artwork.getFolderImages', {
	directory: 'C:\\Music\\Album',
});
if (res.success === false) throw new Error(res.error);
const { images } = res;

artwork.getForTrack ​

Read a picture through the album art manager, which also finds folder covers, and measure it. width and height are read from the PNG header and are 0 for other formats. A file-relative:// path is refused with INVALID_PATH. A file that is only in the cloud and not yet downloaded is not opened and has no picture.

ParameterTypeRequiredDescription
pathstringYesTrack path: native, file://, or with a |subsong:N suffix. Must not be empty.
type"front" | "cover_front" | "back" | "cover_back" | "disc" | "icon" | "artist"NoPicture type. Default: "front".

Returns

FieldTypeDescription
availablebooleanWhether a picture was found.
typestringThe requested type.
pathstringThe path as given.
mimeTypestringMIME type detected from the bytes.
widthintegerWidth in pixels from the PNG header; 0 for other formats.
heightintegerHeight in pixels from the PNG header; 0 for other formats.
sizeintegerPicture size in bytes.
dataUrlstringdata:<mime>;base64,... URL of the picture.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const res = await fb2k.invoke('artwork.getForTrack', {
	path: 'C:\\Music\\song.flac',
	type: 'back',
});
if (res.success === false) throw new Error(res.error);
const { available, dataUrl } = res;

Performance Recommendation

In list and grid views, pass maxSize (for example 200) to artwork.getFb2kUrl, artwork.getFb2kUrlByPath or artwork.getFb2kUrlByPathBatch so the host sends a scaled-down picture. The Data URL methods (artwork.getCurrent, artwork.getByPlaylistItem, artwork.getForTrack) do not accept maxSize and return the picture at its stored size.

width / height Limitation

width and height return actual dimensions only for PNG pictures. For JPEG, GIF, BMP, and WebP, they return 0.

Relative Path Constraint

If the track path uses the file-relative:// scheme, use artwork.getByPlaylistItem instead.

artwork.getLyrics ​

Read the lyrics tag of a track. The host's cached track info is used when complete; a local file it has not read is read from disk, and a remote or unrecognised path keeps whatever the cache has. The tags LYRICS, UNSYNCED LYRICS, UNSYNCEDLYRICS, SYNCEDLYRICS and SYNCED LYRICS are probed in that order and the first non-empty one wins. Without path the playing track is used; with nothing playing the call fails with NO_ACTIVE_ITEM. A path no track can be made for fails with NOT_FOUND, a local file that cannot be read with OPERATION_FAILED. Invalid UTF-8 in lyrics is replaced with U+FFFD without changing tags.

ParameterTypeRequiredDescription
pathstringNoTrack path; omitted for the playing track.

Returns

FieldTypeDescription
availablebooleanWhether a non-empty lyrics tag was found.
tagstringThe tag that supplied the lyrics.
lyricsstringThe lyrics text.
syncedbooleantrue when the tag name marks the lyrics as synced.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const res = await fb2k.invoke('artwork.getLyrics');
if (res.success === false) throw new Error(res.error);
const { available, lyrics } = res;

artwork.getMetadata ​

Read the album-level tags of a track, plus whether the file embeds any picture and whether it carries a lyrics tag. The tags come from the host's cached track info when complete; a local file it has not read is read from disk, and a remote or unrecognised path keeps whatever the cache has, which can be blank. Without path the playing track is used; with nothing playing the call fails with NO_ACTIVE_ITEM. A path no track can be made for fails with NOT_FOUND, a local file that cannot be read with OPERATION_FAILED. Invalid UTF-8 in returned tag values is replaced with U+FFFD without changing the file. A file that is only in the cloud and not yet downloaded is not opened for the picture check, so hasEmbedded is false.

ParameterTypeRequiredDescription
pathstringNoTrack path; omitted for the playing track.

Returns

FieldTypeDescription
availablebooleanAlways true: the track was resolved, whether or not any of its tags could be read.
albumstringALBUM tag; empty when absent.
artiststringARTIST values joined with , in tag order.
albumArtiststringALBUM ARTIST values joined with , in tag order.
titlestringTITLE tag; empty when absent.
yearstringDATE tag as written; empty when absent.
genrestringGENRE values joined with , in tag order.
trackNumberstringTRACKNUMBER tag as written, such as 3 or 3/12; empty when absent.
discNumberstringDISCNUMBER tag as written; empty when absent.
hasEmbeddedbooleanWhether the file embeds any of the five picture types.
hasLyricsbooleanWhether any of the five tags recognized by artwork.getLyrics exists, even an empty one.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

Multi-value tags in artist / albumArtist / genre / composer (only the fields this API actually returns) are joined with , in their original order, without de-duplication.

js
const res = await fb2k.invoke('artwork.getMetadata', {
	path: 'C:\\Music\\song.flac',
});
if (res.success === false) throw new Error(res.error);
const { title, album, hasEmbedded } = res;

Usage notes ​

  • Valid artwork type values are front (also cover_front), back (also cover_back), disc, icon, and artist. Omitted type means front; an unknown value returns INVALID_PARAMS.
  • artwork.getByPath and artwork.getForTrack accept native paths, file:// paths, and path|subsong:N. They reject file-relative:// because an extractor has no playlist context; use artwork.getByPlaylistItem for those items.
  • Direct artwork reads return a standard data:image/...;base64,... URL. artwork.getFb2kUrl and its path variants instead return a fb2k://artwork/ URL in the dataUrl field. Despite the field name, that value is not a Data URL or image bytes: it is resolved only by this component's WebView2 resource handler and is intended for immediate <img src> rendering. Do not persist it, pass it to file.write, or treat it as a system-wide URL. maxSize is applied only when it is greater than 0.
  • To save a direct-read Data URL with file.write, split it at the first comma, keep the Base64 payload after the comma, and write content: 'base64:' + payload with encoding: 'binary'. To pass the same artwork to metadata.embedArtwork, pass only the raw Base64 payload without the Data URL header and without the base64: marker.
  • artwork.getFb2kUrlByPathBatch requires exactly one array input named paths or items. Array entries may be strings or objects with a path member. It has no top-level path parameter. The result is { success, artworks }, with one available/error result for each supplied entry.
  • artwork.getAvailableArtwork reports embedded items and external source labels such as folder:cover.jpg. The implementation opens files through album_art_extractor; absence of artwork is represented by available: false, not necessarily an error.
  • artwork.getFolderImages reads a directory and returns matching .jpg, .jpeg, .png, .gif, .bmp, and .webp files. Its directory argument uses the MediaRead level, so a folder under a media-library watch folder is accepted even where Read would reject it.