Search code examples
command-lineimagemagickstroke

Imagemagick not adding stroke to 'label' operator


I have the following code that is working well, however I would like to add a stroke/border to the label text to make it stand out more. I have tried putting my label stroke code in various places in the command line with no luck. Any ideas?

<?PHP

    $upload = "img.jpg";
    $upload = "../images_aircraft/48078a83.jpg";
    $overlay_logo = "xaviators_overlay.png";
    $caption = strtoupper("1982 KING AIR B200");
    $caption2 = strtoupper("$13,450,500");

    exec("convert {$upload} -strip -thumbnail 700x700^ -gravity north -extent 700x700 -bordercolor black -border 20 \
    \( -size 680x150 -font Exo2-Bold -strokewidth 5 -stroke black -background none -fill white label:'{$caption}' -trim -gravity north -extent 680x150 \) -gravity northwest -geometry +20+40 -composite \
    \( -size 600x130  -font Exo2-Black -background none -fill white -strokewidth 20 -stroke black label:'{$caption2}' -trim -gravity west -extent 600x130 \) -gravity southwest -geometry +30-0 -composite \
    {$overlay_logo} -gravity southeast -geometry +30+30 -composite out.jpg");

?>

<img src="out.jpg" />

Current Output: enter image description here


Solution

  • It works fine for me on IM 6.9.13.16 on Mac OSX Ventura. What is your IM version and platform? I also note that your stroke width of 20 is too large and makes the text totally black. I reduced it to 5 below. I did not have your logo, so I removed that part of the code.

    Input:

    enter image description here

    caption="1982 KING AIR B200"
    caption2="$13,450,500"
    upload="lena.png"
    convert {$upload} -strip -thumbnail 700x700^ -gravity north -extent 700x700 -bordercolor black -border 20 \
    \( -size 680x150 -font /Users/fred/fonts/Exo2-Bold.otf -strokewidth 5 -stroke black -background none -fill white label:"$caption" -trim -gravity north -extent 680x150 \) -gravity northwest -geometry +20+40 -composite \
    \( -size 600x130 -font /Users/fred/fonts/Exo2-Black.otf -background none -fill white -strokewidth 5 -stroke black label:"$caption2" -trim -gravity west -extent 600x130 \) -gravity southwest -geometry +30-0 -composite \
    out.jpg
    

    enter image description here