#!/bin/sh size=512x512 convert "$1" -background white -flatten -alpha off -fx '(r+g+b)/3' -colorspace Gray -resize "$size" -gravity center -extent "$size" "$2"