Index ¦ Archives ¦ RSS > Tag: en

Sorting photos by date using exif date info

Estimated read time: 2 minutes

For a family event I received photos from about 6 persons, and wanted to view all of them, sorted by date. The problem was that the timestamps of the files were sometimes incorrect, and also in all but one cases the exif timestamp was incorrect as well (but at least that was consistently incorrect, e.g. all behind of time by 20 mins, etc.)

So first I searched for a photo where a clock is shown, then matched photos by different authors showing the same action to know the time delta of each camera. The rest can be scripted: just read the exif info, apply the necessary time correction based on the camera model, and touch the file with the correct date. Then any image viewer can show the photos, sorted by date.

Here is the script I came up with:

for i in *.jpg
do
    # 2012:01:01 01:01:01 -> 2012-01-01 01:01:01
    date=$(exiv2 $i |grep timestamp|sed 's/.* : //'|sed 's/^\([0-9][0-9][0-9][0-9]\):\([0-9][0-9]\):\([0-9][0-9]\)/\1-\2-\3/')
    # date string -> epoch
    unix=$(date --date="$date" +%s)

    model=$(exiv2 $i |grep model|sed 's/.*: //')

    if [ "$model" == "NIKON D40" ]; then
        unix=$(($unix-1320)) # Alice
    else
        unix=$(($unix+3600)) # Bob
    fi

    # epoch -> date string
    date=$(python -c "import time; print time.strftime('%Y-%m-%d %H:%M:%S', time.localtime($unix))")
    # profit!
    touch --date="$date" $i
done
# write back the timestamps to the exif info (thx boobaa)
jhead -dsft *.jpg

And additionally if you don’t want to mess up the settings of the image viewer, you can use:

c=0; for i in $(ls -lhtr *.jpg|sed 's/.* //'); do c=$((c+1)); cp -a $i new/$(printf "%03d" $c).jpg; done

to order filenames based on the file timestamp.


Merging git notes

Estimated read time: 2 minutes

The git notes command is really about local annotation of commits — nothing to share. If you decide to still do so, for example the git-scm.com HOWTO can show you how to pull and push them. But what about merging? There is no UI for that, but — given that with git, everything is possible — you can still do so manually.

So the problem comes when Alice fetches notes, Bob does so, Alice pushes her notes back, Bob annotates a different commit and when Bob wants to push, he gets rejected, non-fast-forward. Normally you would merge or rebase in this situation, but given that git notes by default updates the refs/notes/commits ref and you typically have a different branch checked out, you can’t use git merge or git rebase directly.

What works is:

git checkout refs/notes/commits
git fetch origin refs/notes/commits
git merge FETCH_HEAD
git update-ref refs/notes/commits HEAD
git checkout master
  1. Check out the notes, so if you have conflicts, you can resolve them.

  2. Fetch remote notes to FETCH_HEAD.

  3. Do the merge.

  4. Necessary, as git merge won’t update the ref automatically, since we’re not on a branch.

  5. Or whereever you were before.

And now you can push your notes, as detailed in the above referred blog post. Yes, rebasing would be possible as well, that’s left as an exercise for the reader. ;-)


LibreOffice can now import SmartArt in Writer

Estimated read time: 1 minutes

You may remember that LibreOffice 3.5 learned to import SmartArt in Impress. In LibreOffice 3.6, the same is now true for Writer:

Note that just like in Impress, Writer produces far from perfect result if the prerendered output of the diagram is not present in the document. In practice, we can open files produced by Word 2010 just fine, but problems with Word 2007 are expected.

In case you way to play with this feature, a test document is available.


Linux in the Education Conference 2012

Estimated read time: 1 minutes

The Hungarian Linux in the Education Conference 2012 was held today @ Budapest, I held a generic session about LibreOffice (slides), also talked a few guys into submitting Easy Hacks. ;)

Other interesting stuff: a free Logo interpreter in PyUNO by Laszlo, available here.


Thanks for the Hackfest 2012

Estimated read time: 1 minutes

http://libreoffice.hu/files/2012/04/335px-HHHackfest.png

We were in Hamburg during this weekend, and I think all of us had great fun, kudos go to the organizers! If you are curious, here are the topics I worked on besides mentoring when I was asked to do so:

Also thanks Stefan for correcting the misleading icons of the horizontal/vertical flipping in Writer. ;)


OpenSource is the Source of Innovation Conference

Estimated read time: 1 minutes

We presented TDF on this conference with Andras today. It was nice to see familar and new faces as well, we turned some mentioned problems into bugreports and I also fixed the barcode extension to work again with LibreOffice 3.4+, as requested by a user.


LPSP

Estimated read time: 1 minutes

We will give a talk about LPSP and CMIS with Cedric at FOSDEM2012. If you wonder what LPSP and CMIS are:

  • LPSP: LibreOffice extension providing connection to SharePoint

  • CMIS: Content Management Interoperability Services

See you in Brussels!


mtd-utils

Estimated read time: 1 minutes

Quick node about this useful project I packaged two days ago. It has a long FAQ - I was interested in how can one access the builtin nand storage on an arm board using it.

First, check your dmesg, you should see something like:

Creating 3 MTD partitions on "orion_nand":
0x000000000000-0x000000100000 : "u-boot"
0x000000100000-0x000000500000 : "uImage"
0x000000500000-0x000020000000 : "root"

As the names say, the three items here are the bootloader, the kernel and the root filesystem. To access and mount the last one, you need:

ubiattach /dev/ubi_ctrl -m 2
mount /dev/ubi0_0 root
... hack hack hack ...
umount root
ubidetach /dev/ubi_ctrl -m 2

Frugalware arm port install HOWTO

Estimated read time: 4 minutes

I recently got a GuruPlug. It has Debian by default, and it’s apt config is set to stable, while in fact at the moment what’s the factory default is considered as oldstable by upstream. So if you blindly do a few apt-get install foo, soon you’ll have newer userspace than kernel, and your device will no longer boot (based on true story - and yes, this is not Debian’s fault). Moreover, I was interested in how to install Frugalware on this device, so here is a quick howto.

Install rootfs

First you need to bootstrap Frugalware from Debian. It’s a good idea to install Frugalware on a USB stick, so you can switch back to Debian in case you messed up something and start from scratch again.

Partitioning is up to you, you’re recommended to have a small FAT (type: 0x0b) partition (32MB for example) at the beginning, we’ll use that later. The second can be the rest, ext4 or so.

Format and mount it (your device name may differ!):

mkfs.ext4 /dev/sda2
mkdir -p /mnt/sda2
mount /dev/sda2 /mnt/sda2

Then install our pacman-g2 binary to the Debian system, so you can bootstrap:

wget http://ftp.frugalware.org/pub/frugalware/frugalware-stable/frugalware-arm/pacman-g2-3.8.3-2mores2-arm.fpm
unxz pacman-g2-3.8.3-2mores2-arm.tar.xz
cd /
tar xf /path/to/pacman-g2-3.8.3-2mores2-arm.tar
rm .CHANGELOG .FILELIST .PKGINFO

Installing the required packages is a single command, as described here:

pacman-g2.static --noconfirm -Sy core base -r /mnt/sda2/

Upgrade the bootloader

Once the rootfs is ready, you need a new bootloader that will be able to boot our vanilla kernel.

You need a JTAG Board, so you can access the serial console. If you connect the USB cable to you PC, you can use for example

screen /dev/ttyUSB0 115200

to access the device.

Given that we want to boot a vanilla kernel, we need a vanilla bootloader as well. Before you mess with the bootloader, it’s a good idea to make a backup of its config (there is a 3 second timeout during boot - if you press any key there, you get the Marvell prompt). Here is my config:

Marvell>> printenv
bootcmd=${x_bootcmd_ethernet}; ${x_bootcmd_usb}; ${x_bootcmd_kernel}; setenv bootargs ${x_bootargs} ${x_bootargs_root}; bootm 0x6400000;
bootdelay=3
baudrate=115200
x_bootcmd_ethernet=ping 192.168.2.1
x_bootcmd_usb=usb start
x_bootcmd_kernel=nand read.e 0x6400000 0x100000 0x400000
x_bootargs=console=ttyS0,115200
x_bootargs_root=ubi.mtd=2 root=ubi0:rootfs rootfstype=ubifs
ethact=egiga0
bootargs=console=ttyS0,115200 ubi.mtd=2 root=ubi0:rootfs rootfstype=ubifs
ipaddr=10.10.10.10
serverip=10.10.10.179
ethaddr=F0:AD:4E:00:CE:C3
stdin=serial
stdout=serial
stderr=serial

The only semi-unique part is the MAC address of the network interface(s).

If you want to update the bootloader, a possible way is to put the new binary to a pendrive. Given that the default bootloader does not support ext*, we need a fat filesystem. So format the first small partition we created already (the device name may be different in your case!):

mkdosfs /dev/sda1

Till Frugalware 1.6 is released, support for GuruPlug is available in Frugalware -current only, so download the binary package from there, extract the u-boot.kwb file from the guruplug directory, put it to the new partition. (A few other models are explained here).

Before you reboot, copy also /boot/uImage to the fat partition, you may have problems problems with reading the kernel from the ext4 partition with u-boot.

Once copying the kernel is done, reboot and in the u-boot shell do:

usb start
fatload usb 0:1 0x0800000 u-boot.kwb
nand erase 0x0 0x60000
nand write 0x0800000 0x0 0x60000
reset

You can verify the updated bootloader with the version command:

Marvell>> version

U-Boot 2011.12 (Jan 03 2012 - 16:55:38)
Marvell-GuruPlug
gcc (Frugalware Linux) 4.6.2
GNU ld (GNU Binutils) 2.22

If Frugalware is mentioned, that’s a good sign. :)

Boot the new rootfs

Now you can boot your new rootfs:

usb start
fatload usb 0:1 0x00800000 /uImage
setenv bootargs console=ttyS0,115200 root=/dev/sda2 rootdelay=5
bootm 0x00800000

If it booted fine, you may want to make this the default:

setenv bootargs 'console=ttyS0,115200 root=/dev/sda2 rootdelay=5'
setenv bootcmd_usb 'usb start; fatload usb 0:1 0x00800000 /uImage'
setenv bootcmd 'run bootcmd_usb; bootm 0x00800000'
saveenv

Finalize

The rest is up to you:

  • setting up a root password

  • setting up network by default using netconfig

and so on… you know this already, nothing arm-specific.

For the reference, here is the tested CPU and Frugalware version:

$ cat /proc/cpuinfo
Processor       : Feroceon 88FR131 rev 1 (v5l)
BogoMIPS        : 1191.11
Features        : swp half thumb fastmult edsp
CPU implementer : 0x56
CPU architecture: 5TE
CPU variant     : 0x2
CPU part        : 0x131
CPU revision    : 1

Hardware        : Marvell GuruPlug Reference Board
Revision        : 0000
Serial          : 0000000000000000
$ cat /etc/frugalware-release
Frugalware 1.5 (Mores)

Recent contributions

Estimated read time: 1 minutes

  • BitlBee: a patch for skyped got merged, helping to avoid the cryptic openssl error messages when the certificate is missing.

  • openSUSE: the mutt package now contains one more patch from Frugalware’s mutt-ng package, which means my mutt config can be used unmodified (no more unknown config settings)

  • jBPM and bpm-console: these were part of my MSc thesis, github branches are available, upstreaming is in progress (on IRC they confirmed that they are interested in the feature, at least)

© Miklos Vajna. Built using Pelican. Theme by Giulio Fidente on github.