Proper realignment of rotate images

The CSS rotation of images made them be misaligned. I fixed that for most pictures by adding special margin styling, but it didn't work too work for "non-standard" image width/height ratios. Now I compute the margin and apply it after loading the image.