If using flexbox is a valid option for you (don't need to suport old browsers), check my other answer here (which is possibly a duplicate of this one):
Basically you'd need to wrap your img tag in a div and your css would look like this:
.img__container {
display: flex;
padding: 15px 12px;
box-sizing: border-box;
width: 400px; height: 200px;
img {
margin: auto;
max-width: 100%;
max-height: 100%;
}
}