I am trying to create multiple (two or more) small images with different texts/fonts/sizes and then overlay them over a single source image on different positions in a single step (without creating temporary named files by myself).
This is what I tried so far:
Create a single text and merge it on a position using a pipe and a miff stream (works, but I need multiple images):
gm convert \ -background transparent \ -fill black \ -font Calibri \ -size 300x100 \ -pointsize 36 \ -gravity SouthEast \ label:'large text' \ miff:- \ | gm composite -geometry +10+10 miff:- source.tif out.tif
Create and merge first image, store output temp file, load temp file and merge it to source (works, but two calls to
gm
needed, temp file must be written and must be deleted manually):gm convert \ -background transparent \ -fill black \ -font Calibri \ -size 300x100 \ -pointsize 36 \ -gravity SouthEast \ label:'large text' \ miff:- \ | gm composite -geometry +10+10 miff:- source.tif tmp.tif ; \ gm convert \ -background transparent \ -fill grey \ -font Calibri \ -size 200x50 \ -pointsize 12 \ -gravity SouthEast \ label:'small text' \ miff:- \ | gm composite -geometry +300+100 miff:- tmp.tif out.tif
Create multiple texts and merge them onto a position, where only the last position is counted and applied to all files (does not work, only first text is overlaid):
{ gm convert \ -background transparent \ -fill black \ -font Calibri \ -size 300x100 \ -pointsize 36 \ -gravity SouthEast \ label:'large text' \ miff:- ; \ gm convert \ -background transparent \ -fill grey \ -font Calibri \ -size 200x50 \ -pointsize 12 \ -gravity SouthEast \ label:'small text' \ miff:- ; } \ | gm composite miff:- -geometry +10+10 miff:- -geometry +300+100 source.tif -geometry +0+0 out.tif
Use
( ... )
syntax, replacing "text1.tif" and "text2.tif" with thegm convert
commands in braces (did not work in any cases, maybe I am using it wrong?)- Use
flatten
instead ofcomposite
(did work, but all files where placed on the same position rather than on different ones, also would destroy multi-page images) - Use
append
with multiple files through a single pipe (I need them overlaid, not side by side)
Is it possible to combine three or more images over each other, so that each image has a different position on the output image, without resorting to saving and loading temp files? Alternatively, how can I set the z-order of overlaid images before writing them? If possible on gm 1.3.25
and bash 4.3
, but I am open to alternatives that work.