append images using a grid

Use the ImageMagick "montage" command, specifically the "-tile" option. See http://www.imagemagick.org/Usage/montage/ for details.