With ImageMagick I can use the command below to replace a transparent background of an image with a pattern. It seems to work perfectly even with semi-transparent pixels.
composite -compose Dst_Over -tile pattern:checkerboard 'src_file_with_transparent_background.png' 'output_file.jpg'
Is there a way to do the same with GraphicsMagick?
Here is the solution:
gm montage -texture pattern:checkerboard -mode Concatenate input.png output.jpg
Many thanks to the GraphicsMagick maintainer Bob Friesenhahn for his help resolving this problem! You can find his original answer in this thread: https://sourceforge.net/p/graphicsmagick/discussion/250738/thread/9d43ab46/