Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-22T19:00:25.930Z
Answers.Text: Wow, thanks! So simple.
Answers.UserDisplayName: Picard102
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-22T11:33:09.903Z
Answers.LastActivityDate: 2021-06-22T11:33:09.903Z
Answers.UserDisplayName: Matt
Body: <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>
  
Tags: <after-effects-expressions>
Title: Expression to make image same height as shape
UserDisplayName: Picard102
ThreadText: # 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.  
  
  ---
  
  