Posts Tagged GNU/Linux

Renaming photos to give attribution

At ASA Convention, a number of us took many photographs.  Late on the last night, I helped compile the highlights into a souvenir data DVD.  Using the nifty little exiv2 utility, I was able to adjust the image timestamps and retrospectively synchronise the clocks in every camera.  This makes for very enjoyable photo browsing, as you can view chronologically regardless of which camera was used.

Unfortunately I was too rushed to place attribution in the filenames, and so it is not obvious who took each photo.  Luckily we all used different camera models, and that information is still present in the exif metadata.  I used this to split the photos into directories and embed the photographer in both metadata and filename.

I was shooting on my Nikon D200, and so was able to separate my photos by:

for ii in *.jpg; do if grep -q "NIKON D200" $ii ; then mv $ii lachlan/ ; fi ; done

This says: for each jpg file, check if it contains “NIKON D200″ in the exif metadata and if it does then move it to the subdirectory lachlan/

All you need to do is find the camera model string to search for (my friends with Canons had things like “Canon EOS 30D”).  Now I’m going to append photographer names to the filenames, and then return them to their original chronological directories.

[For Facebook Notes readers: this post is redirected from my personal website lachlan.rogers.name]

Tags: ,

Producing handout with LaTeX Beamer

I jotted this down a year ago when I needed to produce a set of handout notes for a 3rd year physics lecture I took. Just last week, after taking a similar set of lectures, I wanted to find it but couldn’t. Murphy’s Law has come into effect, and my jotted note has turned up now that my need for it has passed.

The Beamer class for LaTeX is a great way to produce very nice presentation slides with useful features such as automatic progress markers and internal hyperlinks. Being LaTeX, it is also possible to completely change the output formatting by simply altering certain document settings. This allows me to produce slides that have black backgrounds for better projection onto a screen, and then change a single line (specifying the colour theme) to get a white-background version optimised for printing on paper.

To make it even more efficient to print, I used the following command to fit 3 slides to an A4 page:

pdfnup --frame false --nup 1x3 --paper a4paper --orient auto --pages all --trim "0 0 0 0" --delta "1cm 1cm" --offset "0 0" --scale 0.91 --turn true --noautoscale false --openright false --column false --columnstrict false --tidy true --outfile main3up.pdf main.pdf

Tags: , ,

Converting video files for playback on Android Google Phone

A few months ago I purchased a “Google Phone”: a HTC Magic running the Linux-based Android operating system. I am incredibly pleased with this device.

Today I wanted to convert some video that I recorded on a Nikon Coolpix camera into a format that would play nicely on my Android phone. The resolution needed to be scaled down for the small screen, and I knew that h264 was the best video codec. After some searching online, and a bit of experimenting, I found that this worked wonderfully:

ffmpeg -i input.avi -aspect 3:2 -s 400x300 -vcodec libx264 -b 480k -r 30 -acodec libfaac -ac 1 -ab 32k -padtop 10 -padbottom 10 -padleft 40 -padright 40 -sameq -pass 1 output.mp4

Read the rest of this entry »

Tags:

Photo file-management with raw and jpg

Even when shooting images in raw format, it is typically easier to do simple sorting and sharing with jpg files. With Nikon *.nef raw files, it is possible to extract a full-resolution jpg image using the nefextract script. However, exif metadata is not automatically copied to this extracted jpg.

The tool that I use to manipulate my images according to their exif metadata is exiv2, and I can quite simply copy metadata from raw files to their corresponding jpgs (matching filenames, and all in the one working directory) with:

exiv2 insert -l./ -S.nef *.jpg

After sorting through the jpgs and deleting all but those worth keeping, I wanted to automatically remove the raw files of those deleted images. Sure enough, this is easily done with some bash shell magic:

for file in *??.jpg; do mv raw/${file%%.jpg}.nef 2> /dev/null rawKeep/ ; done

This command says “for each jpg file you find here, move the matching nef file from the subdirectory raw/ to the subdirectory rawKeep/”. I can then delete any files left in the raw/ subdirectory, as they mustn’t have a matching jpg.

People often ask my why I persevere with the “command line” (more technically the “shell”). It seems that they assume tools with graphical interfaces are more powerful and faster. These two routine tasks demonstrate yet again that the shell really is the most efficient way to do many common jobs.

Tags: ,

Duplicating DVDs

Last week I had reason to duplicate some video DVDs.  Yes, it was legitimate; I wanted copies of personal video footage to share with family.  After fiddling around a bit I found a very straighforward way to do this task using simple GNU/Linux tools.

The first step is to copy the DVD to the hard drive (I only have one DVD drive).
cat /dev/sr0 > dvd.iso
where /dev/sr0 is my DVD device.

Then, after changing to a blank DVD, simply
growisofs -dvd-compat -Z /dev/dvd=dvd.iso
and it worked.

Tags:

Un-deleting files on my ext3 “backup” partition

Last week I learnt a very important lesson: a “backup” is not actually a backup if it is the only copy you have, it is at most an archive. In the process of tidying up the files on my external “backup” hard disk I deleted a few directories of photos from the beginning of this year. As I pressed the Enter key I was sure that I had a copy of those photos still on my laptop; but fractions of a second later I experienced a piercing wave of doubt. It was already too late.

After checking my laptop and finding that the doubt was justified, I remembered with relief that before heading over to Europe I had copied all my photos onto DVDs and left them in my office at uni (just in case something our house burnt down or something). I went to sleep mostly certain that I my accidentally deleted files were safe on discs at uni.

As you probably suspect, I did not have a copy of the photos on DVD. My DVD backups only went to the end of 2007, and I had deleted files from the first 2 months of 2008.

It is not a tragedy, as the main photos of consequence were from ASA Convention and I do have the best of my photos on the official DVD. However, it provided me with significant incentive to learn about data recovery on ext3 formatted partitions. I’ve included some of my discoveries below. Read the rest of this entry »

Tags:

Backing up data to DVD

In preparation for my trip to Europe, I needded to free up some space on my hard disk. It was a great opportunity to find out how to burn data DVDs.

I found this DVD creation article on the Gentoo wiki, and the following command worked brilliantly for me:

growisofs -dvd-compat -Z /dev/sr0 -joliet-long -R -V "<volume_name>" dvd/

where /dev/sr0 is my device and dvd/ the directory containing the desired contents of the DVD.

Tags:

Advanced command history in bash

I am an avid user of bash, the standard command line environment (technically “shell”) for GNU/Linux. In today’s graphical-rich computing culture, many people notice my command terminal and assume I must be a stubborn nostalgist of the digital dark ages. The truth is that the command line allows many regular tasks to be performed more efficiently, and makes some things possible that are simply not available any other way.

The extra power of the command line comes at the cost of learning its ways, which are not always obvious or self-explanatory. Today I found a very good guide to increasing bash productivity using vi editing commands, and leveraging the command line history to save time and effort. Both of these articles have very good downloadable cheat-sheets.

Tags:

OpenMoko and Neo1973 in real life

Last night I went along to the Canberra Linux User Group meeting and saw a FIC Neo1973 running OpenMoko. I got to touch it, play with it, listen to it, drool at it, and the end result was basically a mixture of raw excitement and desire. Read the rest of this entry »

Tags:

Easy systematic rename of .jpg and .nef photos

For a while now I’ve been giving all my digital photos filenames that are meaningful to browse, useful to organise and easy (automated) to implement. The date is used to facilitate easy sorting, a few keywords are added to ease browsing, and the timestamp is added to ensure uniqueness. Thus, I end up with filenames like 20070731_a_great_photo_1425-39.jpg. Read the rest of this entry »

Tags: ,