How would I go about resizing the size of a frame based on the size of an object inside of a viewportframe?

I recently was playing a game called Bad Business and I noticed how there was a weapon display frame that displayed a weapon in what I think was a viewportframe. The size of the object in the viewportframe changed the size of its background accordingly. I was wondering how I can achieve something similar to this.

GIF of weapon display frame in Bad Business: https://gyazo.com/b96e971ae100e60d724cf4fce9582e34

I think that’s actually measuring the size of the weapon, and converting that to pixels.

I think you can actually use methods on the Camera for that viewport frame to figure out pixel dimensions: