To resize an image and adjust it to fit a fixed canvas with transparent background:
$ convert in.png \ -resize 128x128 \ -background none \ -gravity center \ -extent 128x128 \ out.png