Archive for category Hacks and Tricks

Revisiting categories, and generally improving this site

When I first started using Wordpress to construct this website, it had “categories” and not “tags”. Since then, I have tried to improve my use of categories and tags have come along to add another complication to the fray. I have now finally reached a system that I really like.

One of the difficulties of a personal website (as opposed to a blog on a specific topic) is that there is such a variety of post types. Sometimes the site becomes a little soap-box where essays can be delivered. Other times, it is a news feed to keep family and friends updated about exciting travel activities. It is also a valuable way to store and share helpful tricks and insights.

So I have now culled my category list down to six distinct topics, and a seventh “uncategorised” overflow pigeonhole. Within these broad categories, posts are further grouped by tags. It is possible to browse posts by category, or by tag. While I’m not claiming that this sort of organising strategy is anything new or unique, I think it is finally a functional way to hold this site together.

I have also revamped this site visually and under the bonnet. Here are some of the more technical details.
Read the rest of this entry »

Tags:

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: ,

Pretty display fonts from Latex

The fonts that LaTeX uses by default (called “Computer Modern”) are very elegant, and are one of the great reasons to use LaTeX for typesetting documents. Frustratingly, I’ve been having difficulty lately with my pdfviewer (epdfview and sometimes xpdf) not displaying these fonts well in pdfs I’ve created using LaTeX.

Adobe acroread has been able to do a better job, but who wants to use such a slow and bloated piece of software just to quickly view a pdf? At least the pdfs have printed properly, so up till now I haven’t been too worried.

The solution, which I found at a page encouragingly called “High quality PDF output from LaTeX and TeX”, is profoundly simple. It simply involves telling LaTeX to use the scalable font rather than the older bitmap version. Add these two lines to the preamble:

\usepackage[T1]{fontenc}
\usepackage{ae,aecompl}

and you’re done.

Tags:

Foray into geotagging photos

One of the really great things about storing photographs digitally is the ability to embed all sorts of information about the image in “metadata” within the file. When I shot film, I carried a notebook around with me that I tried to record exposure settings in (I was usually too lazy); I wanted to be able to learn from experience by looking at the settings I used to take a particular image. Digital cameras have trivialised this process, as they embed the exposure settings within each photograph.

But digital metadata is able to store much more than just the camera settings. In particular, it is becomming increasingly common to store location information (collected automatically by GPS). This is not so much to remind the photographer where they took the photo (most of us are pretty good at remembering that with reasonable precision), but it allows entirely new methods of displaying and browsing sets of photos.

Over the last few months I have experimented with various data acquisition and image display techniques for geo-tagging. This is a growing field, and so I’m sure there’s a lot more for me to learn. However, here are my findings and a quick demonstration of the results. Read the rest of this entry »

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:

The Orton Effect

While browsing some photos on Flickr the other day I came across an interesting artistic photography technique. It is known as the “Orton Effect” after a guy called Michael Orton, and involves superimposing a focussed image and blurred image (both overexposed) of the same scene. The effect is a mixture of sharp detail and blended colour that produces somewhat ethereal and emotionally engaging images. Orton developed the technique using slide film and physically mounting 2 images in a single slide frame, but it is easy to reproduce the effect with digital post-processing. Read the rest of this entry »

Tags: