Monday, July 11, 2016

The better way to get date and time on your photos

On one of the latest Sony cameras, I switched on a feature that imprints the date the photograph was taken, onto the bottom right corner of the photo.

I was shocked at the result.

Sony's software puts a fat orange date stamp on the photo without even antialiasing it. Looks like we've been transported to the 1970's.

Searching for a better alternative led me to a script written by Terdon that makes use of imagemagick to extract exif information from the picture.

  • You can run it via the linux commandline
  • It's fast 
  • Doesn't mess up your existing image and 
  • Is also configurable

See the difference between Sony's orange date stamp and imagemagick's white one.

Here's what to do at your bash terminal:

sudo apt-get install imagemagick
sudo apt-get install exiv2
Then put this script in a file named

#!/usr/bin/env bash

## This command will find all image files, if you are using other
## extensions, you can add them: -o "*.foo"

find . -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.tif" -o \
 -iname "*.tiff" -o -iname "*.png" |

## Go through the results, saving each as $img
while IFS= read -r img; do
 ## Find will return full paths, so an image in the current
 ## directory will be ./foo.jpg and the first dot screws up
 ## bash's pattern matching. Use basename and dirname to extract
 ## the needed information.

 name=$(basename "$img")
 path=$(dirname "$img")

 ## Check whether this file has exif data
 if exiv2 "$img" 2>&1 | grep timestamp >/dev/null
 ## If it does, read it and add the water mark
 echo "Processing $img...";
 convert "$img" -gravity SouthEast -pointsize 22 -fill white \
 -annotate +30+30 %[exif:DateTimeOriginal] \
 ## If the image has no exif data, use the creation date of the
 ## file. CAREFUL: this is the date on which this particular file
 ## was created and it will often not be the same as the date the
 ## photo was taken. This is probably not the desired behaviour so
 ## I have commented it out. To activate, just remove the # from
 ## the beginning of each line.

 # else
 # date=$(stat "$img" | grep Modify | cut -d ' ' -f 2,3 | cut -d ':' -f1,2)
 # convert "$img" -gravity SouthEast -pointsize 22 -fill white \
 # -annotate +30+30 "$date" \
 # "$path"/"${name/%.*/.time.$ext}";


Change the file to an executable and run it:

chmod +x

Run it in the folder where your images are placed.

Works like a charm!

Sunday, July 3, 2016

The ingenuity of the humble zipper

"Clasp locker" and "hookless fastener". That's what the zip was called, once-upon-a-time.

See how the clasps get locked. A rather ingenious invention by Whitcomb L. Judson.

The reason I'm writing about it today, is because the zippers of my bag stopped working and I thought I'd have to replace the zipper teeth and the slider.

The person at the shop though, told me I'd only have to change the slider. Turned out that with time, the insides of the slider get worn out and they aren't able to make the zipper teeth clasp together anymore. The teeth are still ok, and you don't have to replace them.

Replacing involves removing some of the stitches that hold the teeth...

 ...removing the old slider completely, replacing it with a new slider and stitching it back up with a sewing machine.

That's it!
This entire process happened in less than 10 minutes, and cost me Rs.30 and Rs.20 for a large and small slider (stitching charges included).

The next time you worry about throwing away your bag or jacket because of a defective zipper, remember this post. You can get it fixed in a jiffy. If possible, try to get a new slider that matches your bag/jacket. The person at the shop might not have a variety of colours.

Friday, July 1, 2016

Discovering the unknown

X-rays were discovered by accident. We have never seen electrons. We don't know if light is a particle or a wave because of properties which observed. We don't see or hear many wavelengths which other insects and animals can.

In order for our senses of sight, smell, touch, taste and hearing to be able to receive this data and for the brain to process it, we needed to convert X-rays into something that we could see. Electrons paths into something we could experiment upon and prove.

We really are very limited by our senses.

But what if we created a machine and an AI that was capable of manufacturing sensors which would detect properties of the Earth and Universe which we never discovered, and then translate that into data that we can understand?

We would be able to not just discover so many more dimensions, we might even be able to re-program our DNA to be able to take advantage of that data.

How, is the question.