here you go:
if you are dealing with lots of pics ImageMagick is probably a way to go for you.
run something like that for every image(using shell script, shell_exec() from php script or whatever u have):
all decent servers have imagemagick installed so u shouldn't have problems with that
convert input_pic.jpg -resize 100x100 -size 100x100 xc:white +swap -gravity center -composite output_pic.jpg
it will resize your input_pic.jpg so that it will fit inside 100px x 100px white area and save it as output_pic.jpg