The following shell command does the job:
convert "$content" \\ -resize "$size"\\! \\ -matte "$map.png" \\