Code to generate thumbnails with ImageMagick