So I was experimenting around with this component and came across some odd behavior and thought I'd blog about it in case anyone was trying something similar. My goal was to take a piece of cover art, use $getimagewidth()/$getimageheight() to calculate the aspect ratio of the album art, then use that to decide what to draw behind the image. The intended effect would be a stylized now-playing display that would adjust CD images based on singles, full albums, etc.
$puts(album.art,$replace(%path%,%filename_ext%,$if2(%catalognumber%,%album artist% - %album%).jpg))
$puts(album.width,$getimagewidth($get(album.art)))
$puts(album.height,$getimageheight($get(album.art)))
$puts(album.aspect,$div($get(album.width),$get(album.height)))
The oddness I encountered is that there appears to be a delay when running $getimagewidth()/$getimageheight(). If I use the above code in a PerTrack tab: $get(album.art) displays the path to the album cover as expected but $get(album.width) & $get(album.height) come up empty while $get(album.aspect) comes up as 0 (empty divided by empty equals zero).
If I use the above code in a PerSecond tab: $get album.art displays the path to the album cover as expected but the rest of the variables only resolve properly after approximately a 1 second delay.
If I change to a previous track all variables act as expected I am guessing because of some sort of cached results but if I skip forward they only work PerSecond and only after about a 1 second delay. The result is the different background images are drawn approx 1 second after the album art is drawn.