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
Net::GPSD3(3pm) 					User Contributed Perl Documentation					   Net::GPSD3(3pm)

NAME
Net::GPSD3 - Interface to the gpsd server daemon protocol versions 3 (JSON). SYNOPSIS
Watch Interface use Net::GPSD3; my $gpsd=Net::GPSD3->new; $gpsd->watch; One Liner perl -MNet::GPSD3 -e 'Net::GPSD3->new->watch' Poll Interface use Net::GPSD3; use Data::Dumper qw{Dumper}; my $gpsd=Net::GPSD3->new; my $poll=$gpsd->poll; print Dumper($poll); One Liner perl -MNet::GPSD3 -e 'printf "Protocol: %s ", Net::GPSD3->new->poll->parent->cache->VERSION->protocol;' Protocol: 3.4 POE Interface See Net::GPSD3::POE DESCRIPTION
Net::GPSD3 provides an object client interface to the gpsd server daemon utilizing the version 3 protocol. gpsd is an open source GPS daemon from http://gpsd.berlios.de/. Support for Version 3 of the protocol (JSON) was added to the daemon in version 2.90. If your daemon is before 2.90 (protocol 2.X), please use the Net::GPSD package. CONSTRUCTOR
new Returns a new Net::GPSD3 object. my $gpsd=Net::GPSD3->new; my $gpsd=Net::GPSD3->new(host=>"127.0.0.1", port=>2947); #defaults METHODS
host Sets or returns the current gpsd host. my $host=$obj->host; port Sets or returns the current gpsd TCP port. my $port=$obj->port; poll Sends a Poll request to the gpsd server and returns a Net::GPSD3::Return::POLL object. The method also populates the cache object with the Net::GPSD3::Return::VERISON and Net::GPSD3::Return::DEVICES objects. my $poll=$gpsd->poll; #isa Net::GPSD3::Return::POLL object Note: In order to use the poll method consistently you should run the GPSD daemon as a service. You may also need to run the daemon with the "-n" option. watch Calls all handlers that are registered in the handler method. $gpsd->watch; #will not return unless something goes wrong. addHandler Adds handlers to the handler list. $gpsd->addHandler(&myHandler); $gpsd->addHandler(&myHandler1, &myHandler2); A handler is a sub reference where the first argument is a Net::GPSD3::Return::* object. handlers List of handlers that are called in order to process objects from the gpsd wathcer stream. my @handler=$gpsd->handlers; #() my $handler=$gpsd->handlers; #[] cache Returns the Net::GPSD3::Cache caching object. METHODS Internal default_handler socket Returns the cached IO::Socket::INET6 object my $socket=$gpsd->socket; #try to reconnect on failure json Returns the cached JSON::XS object decode Returns a perl data structure given a JSON formated string. my %data=$gpsd->decode($string); #() my $data=$gpsd->decode($string); #{} encode Returns a JSON string from a perl data structure constructor Constructs a class object by lazy loading the classes. my $obj=$gpsd->constructor(%$data); my $obj=$gpsd->constructor(class=>"DEVICE", string=>'{...}', ...); Returns and object in the Net::GPSD3::Return::* namespace. BUGS
Log on RT and Send to gpsd-dev email list There are no two GPS devices that are alike. Each GPS device has a different GPSD signature as well. If your GPS device does not work out of the box with this package, please send me a log of your devices JSON sentences. echo '?POLL;' | nc 127.0.0.1 2947 echo '?WATCH={"enable":true,"json":true};' | socat -t10 stdin stdout | nc 127.0.0.1 2947 SUPPORT
DavisNetworks.com supports all Perl applications including this package. Try gpsd-dev email list AUTHOR
Michael R. Davis CPAN ID: MRDVT STOP, LLC domain=>michaelrdavis,tld=>com,account=>perl http://www.stopllc.com/ COPYRIGHT
This program is free software licensed under the... The BSD License The full text of the license can be found in the LICENSE file included with this module. SEE ALSO
Net::GPSD, Net::GPSD3::POE, GPS::Point, JSON::XS, IO::Socket::INET6, DateTime perl v5.14.2 2011-12-27 Net::GPSD3(3pm)
All times are GMT -4. The time now is 01:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy