// This script is for Directory Opus 11.5.5 or higher // CoverArtDim column (CoverArt WxH) // Uses AudioCoverArt's new width and height properties. // Shows dimensions for a folder if it contains defined files. var vAllowedFolderImages=null; function ImageSize(itm){ if (itm){ var metatype=""+itm.Metadata; //Make sure we get a string. Without "" we get a object. if ((metatype=="audio")&&(itm.Metadata.audio.coverart>0)){ var cnt=itm.Metadata.audio.coverart; var curitm; if(cnt>1){ var enm=[]; var pos=0; var selwidth=0; var selheight=0; var enu = new Enumerator(itm.Metadata.audio.coverart); if (!enu.atEnd()){ while (!enu.atEnd()){ curitm=enu.item(); enm[pos++]={width:curitm.width,height:curitm.height}; enu.moveNext(); } } for (var i=0;i(selheight*selwidth))){ selwidth=enm[i].width; selheight=enm[i].height; } } // If width and height is both 0/undefined then we don't have a supported coverart if ((!selwidth)&&(!selheight)) return null; return {width:selwidth,height:selheight,all:enm}; } else{ curitm=itm.Metadata.audio.coverart(0); // If width and height is both 0/undefined then we don't have a supported coverart if ((!curitm.width)&&(!curitm.height)) return null; return {width:curitm.width,height:curitm.height,all:null}; } } else if (metatype=="image"){ return {width:itm.Metadata.image.picwidth,height:itm.Metadata.image.picheight,all:null}; } } return null; } // Called by Directory Opus to initialize the script function OnInit(initData){ initData.name = "ColCoverArtDimensions2"; initData.desc = "Add a column to show the dimensions of coverart or image"; initData.copyright = "myarmor"; initData.min_version="11.5.5"; initData.version = "1.03"; initData.default_enable = false; var col; col = initData.AddColumn(); col.name = "CoverArtDim"; col.method = "OnCoverArtDim"; col.label = "CoverArt WxH"; col.autogroup = true; col.autorefresh=true; col.justify = "right"; initData.config.allowedFolderImages=DOpus.NewVector('cover.jpg','folder.jpg'); return false; } function AllowItem(item){ if (!vAllowedFolderImages) return false; var len; len=vAllowedFolderImages.count; if (len==0) return false; for (var i=0;i