Cover Art Dimensions Column

About:
This script adds a Cover Art Dimensions column to Directory Opus (Yep ... another one :slight_smile: ). The column is configurable and allows toggling of the bit depth, image type, file size and what it shows for files/directories without cover art.

Why:
This was created to learn more about Opus scripting and because I have gained so much from the many scripts already posted on the forums I figured that someone might find either the resulting column or the script useful.

Installation:

  • Download: Cover Art Dimensions 1.5.js.txt (3.6 KB)
  • Drag the .js.txt file to Preferences / Toolbars / Scripts.
  • Add the "Script > Cover Art Dimensions" column to your file display.

Configuration:
There are four options:

  1. Bit Depth: Include the bit depth information in the column.
  2. Image Type: Include the image type in the column.
  3. Image Size: Include the image size in the column.
  4. Directories: Enter a string to be used for directories (can be blank).
  5. Files: Enter a string to be used for files without cover art (can be blank).

History

  • 1.0
    • Initial Release
  • 1.1
    • Config options for folders and files without cover art are now editable strings.
    • Cleaner script logic for building each column entry based on config settings.
  • 1.5.
    • Changed from displaying just the image extension to the image type.
    • Included an 'about' dialog just to see how it worked.
    • Added the option to include the cover art image size in the column.

Script Code:

// Cover Art Dimensions
// (c) 2020 Steve Banham

scriptName = "Cover Art Dimensions Column";
scriptVersion = "1.5";
scriptDate = "22/03/2020";
scriptCopyright = "(c) 2020 Steve Banham";
scriptMinVersion = "12";
scriptURL = "https://resource.dopus.com/t/cover-art-dimensions-column";
scriptDesc = "Adds a new column displaying the dimensions of the cover art in a music file.";

// This is a script for Directory Opus.
// See https://www.gpsoft.com.au/DScripts/redirect.asp?page=scripts for development information.

// Called by Directory Opus to initialize the script
function OnInit(initData)
{
	initData.name = scriptName;
	initData.version = scriptVersion;
	initData.copyright = scriptCopyright;
	initData.url = scriptURL;
	initData.desc = scriptDesc;
	initData.default_enable = true;
	initData.min_version = scriptMinVersion;
	
	initData.config_desc = DOpus.Create.Map();
	initData.config_groups = DOpus.Create.Map();
	var configName = "";
	
	configName = "Directories";
	initData.Config[configName] = "<dir>";
	initData.config_desc(configName) = "String to show for directories (Can be blank).";
	initData.config_groups(configName) = "No Cover Art";
	
	configName = "Files";
	initData.Config[configName] = "---";
	initData.config_desc(configName) = "String to show for files without cover art (Can be blank).";
	initData.config_groups(configName) = "No Cover Art";
	
	configName = "Bit Depth";
	initData.Config[configName] = true;
	initData.config_desc(configName) = "Include bit depth in column.";
	initData.config_groups(configName) = "Include In Column";
	
	configName = "Image Type";
	initData.Config[configName] = true;
	initData.config_desc(configName) = "Include the image type in the column.";
	initData.config_groups(configName) = "Include In Column";

	configName = "Image Size";
	initData.config[configName] = true;
    initData.config_desc(configName) = "Include the image size in the column.";
    initData.config_groups(configName) = "Include In Column";
	
	var col = initData.AddColumn();
	
    col.name = "CoverArtDim";
    col.method = "OnCoverArtDim";
    col.label = "Cover Art Dimensions";
	col.header = "Cover Art Dimensions";
    col.autogroup = true; 
    col.autorefresh = true;
    col.justify = "left";
    col.match.push_back("Yes");
}

function OnCoverArtDim(scriptColData) {
	
	if (scriptColData.item.is_dir) {
		scriptColData.value = Script.Config["Directories"];
		return;
	}
	
	if (scriptColData.item.metadata() == "audio" && scriptColData.item.metadata.audio.coverart > 0) {	
		var caExt = scriptColData.item.metadata.audio.coverart(0).ext;
		var caSize = scriptColData.item.metadata.audio.coverart(0).size;
		
		if(caExt == ".jpg"){
			caExt = "JPEG Image";
		}
		else {
			caExt = "PNG Image";
		}

		var colData = scriptColData.item.metadata.audio.coverart(0).width + " x " + scriptColData.item.metadata.audio.coverart(0).height;
		
		if (Script.Config["Bit Depth"] == true) {
			colData = colData + " x " + scriptColData.item.metadata.audio.coverart(0).depth;
		}
        
        if (Script.Config["Image Size"] == true) {
            colData = colData + " (" + caSize.fmt() + ")";
        }

		if (Script.Config["Image Type"] == true) {
			colData = colData + " " + caExt;
        }
		
		scriptColData.value = colData;
	}
	else {
		scriptColData.value = Script.Config["Files"];
	}
}

function OnAboutScript(aboutData)
{
	dlg = DOpus.Dlg;
	dlg.window = aboutData.window;
	dlg.title = scriptName;
	dlg.message = scriptName + " v" + scriptVersion + "\t\t" + scriptDate+  "\n\n" + scriptDesc + "\n\n" + scriptCopyright;
	dlg.buttons = "Close";
	dlg.icon = "info";
	dlg.show;
}
4 Likes

Hi Steve Thanks for the script. I have Install your script but nothing has show in my file display. I do not change anything in your script. every settings in default position. What should I do?

Go to the pub for a drink? :grin:

Thanks for the nice reply

I don’t know what else to suggest. As Leo said in the other post - try creating a sample flac that has the problem so others can recreate your problems.