Drawing a 20x20 pixel greyscale image

I'm currently trying to write a program that takes a user-inputted 20x20 pixel greyscale image of a digit and predicts what number the user drew. Here is a sample image of what a typical user input would be:

sample image

How can I ask the user to draw such an image?


Maybe shell out to ImageMagick to create a 400x400 greyscale image:

convert -size 400x400 xc:gray image.bmp

and then start MS Paint (Windows) or GIMP (Linux/macOS) to edit the image. Then, when the user exits, resize the image to 20x20 and save as a PGM which is dead easy to read and necessarily greyscale:

convert image.bmp -resize 20x20 result.pgm