<p>I assume &quot;Kyron BG&quot; is the shape layer and thisLayer is the image layer and you're applying the expression on the scaling of the image layer. Then this should work:</p>
<pre><code>kyronnb = thisComp.layer(&quot;Kyron BG&quot;).sourceRectAtTime();
scaleFactor = kyronnb.height/thisLayer.height*100;
[scaleFactor, scaleFactor]
</code></pre>

CC BY-SA 4.0
2021-06-22T19:00:25.930Z
Wow, thanks! So simple.
Picard102
CC BY-SA 4.0
2021-06-22T11:33:09.903Z
2021-06-22T11:33:09.903Z
Matt
<p>I have a shape that varies in height, and an image that varies in height.</p>
<p>I would like the image height to be the same height as the shape at all times.</p>
<p>I got as far as this, but none of my math seems to be making the image the same height as the bar constantly.</p>
<pre><code>kyronnb = thisComp.layer(&quot;Kyron BG&quot;).sourceRectAtTime();

syz = 100 * thisLayer.height/thisComp.height - 100; 
kper = 100 * kyronnb.height/thisComp.height;

sizeW = kper - syz;

[sizeW, sizeW]
</code></pre>

<after-effects-expressions>
Expression to make image same height as shape
Picard102
# Expression to make image same height as shape

(Asked by: username_0 on 2021-06-22)

I have a shape that varies in height, and an image that varies in height.
I would like the image height to be the same height as the shape at all times.
I got as far as this, but none of my math seems to be making the image the same height as the bar constantly.
kyronnb = thisComp.layer("Kyron BG").sourceRectAtTime();

syz = 100 * thisLayer.height/thisComp.height - 100; 
kper = 100 * kyronnb.height/thisComp.height;

sizeW = kper - syz;

[sizeW, sizeW]

**Tags:** after-effects-expressions


---

## 1 answers

### Answer by username_1 on 2021-06-22. Score: 1 | Accepted answer

I assume "Kyron BG" is the shape layer and thisLayer is the image layer and you're applying the expression on the scaling of the image layer. Then this should work:
kyronnb = thisComp.layer("Kyron BG").sourceRectAtTime();
scaleFactor = kyronnb.height/thisLayer.height*100;
[scaleFactor, scaleFactor]

> **Comments:**
> **username_0**: Wow, thanks! So simple.  

---

