Search code examples
imagemagickpango

How to use pango in script with imagemagick


Here is a simplified version of the code I'm currently using :

cat $FILES | while read line; do
     convert -fill $FG_COLOR -background $BG_COLOR \
         -size ${line_width}x${line_height} -page +${x_margin}+${y} \
         label:"${varL} and ${varR}" miff:-
done | convert -size ${SCREEN_W}x${SCREEN_H} xc:$BG_COLOR - -flatten image.jpg

And it is working well !

But I wish to have different colors for ${varL} and ${varR}, and I guess I should use pango instead of label. Am I correct about that ?

But by keeping the same code and just replacing label by pango I have an unexpected error :

convert-im6.q16: width or height exceeds limit

Solution

  • I am very confused about how I was able to solve this.

    Anyway here is the thing : I don't know why but pango needs to be BEFORE the other arguments.

    convert -fill $FG_COLOR -background $BG_COLOR \
             -size ${line_width}x${line_height} -page +${x_margin}+${y} \
             pango:"${varL} and ${varR}" miff:-
    

    Isn't working, but :

    convert pango:"${varL} and ${varR}" \
             -fill $FG_COLOR -background $BG_COLOR \
             -size ${line_width}x${line_height} -page +${x_margin}+${y} miff:-
    

    Is working !

    EDIT: pango: need to be before -page