Scaling an image to fit n pixels

I thought this was going to be easy, and hopefully for someone it is, but I’m having a tough time so thought I’d ask here…

I have an image - say 50 x 30 - 1500 pixels.

I need to scale it so that it keeps it proportion, and takes n pixels - say 20 for example.