Unix Archives - Stationary Journey https://stationaryjourney.com/category/unix One step forward, one step back Thu, 04 Feb 2016 18:53:29 +0000 en-US hourly 1 https://wordpress.org/?v=6.7.1 https://i0.wp.com/stationaryjourney.com/wp-content/uploads/2015/01/greyscale-512-54a826c8v1_site_icon.png?fit=32%2C32&ssl=1 Unix Archives - Stationary Journey https://stationaryjourney.com/category/unix 32 32 64970933 Timestamping Images https://stationaryjourney.com/timestamping-images?utm_source=rss&utm_medium=rss&utm_campaign=timestamping-images https://stationaryjourney.com/timestamping-images#comments Mon, 28 Sep 2015 15:15:23 +0100 http://stationaryjourney.com/?p=13234

Timestamping images

The post Timestamping Images appeared first on Stationary Journey.

]]>

ts_21618218772_585c36f004_o

I recently had the need to timestamp/datestamp a large number of image files using the EXIF data stored in the files. A shell script under Linux was my preferred choice for this, but I’ve always found shell scripting to be cryptic and ImageMagick difficult to master due to the range of tools and command line options. After some searching I came across some useful advice which I adapted for my own needs. The changes I made were to ensure the date followed the UK format, tailoring the colour and size of the stamp to my preferences, as well as providing more useful feedback on progress.

The results are here in case anyone else finds them useful. I haven’t attempted to break long lines in case that introduced errors.

#! /bin/bash

# Based on code here: http://superuser.com/questions/649033/add-timestamp-to-image-from-linux-command-line
# Stored as ~/scripts/stamp.sh, included in path with the following added to .profile:
# PATH=$PATH:"$HOME/scripts"
# Made executable with:
# chmod +x ~/scripts/stamp.sh
# Uncomment the next command for more verbose feedback
# set -x

textcolor="rgb(43,255,0)"
ext="*jpg"

count=$(ls -1 $ext | wc -l)
echo "$count files to be processed"

for img in $ext;
   do stamp=($(identify -format %[EXIF:DateTime] $img))
      full="${stamp[0]:8:2}/${stamp[0]:5:2}/${stamp[0]:0:4} ${stamp[1]}"
      convert "$img" -gravity SouthEast -pointsize 84  -fill $textcolor -weight bold -stroke black -strokewidth 3 -annotate +30+30 "$full" "ts_""$img"
      ((count -= 1))
      echo "Image $img processed, $count remaining"
done

echo "Finished!"

The post Timestamping Images appeared first on Stationary Journey.

]]>
https://stationaryjourney.com/timestamping-images/feed 1 13234