Hello everyone. If you ever been updating templates created by others, or edited-in your own projects with new media assets, most likely at some point you been hitting head into a wall. Tediousness of adjusting variously sized assets to fit or fill the placeholder is always there, always boring. In this tutorial, I will cover how to achieve it effort free with expressions - every new update won't make you anxious anymore.
This technique enables to dynamically scale layers placement in the composition based on content size. This is super helpful if you want to update data in the project with an ease. Change content in the project dynamically without any manual work involved and increase your workflow's efficiency.
If you are interested to hear more from me about After Effects, just feel free to signup for a future updates at my website and subscribe to the channel on Youtube. My promise is to go into more advanced approaches in the long run.
Thanks for your time, and hope to see you around
Expression to Scale to FIT Your image inside the Composition
compW = thisComp.width;
compH = thisComp.height;
layerW = thisLayer.width;
layerH = thisLayer.height;
ratioW = compW / layerW;
ratioH = compH / layerH;
scaleVal = 100;
layerWUpdated = layerW * ratioH;
if(layerWUpdated > compW){
scaleNew = scaleVal * ratioW;
} else{
scaleNew = scaleVal * ratioH;
}
[scaleNew,scaleNew]
Expression to Scale to FILL Your image inside the Composition
compW = thisComp.width;
compH = thisComp.height;
layerW = thisLayer.width;
layerH = thisLayer.height;
ratioW = compW / layerW;
ratioH = compH / layerH;
scaleVal = 100;
layerWUpdated = layerW * ratioH;
if(layerWUpdated > compW){
scaleNew = scaleVal * ratioH;
} else{
scaleNew = scaleVal * ratioW;
}
[scaleNew,scaleNew]