Looks like there were a couple of slight issues with the solution posted:
length is an awk function and should be used as a variable name
image magic draw function requires text x,y 'string'
Adjusted script to correct these issues:
source=source.jpg
target=target.JPG
# get the image's size, width=$1, length=$2, you need adjust for your image,
# depand the output format of command identify
set -- $(identify $source |awk 'NR==1{split($3,a,"x"); print a[1],a[2]}')
cat jhead |grep "GPS " |awk -v width=$1 -v lngth=$2 -v sfile=$source -v tfile=$target '
NR==1{Latitude=$0}NR==2{Longitude=$2} NR==3{Altitude=$0}
END{
printf "convert -pointsize 18 -font times.ttf -fill white "
printf "-stroke black -strokewidth 1 "
printf "-draw \"text 10,%d %c%s%c\" ", lngth-72, 39, Latitude, 39
printf "-draw \"text 10,%d %c%s%c\" ", lngth-54, 39, Longitude, 39
printf "-draw \"text 10,%d %c%s%c\" ", lngth-36, 39, Altitude, 39
printf "%s %s\n", sfile, tfile }'
Other things to consider: the black stroke around the text looks really poor with my testing images and you may want to try without the stroke like (remove line is green above). I always like using a gamma adjust in a rectangle where the text is to go (say 0.2 gamma with white text), this tends to help the text stand out from the background.
You would need to play around with imagemagic to measure the size of the text and darken a rectangle where it is to go.
---------- Post updated at 03:35 PM ---------- Previous update was at 01:24 PM ----------
I've had a go at creating a dark plaque sized from the GPS text. This should get you going, but it could be tweaked more.
Your GPS text may always be a consistent width and you could just use a standard image for the plaque (just get rid of the maxwidth function and the convert command that created the black plauque.jpg images:
source=source.jpg
target=target.JPG
# get the image's size, width=$1, length=$2, you need adjust for your image,
# depand the output format of command identify
set -- $(identify $source |awk 'NR==1{split($3,a,"x"); print a[1],a[2]}')
I_WIDTH=$1
I_LENGTH=$2
function maxwidth()
{
MAX_WIDTH=0
while read line
do
INFO=$(convert -size 1025x768 xc:lightblue -font times.ttf -pointsize 18 -fill none -undercolor white -annotate +20+100 "$line" -trim info:)
WIDTH=${INFO##*XC }
WIDTH=${WIDTH%%x*}
[ $WIDTH -gt $MAX_WIDTH ] && MAX_WIDTH=$WIDTH
done
echo $MAX_WIDTH
}
MW=$(cat jhead | grep "GPS " | maxwidth)
let WIDTH=MW+10
HEIGHT=60
convert -size ${WIDTH}x${HEIGHT} xc:black plaque.jpg
composite plaque.jpg -geometry +5+$(( $I_LENGTH - $HEIGHT - 5 )) -dissolve 60 $source $target
CMD=$(cat jhead |grep "GPS " |awk -v width=$1 -v lngth=$2 -v tfile=$target '
NR==1{Latitude=$0}NR==2{Longitude=$0} NR==3{Altitude=$0}
END{
printf "convert -pointsize 18 -font times.ttf -fill white "
printf "-draw \"text 10,%d %c%s%c\" ", lngth-46, 39, Latitude, 39
printf "-draw \"text 10,%d %c%s%c\" ", lngth-28, 39, Longitude, 39
printf "-draw \"text 10,%d %c%s%c\" ", lngth-10, 39, Altitude, 39
printf "%s %s\n", tfile, tfile }')
eval $CMD
Here is a pretty light image (mainly white where the text is to appear) and I think it is still quite readable at 60%: