Well the code I posted above should work for any background image that is a 4x3 aspect ratio, regardless of the size/ratio of your foobar panel. That's why the $get(bg) variable is based on the panel width and height, so it can change along with it. If you change bg images to something else, modify the ratio in the code and it should still work.
I haven't tried it, but I would like to know if it does what you want it to.
It doesn't seem to work :-(
But I have found a solution
$ifgreater(
$eval(%_width%*10),$eval(%_height%*16),
$imageabs2(%_width%,$eval(%_width%*10/16),0,0,,,0,0,skins/skin2/bg.png,),
$imageabs2($eval(%_height%*16/10),%_height%,0,0,,,0,0,skins/skin2/bg.png,)
)
The main problem I had came from my previous comparison that generated non-integer results
$eval(16/10),$eval(%_width%/%_height%)
As you said earlier, now I just need to add some pixels to remove black borders.