how do i/is there a way to auto scale a single dimension of an image set on a layer?
You would have to set the style: backgroundSize: "100px 50px"
so: l = new Layer backgroundColor: "rgba(255,255,255,0)" image: url width: 200 backgroundSize: "200px auto"
doesn't seem to work. it stil gives me 200.
what i'm trying to do is set an image in a layer, then have that layer dynamically resize based on the width i set, so that i can now adjust it's container accordingly. The image is determining the size of the layer and everything else surrounding it
(sorry indentation didn't pan out)
So you want like an intrinsic height based on the layer width. Assuming it's dynamic?
Maybe go the "scale" way, instead of setting dimensions individually?
I think you could load it into the dom and then measure it there before you actually render it?
I had to do this recently, I can share some code when I get back to my desk later today.
Sorry for the delay, with a newborn I haven't had a chance to sit down... :)
Trick is to listen for the ImageLoaded event on the layer, then just set height proportionally to the original image height. The original image is an argument that is passed to the ImageLoaded callback, so you can access it's native height/width to get the original aspect ratio.