With CSS you can:
CSS:
<!doctype html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<title>Exemplo pt.stackoverflow - Pergunta 10483</title>
<style>
.quadroImagem {
display:inline-block;
margin: 0;
padding: 0;
width: 200px;
height: 200px;
text-align: center;
background-color: #FFF;
border: 1px solid #999;
line-height: 196px;
}
.quadroImagem img {
max-height: 200px;
max-width: 200px;
vertical-align:middle;
}
</style>
</head>
<body>
<div class="quadroImagem">
<img src="minha_imagem.jpg" />
</div>
</body>
</html>
Remembering that when changing the default size (in the example, 200px) the line-height value should always be 4px smaller, ie:
For 400x400, line-height: 396px;
For 100x100, line-height: 96px;
Line-height is used to allow vertical centering indicated in the image itself with vertical-align: middle;
Test and see. Use rectangular square images (with height greater than width and vice versa).