What is standard about 4:3? I don't get this step of the algorithm at all.  I could see if you compared scaled.width to container.width and found that the scaled preview would not fill the height of the screen, then you'd need to center it.  But this ratio comparison just does not make sense to me.