Sensor size based on mesh bounds

Hello all,

Can someone help me understand how could i change the camera sensor size (both width and height) based on mesh bounding box? So that length of my mesh is a sensor width for example.

Preferably with blueprints.