Sponsored Content
Full Discussion: print metadata to jpg
Top Forums Shell Programming and Scripting print metadata to jpg Post 302485630 by Chubler_XL on Wednesday 5th of January 2011 06:46:41 PM
Old 01-05-2011
If your going to process a few images it is worth removing the calls to awk and using bash arrays/string processing instead.

Here is a version that defines font and size at to so you can trial different fonts/point sizes:

Code:
#!/bin/bash
FONT=times.ttf
FONT_SIZE=18
 
# Get width or length from image info string
function getwl
{
  read WnL
  # Get 3rd word
  WnL=${WnL#* * }
  WnL=${WnL%% *}
  # Remove from + to end
  WnL=${WnL%%+*}
  # Width before 'x' Length after
  [ $1 = 'L' ] && echo ${WnL#*x}
  [ $1 = 'W' ] && echo ${WnL%x*}
}
 
function process_image
{
    source=$1
    target=${1%.jpg}GPS.jpg
 
    I_HEIGHT=$(identify $source | getwl L)
 
    # Fetch GPS info into array
    IFS="
    " GPS=( $(jhead $source | grep "GPS ") )
 
    MW=0
    for line in "${GPS[0]}" "${GPS[1]}" "${GPS[2]}"
    do
        WIDTH=$(convert -size 1025x768 xc:lightblue -font $FONT \
            -pointsize $FONT_SIZE -fill none -undercolor white \
            -annotate +20+100 "$line" -trim info: | getwl W)
        [ $WIDTH -gt $MW ] && MW=$WIDTH
    done
 
    let WIDTH=MW+10
    let P_HEIGHT=FONT_HEIGHT*3+6
 
    convert -size ${WIDTH}x${P_HEIGHT} xc:black plaque.jpg
    composite plaque.jpg -geometry +5+$(( $I_HEIGHT - $P_HEIGHT - 5 )) \
         -dissolve 60 $source $target
 
    convert -pointsize $FONT_SIZE -font $FONT -fill white \
        -draw "text 10,$((I_HEIGHT - FONT_HEIGHT*7/3 - 8)) \"${GPS[0]}\"" \
        -draw "text 10,$((I_HEIGHT - FONT_HEIGHT*4/3 - 8)) \"${GPS[1]}\"" \
        -draw "text 10,$((I_HEIGHT - FONT_HEIGHT*1/3 - 8)) \"${GPS[2]}\"" \
        $target $target
}
 
FONT_HEIGHT=$(convert -size 1025x768 xc:lightblue -font $FONT \
            -pointsize $FONT_SIZE -fill none -undercolor white \
            -annotate +20+100 "Testing" -trim info: | getwl L)
 
for file in $@
do
   process_image $file
done

This User Gave Thanks to Chubler_XL For This Post:
 

5 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Print the content of a directory in jpg file

Is there any possible way to print the contents of a directory to a .jpg file? I have a list of thumbnails (e-books) which I want to share (+500) but I don't know how to make this. I would appreciate a lot any comments regarding this issue. (4 Replies)
Discussion started by: agasamapetilon
4 Replies

2. Programming

Best way to dump metadata to file: when and by who?

Hi, my application (actually library) indexes a file of many GB producing tables (arrays of offset and length of the data indexed) for later reuse. The tables produced are pretty big too, so big that I ran out of memory in my process (3GB limit), when indexing more than 8GB of file or so.... (9 Replies)
Discussion started by: emitrax
9 Replies

3. Shell Programming and Scripting

Rename all ".JPG" files to ".jpg" under all subfolders...

Hi, Dear all: One question ! ^_^ I'm using bash under Ubuntu 9.10. My question is not to rename all ".JPG" files to ".jpg" in a single folder, but to rename all ".JPG" files to ".jpg" in all subfolders. To rename all ".JPG" to ".jpg" in a single folder, for x in *.JPG; do mv "$x"... (7 Replies)
Discussion started by: jiapei100
7 Replies

4. UNIX for Advanced & Expert Users

LVM - restore metadata on other disk

Hi guys, I would like to ask your opinion about my theory, how to fix my broken LVM without risking any data loss. I use Archlinux at home. I just love this distro, even it gives me a lots of work (particularly after system updates). Basic system spec: AMD FX(tm)-6100 Six-Core Processor... (1 Reply)
Discussion started by: lyynxxx
1 Replies

5. UNIX and Linux Applications

About gvfsd-metadata

I need a hint about gvfsd-metadata using mate on bsd. Or dual-core cpu, quad-core cpu ore an old laptop single core, the gvfsd is an obstacle and does not accelerate anything, vice versa, it slows down many processes, coming from gnome. So someone can give me a hint how to wipe it out for good? I... (1 Reply)
Discussion started by: 1in10
1 Replies
GPSCAT(1)							GPSD Documentation							 GPSCAT(1)

NAME
gpscat - dump the output from a GPS SYNOPSIS
gpscat [-s speed] [-p] [-t] [-D debuglevel] serial-port DESCRIPTION
gpscat is a simple program for logging and packetizing GPS data streams. It takes input from a specified file or serial device (presumed to have a GPS attached) and reports to standard output. The program runs until end of input or it is interrupted by ^C or other means. It does not terminate on a bad backet; this is intentional. In raw mode (the default) gpscat simply dumps its input to standard output. Nonprintable characters other than ASCII whitespace are rendered as hexadecimal string escapes. In packetizing mode, gpscat uses the same code as gpsd(8)'s packet sniffer to break the input into packets. Packets are reported one per line; line breaks in the packets themselves are escaped. This program is useful as a sanity checker when examining a new device. It can be used as a primitive NMEA logger, but beware that (a) interrupting it likely to cut off output in mid-sentence, and (b) to avoid displaying incomplete NMEA sentences right up next to shell prompts that often contain a $, raw mode always emits an extra final linefeed. Also, be aware that packetizing mode will produce useless results -- probably consuming the entirety of input and appearing to hang -- if it is fed data that is not a sequence of packets of one of the known types. The program accepts the following options: -p Invoke packetizer mode. -s Set the port's baud rate (and optionally its parity and stop bits) before reading. Argument should begin with one of the normal integer baud rates (300, 1200, 4800, 9600, 19200, 38400, etc.). It may be followed by an optional suffix [NOE][12] to set parity (None, Even, Odd) and stop bits (1 or 2). -t Invoke packetizer mode, with the packet type and length (in parentheses) reported before a colon and space on each line. -D In packetizer mode, enable progress messages from the packet getter. Probably only of interest to developers testing packet getter changes. -h Display program usage and exit. Specifying -s 4800N1 is frequently helpful with unknown devices. SEE ALSO
gpsd(8), gps(1), libgps(3), libgpsd(3), gpsfake(1). gpsprof(1), gpsctl(1), gpsdctl(8), gpsmon(1). AUTHOR
Eric S. Raymond esr@thyrsus.com. The GPSD Project 16 Nov 2006 GPSCAT(1)
All times are GMT -4. The time now is 11:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy