rewrite gm imagemagic