The key to your problems is that percentage that you specify gives the point where the container and the image match. This point is calculated both in the image and in the container.
So, if you want the image centered, that means that the center of the image is in the center of the container. So, this is the value that you find by trial and error.
The key here is 50% as background-position always gets the image centered, and you don't need any of your calculations
If you specify 10% for the property, that would mean that the point at 10% from the left in the image is positioned at the point at 10% from the left in the container.
formula for this
How to convert from percentage to px (as requested). Lets say that you have a container o size n and the image is greater by a factor of f You specify a background position of x%. We take this as an unitary factor a being a=x*100
The position to match in the container is an. The position to match in the image is afn. The position of the image from the container is the difference, afn-an , that can be given as an(f-1).
That explains why:
The apparent result of the property is inverted when f > 1 . (the image is bigger than the container.
The result is nil when f = 1 (the image is the same size than the container)
Now to convert that to space percentage, you just divide by the size of the container (n) to give
a(f-1)
or divide by the size of the image (fn) to give
a(f-1)/f