Work-around if 64-bit Google Earth crashes in Gentoo Linux

Google Earth 5.2.1.1588 was the last version of Google Earth for Linux that worked on my main laptop running 64-bit Gentoo Linux. Even the Panoramio photos were displayed (a common complaint amongst users of Google Earth for Linux). But every subsequent version crashed when I launched it. The latest version, 7.1.2.2041, is no exception:

$ googleearth
[0403/012031:ERROR:net_util.cc(2195)] Not implemented reached in bool net::HaveOnlyLoopbackAddresses()
[0403/012033:ERROR:nss_ocsp.cc(581)] No URLRequestContext for OCSP handler.
[0403/012033:ERROR:nss_ocsp.cc(581)] No URLRequestContext for OCSP handler.
[0403/012033:ERROR:nss_ocsp.cc(581)] No URLRequestContext for OCSP handler.
[0403/012033:ERROR:nss_ocsp.cc(581)] No URLRequestContext for OCSP handler.
[0403/012033:ERROR:nss_ocsp.cc(581)] No URLRequestContext for OCSP handler.
[0403/012033:ERROR:nss_ocsp.cc(581)] No URLRequestContext for OCSP handler.
[0403/012033:ERROR:nss_ocsp.cc(581)] No URLRequestContext for OCSP handler.
[0403/012033:ERROR:nss_ocsp.cc(581)] No URLRequestContext for OCSP handler.
[0403/012033:WARNING:backend_impl.cc(1875)] Destroying invalid entry.
[0403/012033:ERROR:nss_ocsp.cc(581)] No URLRequestContext for OCSP handler.
[0403/012033:ERROR:nss_ocsp.cc(581)] No URLRequestContext for OCSP handler.
[0403/012033:ERROR:nss_ocsp.cc(581)] No URLRequestContext for OCSP handler.
[0403/012033:ERROR:nss_ocsp.cc(581)] No URLRequestContext for OCSP handler.
Google Earth has caught signal 11.



We apologize for the inconvenience, but Google Earth has crashed.
This is a bug in the program, and should never happen under normal
circumstances. A bug report and debugging data have been written
to this text file:

/home/fitzcarraldo/.googleearth/crashlogs/crashlog-533ca953.txt

Please include this file if you submit a bug report to Google.

Now, the Google Earth installation package bundles the libraries it needs, so they are used instead of the ‘native’ libraries installed on your machine. A Linux user going by the moniker amirpli worked out how to enable Google Earth for Linux to use the native Qt libraries rather than the Qt libraries bundled with Google Earth, and posted instructions for a number of distributions (see, for example, Comment 9 in Gentoo Bugzilla Bug Report No. 490066). However, even if I apply amirpli‘s fix, Google Earth on my main laptop crashed with almost the same error message as above. Looking through the crash log file that Google Earth generates, I see the following line, which makes me suspect that Google Earth cannot work with the closed-source AMD ATI Catalyst driver (a.k.a. FGLRX):

./libbase.so(_ZN5earth15GfxCardInfoUnix25GetGraphicsCardMemoryInMBERi+0xe)[0x7f011b3e654e]

I noticed a few posts by users of other distributions in various forums saying that they had installed the 32-bit version of Google Earth in their 64-bit (multilib) installations, so I decided to try that in Gentoo. I hacked the ebuild of version 7.1.2.2041 to force it to install the 32-bit version of Google Earth on my 64-bit multilib installation, and installed it via a local overlay.

The hacked ebuild has the following changes from the stock 7.1.2.2041 ebuild:

a) Replace:

SRC_URI="x86? ( http://dl.google.com/dl/earth/client/current/google-earth-stable_current_i386.deb
                       -> GoogleEarthLinux-${PV}_i386.deb )
       amd64? ( http://dl.google.com/dl/earth/client/current/google-earth-stable_current_amd64.deb
                       -> GoogleEarthLinux-${PV}_amd64.deb )"

with:

SRC_URI="http://dl.google.com/dl/earth/client/current/google-earth-stable_current_i386.deb
                       -> GoogleEarthLinux-${PV}_i386.deb"


b) Replace:

unpack_deb GoogleEarthLinux-${PV}_$(usex amd64 "amd64" "i386").deb

with:

unpack_deb GoogleEarthLinux-${PV}_i386.deb


c) Replace:

patchelf --set-interpreter /lib/ld-linux$(usex amd64 "-x86-64" "").so.2 ${PN}-bin || die "patchelf failed"

with:

patchelf --set-interpreter /lib/ld-linux.so.2 ${PN}-bin || die "patchelf failed"


If you have not used a local overlay before, it is not difficult — just follow the steps given below.

1. If you have not done it before, tell Portage the location of the local overlay:

# echo 'PORTDIR_OVERLAY="${PORTDIR_OVERLAY} /usr/local/portage/"' >> /etc/make.conf

2. If you have not done it before, give your local overlay a name:

# mkdir /usr/local/portage/profiles
# echo "local_overlay" > /usr/local/portage/profiles/repo_name

3. Create the directories for the local overlay’s Google Earth ebuild and its associated files:

# mkdir -p /usr/local/portage/sci-geosciences/googleearth/files

4. Uninstall the non-functioning 64-bit version of Google Earth that you installed from the Portage main tree:

# emerge -C googleearth

5. Copy the main tree’s ebuild and associated files to the local overlay and edit the ebuild as per the changes I listed above:

# cp /usr/portage/sci-geosciences/googleearth/googleearth-7.1.2.2041.ebuild /usr/local/portage/sci-geosciences/googleearth/
# cp /usr/portage/sci-geosciences/googleearth/files/* /usr/local/portage/sci-geosciences/googleearth/files/
# cd /usr/local/portage/sci-geosciences/googleearth/
# nano googleearth-7.1.2.2041.ebuild

6. Create the manifest for the ebuild and associated files:

# ebuild googleearth-7.1.2.2041.ebuild manifest

7. Finally, install the package:

# emerge googleearth::local_overlay

The 32-bit version of Google Earth works fine in my 64-bit multilib installation, although the Panoramio photos are not displayed, but then Linux users are used to that :-/. Come on Google, you can do better than this!

Installing the Windows version of Google Earth in WINE

Some Gentoo Linux users have reported that, although the native Linux release of Google Earth crashes, they can run the Windows version successfully under WINE. However, those users have also reported that the Windows installer for Google Earth did not work under WINE and so they copied the C:\Program Files\Google\Google Earth\ directory from a Windows PC to the virtual C:\ drive in their .wine directory (it would be ‘Program Files (x86)‘ in a 64-bit Windows installation, as Google Earth is a 32-bit application).

Now, if you download the Windows Google Earth installer from the Google Web site, what you get is a file GoogleEarthWin.exe that is 534.6 KiB in size (the size may vary depending on the release). However, you can instead download the Offline Installer using the following URL:

http://dl.google.com/earth/client/advanced/current/GoogleEarthWin.exe

and then you get a file GoogleEarthWin.exe that is 24.3 MiB in size (the size will vary depending on the release), which does run in WINE and does install the Windows version of Google Earth in WINE.

So, you might like to try that if you cannot run Google Earth in Linux but you have WINE installed. However, note that you will be wasting your time if the native Linux version of Google Earth crashes because of its incompatibility with the closed-source ATI or NVIDIA video driver. For example, Google Earth 7.1.2.2041 for Linux crashes on my main laptop using the 14.3_beta version of ati-drivers (AMD ATI Catalyst driver, a.k.a. FGLRX).

Anyway, if you want to install the Windows release of Google Earth under WINE here’s how to do it in a Konsole/Terminal window:

$ cd
$ export WINEPREFIX=$HOME/.wine-googleearth
$ export WINEARCH="win32"
$ winecfg
$ cd ./.wine-googleearth/drive_c/
$ wget http://dl.google.com/earth/client/advanced/current/GoogleEarthWin.exe
$ wine GoogleEarthWin.exe

And, to run it later:

$ env WINEPREFIX="/home/fitzcarraldo/.wine-googleearth" WINEARCH="win32" wine C:\\windows\\command\\start.exe /Unix /home/fitzcarraldo/.wine-googleearth/dosdevices/c:/users/fitzcarraldo/Start\ Menu/Programs/Google\ Earth/Google\ Earth.lnk

(Of course replace “fitzcarraldo” with your user name.)

But, as I wrote above, if the native Linux version of Google Earth crashes due to its incompatibility with the closed-source video driver (ATI or NVIDIA), it is highly unlikely the native Windows version will work under WINE.

Split an A4 PDF file into two A5 PDF files

This week I scanned a couple of receipts in order to submit them to a client with an expenses claim. The two receipts were physically small enough to both fit on an A4 page, so I lay them both on the bed of a scanner and produced a PDF file with the two receipts on one A4 page. The resulting scan looked rather like the sketch in Figure 1. However, a couple of days later I remembered that the client wanted copies of receipts to be submitted individually, but the office scanner had stopped working and so I needed to split the original PDF file into two PDF files containing images rather like the sketches in Figures 2 and 3.

Figure 1 - original A4 image

Figure 1 - original A4 image

Figure 2 - A5 bottom half of original A4 image

Figure 2 - A5 bottom half of original A4 image

Figure 3 - A5 top half of original A4 image

Figure 3 - A5 top half of original A4 image

I was surprised to find little information on the Web about how to do such a thing. I did come across three applications that looked like they probably could do the job: jPdf Tweak, BRISS and krop. jPdf Tweak is in the Portage main tree (app-text/jpdftweak). BRISS isn’t. The krop Web page does have a link to an ebuild which could be downloaded and installed via a local overlay. I did have a brief play with jPdf Tweak and it looks powerful, but I did not find it particularly intuitive and I would need to study the manual in detail. Anyway, I thought I would try a command line approach for the fun of it.

Searching the Web I came across a site with a Perl script that looked promising: Split (crop) double page PDFs in two posted by someone called iblis (to whom I’m grateful). It uses a Perl module PDF:API2 which does exist in the Portage main tree (dev-perl/PDF-API2) and which I already had installed. I modified the last couple of lines of the script very slightly, so it now looks like this:

#!/usr/bin/env perl
use strict; use warnings;
use PDF::API2;
     
my $filename = shift || 'test.pdf';
my $oldpdf = PDF::API2->open($filename);
my $newpdf = PDF::API2->new;
     
for my $page_nb (1..$oldpdf->pages) {
my ($page, @cropdata);
     
$page = $newpdf->importpage($oldpdf, $page_nb);
@cropdata = $page->get_mediabox;
$cropdata[2] /= 2;
$page->cropbox(@cropdata);
$page->trimbox(@cropdata);
$page->mediabox(@cropdata);
     
$page = $newpdf->importpage($oldpdf, $page_nb);
@cropdata = $page->get_mediabox;
$cropdata[0] = $cropdata[2] / 2;
$page->cropbox(@cropdata);
$page->trimbox(@cropdata);
$page->mediabox(@cropdata);
}
     
(my $newfilename = $filename) =~ s/(.*)\.(\w+)$/$1.split.$2/;
$newpdf->saveas($newfilename);
     
__END__

I saved it with the file name split_pdf_A4_to_A5.pl and made it executable:

$ chmod +x split_pdf_A4_to_A5.pl

Then I used the following procedure to split the original PDF file:

1. I used the excellent command line utility pdftk (the package app-text/pdftk in Gentoo), which I had already installed, to rotate the A4 page clockwise and save it in a file named rotated.pdf:

$ pdftk original.pdf rotate 1-1right output rotated.pdf

Now the A4 page looked similar to the sketch in Figure 4.

Figure 4 - original A4 image, rotated clockwise by 90 degrees

Figure 4 - original A4 image, rotated clockwise by 90 degrees

2. I used the Perl script to split the A4 page into two A5 pages within one PDF file:

$ ./split_pdf_A4_to_A5.pl rotated.pdf

The above command created a file rotated.split.pdf containing two A5 pages.

3. Finally, I split the two-page PDF file into two separate single-page files:

$ pdftk rotated.split.pdf burst

which left me with two A5 PDF files named page_0001.pdf and page_0002.pdf similar to the sketches in Figures 2 and 3 above.

Mission accomplished. :-)

Installing and using ZBar in Linux to scan bar codes with your Webcam

ZBar is an application that can scan and decode several bar code symbologies (including QR Code) from sources such as a Webcam or an image file. I had been wanting to install it for some time and was finally spurred on to do it by a request for help to get it working in the Sabayon Linux forums. Here are the steps I used.

1. I installed the package media-gfx/zbar-0.10-r1.
Note for Gentoo users: I merged the package with the imagemagick and v4l USE flags set, so that both zbarimg and zbarcam would be installed. If you only want to use ZBar with a Webcam then turn off the imagemagick flag and zbarimg will not be installed.
Note for Sabayon Linux users: The Entropy package was built with both the above-mentioned USE flags set, so zbarimg and zbarcam will be installed.

2. Then I checked the status of the installed package by using the Portage eix command:

$ eix -I zbar
[I] media-gfx/zbar
Available versions: (~)0.10-r1 {{X gtk imagemagick jpeg python qt4 static-libs +threads v4l xv}}
Installed versions: 0.10-r1(03:56:14 05/10/12)(X gtk imagemagick jpeg qt4 threads v4l xv -python -static-libs)
Homepage: http://zbar.sourceforge.net/
Description: Library and tools for reading barcodes from images or video

Sabayon Linux users could instead use the following command:

$ equo search --verbose zbar

3. Then I checked which video device my laptop’s inbuilt Webcam is:

$ ls /dev/video*
/dev/video0

4. As it is /dev/video0, I launched zbarcam as follows:

$ zbarcam --raw /dev/video0
WARNING: no compatible input to output format
...trying again with output disabled
ERROR: zbar processor in zbar_processor_init():
unsupported request: no compatible image format

Clearly zbarcam was not recognising the Webcam.

5. As I had installed the package with the Video4Linux USE flag set, I then launched zbarcam with the following prefix:

$ LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so zbarcam --raw /dev/video0

The ZBar GUI window popped up and I could see myself in the window. So far, so good.

6. I held a QR Code 2D bar code in front of the Webcam, then held a 1D Interleaved 2 of 5 bar code in front of the Webcam. The following was displayed:

$ LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so zbarcam --raw /dev/video0
http://roho.it/mryt
0161223563

Both the QR Code and the I2of5 bar code were read correctly. If the --raw parameter is omitted then zbarcam displays the symbology of the bar code too:

$ LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so zbarcam /dev/video0
QR-Code:http://roho.it/mryt
I2/5:0161223563

7. Then I tried using ZBar to read a bar code which I had previously saved as a .jpg file:

$ zbarimg --raw ~/zebra04.jpg
01234565
scanned 1 barcode symbols from 1 images in 0.04 seconds

$ zbarimg ~/zebra04.jpg
EAN-8:01234565
scanned 1 barcode symbols from 1 images in 0.04 seconds

To find out the other parameters available, use the commands:

$ man zbarcam
$ zbarcam --help
$ man zbarimg
$ zbarimg --help

ZBar is a nice tool. 8-)

ExifTool comes to the rescue when I need to fix the date and time in a batch of photo files

Before departing on an overseas trip recently I configured my camera to have the correct date and time at home (BST time zone). Of course I forgot to reconfigure the camera to the local time at my destination. On top of that, for some reason I still do not know, the date in the camera got changed. Anyway, I ended up with a large number of photos with EXIF data containing the wrong date and time. For example, I took one photo on 2011:08:04 at 09:19:03 local time but the EXIF data in the JPEG file was 2011:07:25 02:19:03.

So I needed to find a way to correct the date and time in all the photos in one fell swoop. Enter ExifTool, an excellent command line tool written in Perl. See ExifTool by Phil Harvey for full details and the download page.

To install it, I downloaded Image-ExifTool-8.61.tar.gz and followed the instructions on Installing ExifTool on Unix Platforms.

I’m going to show you how I fixed my photos. There is a lot of console output in this article because I want to give you actual examples of how to use the ExifTool commands, as it took me a while to understand the detailed documentation for the tool.

In order to fix my photos, I first copied into the ExifTool directory the directory containing the photos.

Then I used ExifTool to check the EXIF data in one of the photos, to see which tags needed to be corrected:

fitzcarraldo@meshedgedx ~ $ cd ExifTool/Image-ExifTool-8.61
fitzcarraldo@meshedgedx ~/ExifTool/Image-ExifTool-8.61 $ ./exiftool Photos_04_08_2011/DSC00006.JPG
ExifTool Version Number : 8.61
File Name : DSC00006.JPG
Directory : Photos_04_08_2011
File Size : 1405 kB
File Modification Date/Time : 2011:08:10 09:44:27+01:00 <------- This was the date and time that I last modified this file.
File Permissions : rwxrwxrwx
File Type : JPEG
MIME Type : image/jpeg
Exif Byte Order : Little-endian (Intel, II)
Image Description :
Make : SONY
Camera Model Name : DSC-WX7
Orientation : Horizontal (normal)
X Resolution : 72
Y Resolution : 72
Resolution Unit : inches
Modify Date : 2011:07:25 02:19:03 <------- This is the wrong date and time. It should be 2011:08:04 09:19:03.
Y Cb Cr Positioning : Co-sited
Exposure Time : 1/250
F Number : 8.0
Exposure Program : Landscape
ISO : 100
Sensitivity Type : Recommended Exposure Index
Recommended Exposure Index : 100
Exif Version : 0230
Date/Time Original : 2011:07:25 02:19:03 <------- This is the wrong date and time. It should be 2011:08:04 09:19:03.
Create Date : 2011:07:25 02:19:03 <------- This is the wrong date and time. It should be 2011:08:04 09:19:03.
Components Configuration : Y, Cb, Cr, -
Compressed Bits Per Pixel : 2
Brightness Value : 10.15390625
Exposure Compensation : 0
Max Aperture Value : 2.6
Metering Mode : Multi-segment
Light Source : Unknown
Flash : Auto, Did not fire
Focal Length : 4.5 mm
Panorama Full Width : 0
Panorama Full Height : 0
Panorama Direction : Right to Left
Panorama Crop Left : 0
Panorama Crop Top : 0
Panorama Crop Right : 0
Panorama Crop Bottom : 0
Panorama Frame Width : 0
Panorama Frame Height : 0
Panorama Source Width : 0
Panorama Source Height : 0
Brightness : 0
High ISO Noise Reduction : n/a
HDR : Off
Face Info Offset : 94
Sony Date Time : 2011:07:25 02:19:03 <------- This is the wrong date and time. It should be 2011:08:04 09:19:03.
Faces Detected : 0
Face Info Length : 37
Color Reproduction : Standard
Color Temperature : 4294967295
Color Compensation Filter : -1
Scene Mode : n/a
Zone Matching : ISO Setting Used
Image Stabilization : On
Color Mode : n/a
Macro : Off
Focus Mode : Permanent-AF
AF Mode : Default
AF Illuminator : Auto
Quality : Normal
Flash Level : Unknown (128)
Release Mode : Normal
Sequence Number : Single
Anti-Blur : On (Shooting)
Long Exposure Noise Reduction : Unknown (2)
Dynamic Range Optimizer : Standard
Intelligent Auto : On
White Balance : Auto
User Comment :
Flashpix Version : 0100
Color Space : sRGB
Exif Image Width : 2592
Exif Image Height : 1944
Interoperability Index : R98 - DCF basic file (sRGB)
Interoperability Version : 0100
File Source : Digital Camera
Scene Type : Directly photographed
Custom Rendered : Normal
Exposure Mode : Auto
Digital Zoom Ratio : 1
Scene Capture Type : Landscape
Contrast : Normal
Saturation : Normal
Sharpness : Normal
Lens Info : 4.5-22.5mm f/2.6-6.3
PrintIM Version : 0300
Compression : JPEG (old-style)
Thumbnail Offset : 13588
Thumbnail Length : 8277
MPF Version : 0100
Number Of Images : 2
MP Image Flags : Dependent child image
MP Image Format : JPEG
MP Image Type : Large Thumbnail (full HD equivalent)
MP Image Length : 343933
MP Image Start : 1095165
Dependent Image 1 Entry Number : 0
Dependent Image 2 Entry Number : 0
Image Width : 2592
Image Height : 1944
Encoding Process : Baseline DCT, Huffman coding
Bits Per Sample : 8
Color Components : 3
Y Cb Cr Sub Sampling : YCbCr4:2:2 (2 1)
Aperture : 8.0
Image Size : 2592x1944
Preview Image : (Binary data 343933 bytes, use -b option to extract)
Shutter Speed : 1/250
Thumbnail Image : (Binary data 8277 bytes, use -b option to extract)
Focal Length : 4.5 mm
Light Value : 14.0

I found four tags were incorrect in the file: ‘Modify Date’, ‘Date/Time Original’, ‘Create Date’ and ‘Sony Date Time’. However, before using ExifTool on all four tags and on the whole batch of photos, I first tried fixing only the tag ‘Sony Date Time’ in this single photo, to see if that would work:

fitzcarraldo@meshedgedx ~/ExifTool/Image-ExifTool-8.61 $ ./exiftool "-SonyDateTime+=0:00:10 07:00:0" Photos_04_08_2011/DSC00006.JPG

and then I checked the photo’s meta data again to see if the tag had been changed correctly:

fitzcarraldo@meshedgedx ~/ExifTool/Image-ExifTool-8.61 $ ./exiftool Photos_04_08_2011/DSC00006.JPG
ExifTool Version Number : 8.61
File Name : DSC00006.JPG
Directory : Photos_04_08_2011
File Size : 1405 kB
File Modification Date/Time : 2011:08:10 09:45:16+01:00 <------- This was the date and time when I ran ExifTool to change 'Sony Date Time' in this file.
File Permissions : rwxrwxrwx
File Type : JPEG
MIME Type : image/jpeg
Exif Byte Order : Little-endian (Intel, II)
Image Description :
Make : SONY
Camera Model Name : DSC-WX7
Orientation : Horizontal (normal)
X Resolution : 72
Y Resolution : 72
Resolution Unit : inches
Modify Date : 2011:07:25 02:19:03 <------- Notice it is still wrong, as I didn't try to change it.
Y Cb Cr Positioning : Co-sited
Exposure Time : 1/250
F Number : 8.0
Exposure Program : Landscape
ISO : 100
Sensitivity Type : Recommended Exposure Index
Recommended Exposure Index : 100
Exif Version : 0230
Date/Time Original : 2011:07:25 02:19:03 <------- Notice it is still wrong, as I didn't try to change it.
Create Date : 2011:07:25 02:19:03 <------- Notice it is still wrong, as I didn't try to change it.
Components Configuration : Y, Cb, Cr, -
Compressed Bits Per Pixel : 2
Brightness Value : 10.15390625
Exposure Compensation : 0
Max Aperture Value : 2.6
Metering Mode : Multi-segment
Light Source : Unknown
Flash : Auto, Did not fire
Focal Length : 4.5 mm
Panorama Full Width : 0
Panorama Full Height : 0
Panorama Direction : Right to Left
Panorama Crop Left : 0
Panorama Crop Top : 0
Panorama Crop Right : 0
Panorama Crop Bottom : 0
Panorama Frame Width : 0
Panorama Frame Height : 0
Panorama Source Width : 0
Panorama Source Height : 0
Brightness : 0
High ISO Noise Reduction : n/a
HDR : Off
Face Info Offset : 94
Sony Date Time : 2011:08:04 09:19:03 <------- Notice it is now correct.
Faces Detected : 0
Face Info Length : 37
Color Reproduction : Standard
Color Temperature : 4294967295
Color Compensation Filter : -1
Scene Mode : n/a
Zone Matching : ISO Setting Used
Image Stabilization : On
Color Mode : n/a
Macro : Off
Focus Mode : Permanent-AF
AF Mode : Default
AF Illuminator : Auto
Quality : Normal
Flash Level : Unknown (128)
Release Mode : Normal
Sequence Number : Single
Anti-Blur : On (Shooting)
Long Exposure Noise Reduction : Unknown (2)
Dynamic Range Optimizer : Standard
Intelligent Auto : On
White Balance : Auto
User Comment :
Flashpix Version : 0100
Color Space : sRGB
Exif Image Width : 2592
Exif Image Height : 1944
Interoperability Index : R98 - DCF basic file (sRGB)
Interoperability Version : 0100
File Source : Digital Camera
Scene Type : Directly photographed
Custom Rendered : Normal
Exposure Mode : Auto
Digital Zoom Ratio : 1
Scene Capture Type : Landscape
Contrast : Normal
Saturation : Normal
Sharpness : Normal
Lens Info : 4.5-22.5mm f/2.6-6.3
PrintIM Version : 0300
Compression : JPEG (old-style)
Thumbnail Offset : 13588
Thumbnail Length : 8277
MPF Version : 0100
Number Of Images : 2
MP Image Flags : Dependent child image
MP Image Format : JPEG
MP Image Type : Large Thumbnail (full HD equivalent)
MP Image Length : 343933
MP Image Start : 1095165
Dependent Image 1 Entry Number : 0
Dependent Image 2 Entry Number : 0
Image Width : 2592
Image Height : 1944
Encoding Process : Baseline DCT, Huffman coding
Bits Per Sample : 8
Color Components : 3
Y Cb Cr Sub Sampling : YCbCr4:2:2 (2 1)
Aperture : 8.0
Image Size : 2592x1944
Preview Image : (Binary data 343933 bytes, use -b option to extract)
Shutter Speed : 1/250
Thumbnail Image : (Binary data 8277 bytes, use -b option to extract)
Focal Length : 4.5 mm
Light Value : 14.0

So it looked like ExifTool would do the job. But I was still cautious, so I then used ExifTool to change the tags ‘Modify Date’, ‘Date/Time Original’, ‘Create Date’ and ‘Sony Date Time’ in another photo, just to check they would all be changed correctly, and I doublechecked the dates and times in the EXIF data, this time by using the ExifTool command switches -a -u and -g1 to group the meta data:

fitzcarraldo@meshedgedx ~/ExifTool/Image-ExifTool-8.61 $ ./exiftool -a -u -g1 Photos_04_08_2011/DSC00168.JPG
---- ExifTool ----
ExifTool Version Number : 8.61
---- System ----
File Name : DSC00168.JPG
Directory : .
File Size : 1854 kB
File Modification Date/Time : 2011:08:11 06:30:30+01:00
File Permissions : rwxrwxrwx
---- File ----
File Type : JPEG
MIME Type : image/jpeg
Exif Byte Order : Little-endian (Intel, II)
Image Width : 2592
Image Height : 1944
Encoding Process : Baseline DCT, Huffman coding
Bits Per Sample : 8
Color Components : 3
Y Cb Cr Sub Sampling : YCbCr4:2:2 (2 1)
---- IFD0 ----
Image Description :
Make : SONY
Camera Model Name : DSC-WX7
Orientation : Horizontal (normal)
X Resolution : 72
Y Resolution : 72
Resolution Unit : inches
Modify Date : 2011:08:04 15:30:20 <------- Fixed.
Y Cb Cr Positioning : Co-sited
---- ExifIFD ----
Exposure Time : 1/30
F Number : 2.6
Exposure Program : Program AE
ISO : 400
Sensitivity Type : Recommended Exposure Index
Recommended Exposure Index : 400
Exif Version : 0230
Date/Time Original : 2011:08:04 15:30:20 <------- Fixed.
Create Date : 2011:08:04 15:30:20 <------- Fixed.
Components Configuration : Y, Cb, Cr, -
Compressed Bits Per Pixel : 2
Brightness Value : 1.17734375
Exposure Compensation : 0
Max Aperture Value : 2.6
Metering Mode : Multi-segment
Light Source : Unknown
Flash : Off, Did not fire
Focal Length : 4.5 mm
User Comment :
Flashpix Version : 0100
Color Space : sRGB
Exif Image Width : 2592
Exif Image Height : 1944
File Source : Digital Camera
Scene Type : Directly photographed
Custom Rendered : Normal
Exposure Mode : Auto
White Balance : Auto
Digital Zoom Ratio : 1
Scene Capture Type : Standard
Contrast : Normal
Saturation : Normal
Sharpness : Normal
Lens Info : 4.5-22.5mm f/2.6-6.3
---- Sony ----
Panorama Full Width : 0
Panorama Full Height : 0
Panorama Direction : Right to Left
Panorama Crop Left : 0
Panorama Crop Top : 0
Panorama Crop Right : 0
Panorama Crop Bottom : 0
Panorama Frame Width : 0
Panorama Frame Height : 0
Panorama Source Width : 0
Panorama Source Height : 0
Sony 0x2000 : 0
Sony 0x2002 : 0
Sony 0x2003 : �������������������������������������������������������[...]
Contrast : 0
Saturation : -1
Sharpness : -1
Brightness : 0
Long Exposure Noise Reduction : n/a
High ISO Noise Reduction : n/a
HDR : Off
Sony 0x200c : 0 0 0
Sony 0x200d : 1
Face Info Offset : 94
Sony Date Time : 2011:08:04 15:30:20 <------- Fixed.
Faces Detected : 0
Face Info Length : 37
Color Reproduction : Standard
Color Temperature : 4294967295
Color Compensation Filter : -1
Scene Mode : n/a
Zone Matching : ISO Setting Used
Dynamic Range Optimizer : Standard
Image Stabilization : On
Color Mode : n/a
Macro : Off
Exposure Mode : Program
Focus Mode : Permanent-AF
AF Mode : Default
AF Illuminator : Auto
Sony 0xb045 : 0
Sony 0xb046 : 0
Quality : Normal
Flash Level : Unknown (128)
Release Mode : Normal
Sequence Number : Single
Anti-Blur : On (Shooting)
Sony 0xb04c : 1
Sony 0xb04d : 0
Long Exposure Noise Reduction : Unknown (2)
Dynamic Range Optimizer : Standard
Sony 0xb050 : 2
Sony 0xb051 : 0
Intelligent Auto : On
Sony 0xb053 : 0
White Balance : Auto
Sony 0x9400 : ...........��[...]
Sony 0x9401 : c���....��.����.�D��..�.0b0.L��e�e0E0.L��.[...]
Sony 0x9402 : .l���i.p!�!�����i���V�ie�Pp_��}@i�[...]
Sony 0x9403 : .��.i.��.榚~W��...���[...]
Sony 0x9404 : @�..�.�@}.��.�.0�K��pl.�V���.�..͵�QV..MV[...]
Sony 0x9405 : ..��.��Ģ�E5�..�..[...]
Sony 0x9406 : �������������������������������������������������������[...]
Sony 0x9407 : �������������������������������������������������������[...]
Sony 0x9408 : .#?A??AA��...�[...]
Sony 0x9409 : .[...]
Sony 0x940a : ��.��[...]
Sony 0x940b : �.�@�@�}�}t}.@�@PpFpNp�p��.�Ҋ_�9�~���v͔� ͸����^�.�[...]
Sony 0x940c : ������[...]
Sony 0x940d : �������������������������������������������������������[...]
Sony 0x940e : �������������������������������������������������������[...]
Sony 0xa100 : [...]
---- InteropIFD ----
Interoperability Index : R98 - DCF basic file (sRGB)
Interoperability Version : 0100
---- PrintIM ----
PrintIM Version : 0300
Print IM 0x0002 : 0x00000001
Print IM 0x0101 : 0x00000001
---- IFD1 ----
Compression : JPEG (old-style)
Image Description :
Make : SONY
Camera Model Name : DSC-WX7
Orientation : Horizontal (normal)
X Resolution : 72
Y Resolution : 72
Resolution Unit : inches
Modify Date : 2011:07:25 08:30:20 <------- Whoops, this one is still incorrect.
Thumbnail Offset : 13588
Thumbnail Length : 12400
Y Cb Cr Positioning : Co-sited
---- MPF0 ----
MPF Version : 0100
Number Of Images : 2
---- MPImage1 ----
MP Image Flags : Representative image, Dependent parent image
MP Image Format : JPEG
MP Image Type : Baseline MP Primary Image
MP Image Length : 1399500
MP Image Start : 0
Dependent Image 1 Entry Number : 2
Dependent Image 2 Entry Number : 0
---- MPImage2 ----
MP Image Flags : Dependent child image
MP Image Format : JPEG
MP Image Type : Large Thumbnail (full HD equivalent)
MP Image Length : 496491
MP Image Start : 1402364
Dependent Image 1 Entry Number : 0
Dependent Image 2 Entry Number : 0
---- Composite ----
Aperture : 2.6
Image Size : 2592x1944
Preview Image : (Binary data 496491 bytes, use -b option to extract)
Shutter Speed : 1/30
Thumbnail Image : (Binary data 12400 bytes, use -b option to extract)
Focal Length : 4.5 mm
Light Value : 5.7

As you can see from the output above, I found another tag that was also incorrect: ‘Modify Date’ in Group IFD1. So I tried to fix that:

fitzcarraldo@meshedgedx ~/ExifTool/Image-ExifTool-8.61 $ ./exiftool "-IFD1:ModifyDate+=0:00:10 07:00:0" Photos_04_08_2011/DSC00168.JPG
1 image files updated

Notice in the command that I prefixed the tag (ModifyDate) with the group (IFD1).

and I checked the photo’s meta data again:

fitzcarraldo@meshedgedx ~/ExifTool/Image-ExifTool-8.61 $ ./exiftool -a -u -g1 Photos_04_08_2011/DSC00168.JPG
---- ExifTool ----
ExifTool Version Number : 8.61
---- System ----
File Name : DSC00168.JPG
Directory : .
File Size : 1854 kB
File Modification Date/Time : 2011:08:11 06:33:50+01:00
File Permissions : rwxrwxrwx
---- File ----
File Type : JPEG
MIME Type : image/jpeg
Exif Byte Order : Little-endian (Intel, II)
Image Width : 2592
Image Height : 1944
Encoding Process : Baseline DCT, Huffman coding
Bits Per Sample : 8
Color Components : 3
Y Cb Cr Sub Sampling : YCbCr4:2:2 (2 1)
---- IFD0 ----
Image Description :
Make : SONY
Camera Model Name : DSC-WX7
Orientation : Horizontal (normal)
X Resolution : 72
Y Resolution : 72
Resolution Unit : inches
Modify Date : 2011:08:04 15:30:20
Y Cb Cr Positioning : Co-sited
---- ExifIFD ----
Exposure Time : 1/30
F Number : 2.6
Exposure Program : Program AE
ISO : 400
Sensitivity Type : Recommended Exposure Index
Recommended Exposure Index : 400
Exif Version : 0230
Date/Time Original : 2011:08:04 15:30:20
Create Date : 2011:08:04 15:30:20
Components Configuration : Y, Cb, Cr, -
Compressed Bits Per Pixel : 2
Brightness Value : 1.17734375
Exposure Compensation : 0
Max Aperture Value : 2.6
Metering Mode : Multi-segment
Light Source : Unknown
Flash : Off, Did not fire
Focal Length : 4.5 mm
User Comment :
Flashpix Version : 0100
Color Space : sRGB
Exif Image Width : 2592
Exif Image Height : 1944
File Source : Digital Camera
Scene Type : Directly photographed
Custom Rendered : Normal
Exposure Mode : Auto
White Balance : Auto
Digital Zoom Ratio : 1
Scene Capture Type : Standard
Contrast : Normal
Saturation : Normal
Sharpness : Normal
Lens Info : 4.5-22.5mm f/2.6-6.3
---- Sony ----
Panorama Full Width : 0
Panorama Full Height : 0
Panorama Direction : Right to Left
Panorama Crop Left : 0
Panorama Crop Top : 0
Panorama Crop Right : 0
Panorama Crop Bottom : 0
Panorama Frame Width : 0
Panorama Frame Height : 0
Panorama Source Width : 0
Panorama Source Height : 0
Sony 0x2000 : 0
Sony 0x2002 : 0
Sony 0x2003 : �������������������������������������������������������[...]
Contrast : 0
Saturation : -1
Sharpness : -1
Brightness : 0
Long Exposure Noise Reduction : n/a
High ISO Noise Reduction : n/a
HDR : Off
Sony 0x200c : 0 0 0
Sony 0x200d : 1
Face Info Offset : 94
Sony Date Time : 2011:08:04 15:30:20
Faces Detected : 0
Face Info Length : 37
Color Reproduction : Standard
Color Temperature : 4294967295
Color Compensation Filter : -1
Scene Mode : n/a
Zone Matching : ISO Setting Used
Dynamic Range Optimizer : Standard
Image Stabilization : On
Color Mode : n/a
Macro : Off
Exposure Mode : Program
Focus Mode : Permanent-AF
AF Mode : Default
AF Illuminator : Auto
Sony 0xb045 : 0
Sony 0xb046 : 0
Quality : Normal
Flash Level : Unknown (128)
Release Mode : Normal
Sequence Number : Single
Anti-Blur : On (Shooting)
Sony 0xb04c : 1
Sony 0xb04d : 0
Long Exposure Noise Reduction : Unknown (2)
Dynamic Range Optimizer : Standard
Sony 0xb050 : 2
Sony 0xb051 : 0
Intelligent Auto : On
Sony 0xb053 : 0
White Balance : Auto
Sony 0x9400 : ...........��[...]
Sony 0x9401 : c���....��.����.�D��..�.0b0.L��e�e0E0.L��.[...]
Sony 0x9402 : .l���i.p!�!�����i���V�ie�Pp_��}@i�[...]
Sony 0x9403 : .��.i.��.榚~W��...���[...]
Sony 0x9404 : @�..�.�@}.��.�.0�K��pl.�V���.�..͵�QV..MV[...]
Sony 0x9405 : ..��.��Ģ�E5�..�..[...]
Sony 0x9406 : �������������������������������������������������������[...]
Sony 0x9407 : �������������������������������������������������������[...]
Sony 0x9408 : .#?A??AA��...�[...]
Sony 0x9409 : .[...]
Sony 0x940a : ��.��[...]
Sony 0x940b : �.�@�@�}�}t}.@�@PpFpNp�p��.�Ҋ_�9�~���v͔� ͸����^�.�[...]
Sony 0x940c : ������[...]
Sony 0x940d : �������������������������������������������������������[...]
Sony 0x940e : �������������������������������������������������������[...]
Sony 0xa100 : [...]
---- InteropIFD ----
Interoperability Index : R98 - DCF basic file (sRGB)
Interoperability Version : 0100
---- PrintIM ----
PrintIM Version : 0300
Print IM 0x0002 : 0x00000001
Print IM 0x0101 : 0x00000001
---- IFD1 ----
Compression : JPEG (old-style)
Image Description :
Make : SONY
Camera Model Name : DSC-WX7
Orientation : Horizontal (normal)
X Resolution : 72
Y Resolution : 72
Resolution Unit : inches
Modify Date : 2011:08:04 15:30:20 <------- Notice it is now correct.
Thumbnail Offset : 13588
Thumbnail Length : 12400
Y Cb Cr Positioning : Co-sited
---- MPF0 ----
MPF Version : 0100
Number Of Images : 2
---- MPImage1 ----
MP Image Flags : Representative image, Dependent parent image
MP Image Format : JPEG
MP Image Type : Baseline MP Primary Image
MP Image Length : 1399500
MP Image Start : 0
Dependent Image 1 Entry Number : 2
Dependent Image 2 Entry Number : 0
---- MPImage2 ----
MP Image Flags : Dependent child image
MP Image Format : JPEG
MP Image Type : Large Thumbnail (full HD equivalent)
MP Image Length : 496491
MP Image Start : 1402364
Dependent Image 1 Entry Number : 0
Dependent Image 2 Entry Number : 0
---- Composite ----
Aperture : 2.6
Image Size : 2592x1944
Preview Image : (Binary data 496491 bytes, use -b option to extract)
Shutter Speed : 1/30
Thumbnail Image : (Binary data 12400 bytes, use -b option to extract)
Focal Length : 4.5 mm
Light Value : 5.7

Now I was confident that I could fix all the incorrect tags, so I again copied the directory containing the original files into the ExifTool directory and used the commands below to change the date and time from e.g. 2011:07:25 02:19:03 to 2011:08:04 09:19:03, i.e. I wanted to: a) add 7 hours to the EXIF times to make them correct for the city I was in instead of UK BST; b) add 10 days to the EXIF dates to fix the incorrect date (2011:07:25) that was set in my camera to the correct date (2011:08:04).

$ cd ~/ExifTool/Image-ExifTool-8.61
$ ./exiftool "-SonyDateTime+=0:00:10 07:00:0" Photos_04_08_2011/
$ ./exiftool "-DateTimeOriginal+=0:00:10 07:00:0" Photos_04_08_2011/
$ ./exiftool "-CreateDate+=0:00:10 07:00:0" Photos_04_08_2011/
$ ./exiftool "-IFD0:ModifyDate+=0:00:10 07:00:0" Photos_04_08_2011/
$ ./exiftool "-IFD1:ModifyDate+=0:00:10 07:00:0" Photos_04_08_2011/

Finally, as ExifTool automatically creates a back up file before changing EXIF data in a photo file, I deleted the back up files after I had checked that the EXIF data in the new files contained the correct dates and times:

$ rm ./Photos_04_08_2011/*_original

Yet another great tool to add to my toolbox.

Converseen, a GUI batch image converter and resizer using Qt4 and ImageMagick

I normally use ImageMagick on the command line to convert and/or resize my photographs, and the two commands I use are convert and mogrify. However, I learned recently of Converseen, a GUI tool for batch conversion and resizing of image files which is a front-end for ImageMagick. Although it’s easy enough to use the command line, a GUI tool does save having to remember the command syntax each time, so I thought I’d install Converseen in Gentoo. Converseen is not in the main Portage tree, but I found an ebuild for version 0.2 from the qting-edge overlay. However, rather than add the overlay I decided instead to use a local overlay to install Converseen, which is currently at version 0.4.1, and the procedure I used is given below.

1. I downloaded to ~/Desktop/ the ebuild file from http://gitorious.org/gentoo-qt/qting-edge/blobs/master/media-gfx/converseen/converseen-0.2.ebuild and renamed it as converseen-0.4.1.ebuild, which contains the following:

# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI="2"

LANGSLONG="it_IT pl_PL"

inherit qt4-edge

MY_P=${PN}-${PV}

DESCRIPTION="GUI image conversion tool based on imagemagick"
HOMEPAGE="http://converseen.sourceforge.net"
SRC_URI="mirror://sourceforge/${PN}/${MY_P}.tar.bz2"

LICENSE="GPL-3"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="debug"

DEPEND="x11-libs/qt-gui:4
|| ( media-gfx/graphicsmagick[imagemagick] media-gfx/imagemagick )"
RDEPEND="${DEPEND}"

S="${WORKDIR}/${MY_P}"

DOCS="README"

src_prepare() {
qt4-edge_src_prepare

sed -i -e "s!/usr/lib!/usr/$(get_libdir)!" ${PN}.pro \
|| die "sed libdir failed"

local ts_files=
for lingua in ${LINGUAS}; do
for a in ${LANGSLONG}; do
if [[ ${lingua} == ${a%_*} ]]; then
ts_files="${ts_files} loc/${PN}_${a}.ts"
fi
done
done
local qm_files="${ts_files/.ts/.qm}"

sed -e '/^ loc/d' \
-e "s!\(TRANSLATIONS += \).*!\1${ts_files}!" \
-e "s!\(translations\.files = \).*!\1${qm_files}!" \
-i ${PN}.pro || die "sed translations failed"
}

2. I downloaded to ~/Desktop/ the file qt4-edge.eclass, which contains the following:

# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

# @ECLASS: qt4-edge.eclass
# @MAINTAINER:
# Ben de Groot ,
# Markos Chandras ,
# Davide Pesavento ,
# Dominik Kapusta
# @BLURB: Experimental eclass for Qt4 packages
# @DESCRIPTION:
# This eclass contains various functions that may be useful when
# dealing with packages using Qt4 libraries. Requires EAPI=2.

inherit base eutils multilib qt4-r2 toolchain-funcs

export XDG_CONFIG_HOME="${T}"

qt4-edge_pkg_setup() {
if [[ -z ${I_KNOW_WHAT_I_AM_DOING} ]]; then
ewarn
ewarn "Please file bugs on bugs.gentoo.org and prepend the summary with"
ewarn "[qting-edge]. Alternatively, contact qt@gentoo.org."
ewarn "Thank you for using qting-edge overlay."
ewarn
ebeep 5
fi
}

qt4-edge_src_unpack() {
debug-print-function $FUNCNAME "$@"

qt4-r2_src_unpack "$@"
}

# @FUNCTION: qt4-edge_src_prepare
# @DESCRIPTION:
# Default src_prepare function for packages that depend on qt4. If you have to
# override src_prepare in your ebuild, you should call qt4-edge_src_prepare in it,
# otherwise autopatcher will not work!
qt4-edge_src_prepare() {
debug-print-function $FUNCNAME "$@"

qt4-r2_src_prepare
}

# @FUNCTION: qt4-edge_src_configure
# @DESCRIPTION:
# Default src_configure function for packages that depends on qt4. If you have to
# override src_configure in your ebuild, call qt4-edge_src_configure in it.
qt4-edge_src_configure() {
debug-print-function $FUNCNAME "$@"

qt4-r2_src_configure
}

# @FUNCTION: qt4-edge_src_compile
# @DESCRIPTION:
# Default src_compile function for packages that depends on qt4. If you have to
# override src_compile in your ebuild (probably you don't need to), call
# qt4-edge_src_compile in it.
qt4-edge_src_compile() {
debug-print-function $FUNCNAME "$@"

qt4-r2_src_compile
}

# @FUNCTION: qt4-edge_src_install
# @DESCRIPTION:
# Default src_install function for qt4-based packages. Installs compiled code,
# documentation (via DOCS variable) and translations (via LANGS and
# LANGSLONG variables).
qt4-edge_src_install() {
debug-print-function $FUNCNAME "$@"

qt4-r2_src_install

# install translations # hwoarang: Is this valid for every package???
# need to have specified LANGS or LANGSLONG for this to work
[[ -n "${LANGS}" || -n "${LANGSLONG}" ]] && prepare_translations
}

# Internal function
_do_qm() {
debug-print-function $FUNCNAME "$@"
[[ $# -ne 2 ]] && die "$FUNCNAME requires exactly 2 arguments!"

local transfile="$(find "${1}" -type f -name "*${2}".qm)"
if [[ -e ${transfile} ]]; then
INSDESTTREE="/usr/share/${PN}/${1#${S}}" \
doins "${transfile}" \
|| die "failed to install ${2} translation"
else
eerror
eerror "Failed to install ${2} translation. Contact eclass maintainer."
eerror
die "Failed to install translations"
fi
}

# @VARIABLE: TRANSLATIONSDIR
# @DESCRIPTION: Translations directory. If not set, ${S} will be used

# @FUNCTION: prepare_translations
# @DESCRIPTION:
# Choose and install translation files. Normally you don't need to call
# this function directly as it is called from qt4-edge_src_install.
prepare_translations() {
debug-print-function $FUNCNAME "$@"

# Find translations directory
# Changed default to . - crazy upstreams :)
local roottrdir="${TRANSLATIONSDIR:-${S}}" trdir=.
for dir in lang langs translations; do
[[ -d ${roottrdir}/${dir} ]] && trdir="${roottrdir}/${dir}"
done

local lang=
for lang in ${LINGUAS}; do
for x in ${LANGS}; do
[[ ${lang} == ${x%_*} ]] && _do_qm "${trdir}" ${x}
done
for x in ${LANGSLONG}; do
[[ ${lang} == ${x} ]] && _do_qm "${trdir}" ${x}
done
done
}

EXPORT_FUNCTIONS pkg_setup src_unpack src_prepare src_configure src_compile src_install

3. I synchronised the Portage main tree’s ebuilds on my PC with those in the repositories:

# emerge --sync

4. I made sure that /etc/make.conf has the following lines at the end of the file:

PORTDIR_OVERLAY="${PORTDIR_OVERLAY} /usr/local/portage/"
ACCEPT_LICENSE="*"

5. I created the necessary directories in the local overlay:

# mkdir -p /usr/local/portage/media-gfx/converseen
# mkdir -p /usr/local/portage/eclass

6. I made sure Portage would not nag me about a missing name for my local overlay:

# mkdir /usr/local/portage/profiles
# echo "local_overlay" > /usr/local/portage/profiles/repo_name

7. I copied the converseen ebuild and eclass file into the relevant directories:

# cp /home/fitzcarraldo/Desktop/converseen-0.4.1.ebuild /usr/local/portage/media-gfx/converseen/
# cp /home/fitzcarraldo/Desktop/qt4-edge.eclass /usr/local/portage/eclass/

8. I generated the manifest for the package:

# cd /usr/local/portage/media-gfx/converseen/
# ebuild converseen-0.4.1.ebuild manifest

9. I merged the package:

# emerge -1v converseen

An entry for Converseen was added to Kickoff > Applications > Graphics, and I can either use that to launch it or I can launch it from the command line by entering the command converseen. The user interface is easy to master, and I’ve already put Converseen to use at work and at home. Overall, then, a useful addition to my KDE toolkit.

EDIT (July 23, 2012}: There is an ebuild for Converseen in Portage these days, so use that instead to install Converseen.

Follow

Get every new post delivered to your Inbox.

Join 50 other followers