#!/bin/bash
gm identify -format "%W %H" "$1" | while read width height
do
cols=$((width / 8))
rows=$((height / 8))
seq -f "$2" 0 $((cols*rows - 1))
done