Friday, 20 February 2009

EEE PC as Photo Frame - adding music

It would be nice to add some background music while watching a slideshow (see my previous post about making a slideshow script). After playing with that script I ended up with the following version:
#!/bin/sh

xset s off -dpms
mpg321 --random --quiet /path/to/music/files/*.mp3 &
qiv -sfmir -d 8 /path/to/picture/files/*.JPG
killall mpg321
xset s on +dpms
You should obviously replace "/path/to/music/files/" and "/path/to/picture/files/" to your actual locations.

Below is the short explanation of the changes.
I noticed that after 20 minutes the screen went blank, although screen-saver feature was disabled. The command
xset q
revealed, that DPMS (Display Power Management Signaling) feature was enabled, so I changed the first command in the script as follows:
xset s off -dpms
to switch DPMS totally off. The last command re-enables this feature.

Using my Package Finder tool I found that my EEE PC had pre-installed command-line audio player, called mpg321. It appeared that this program was quite suitable for our purposes.
mpg321 --random --quiet /path/to/music/files/*.mp3 &
The above command launches mpg321 player and tells it to play all mp3 files in the given folder in random order; the --quiet option supresses unnecessary text output. The "&" at the end tells the OS not to wait for the player finished its work, but go to the next line of the script.

When we terminated qiv, playing the slideshow, we also have to stop music. The command
killall mpg321
does the trick.

That's all.

Sunday, 15 February 2009

Asus EEE PC 701 as Digital Photo Frame



Its quite easy to turn your EEE PC into digital photo frame. To make this possible one needs two things.
Firstly a program, which would present the photos in a full-screen slideshow mode.
Secondly the screen saver (or rather power saver) feature should be temporarily disabled, to avoid getting black screen after 5 mins of inactivity. Obviously the laptop must be powered from the mains.

After some googling I found the program, which I think fits quite well for slideshow. It's called qiv, Quick Image Viewer. Because EEE PC has a lot of software pre-installed, it worth to see, if this program is already on your computer or not.

1. Open the terminal (Ctrl+Alt+T) and type:
qiv --help
If you see a lot of output with explanations of possible options and available keys, you can skip the next step, otherwise you have to install it.

2. Type in the terminal:
sudo apt-get install qiv
The above command (apt-get) installs the mentioned package (qiv) into your computer, and requires administrative rights to perform this task (sudo).
If the above does not work, see this tutorial about Adding Additional Software Repositories
.
Unfortunately I am not sure what repository qiv came from.
Note: If you are in doubt what any terminal command is intended to, say "sudo" as above, type "man sudo", which will show manual pages for the given command; to scroll down use Space key, to terminate the manual press Ctrl+Z. Other possible ways are to type the command with -h or --help options, or find its description in the Internet with Google.

3. Put the pictures, you want to present, in a single folder. You may also wish to scale them down, to save some disk space. In my case the photos were exported (with scaling down to 800 pixels) from Picasa to
/home/user/MMC-SD/partition1/DCIM/Starred-Photos/
As you may guess the above string points to the folder, located on the 1GB SD card, which was earlier used with my digital camera. Now this card is an extra storage for EEE PC.

4. Again, in the terminal type the following (change my folder to the path to your picture location, and keep in mind that Linux commands are case-sensitive):
qiv -sfmir -d 8 /home/user/MMC-SD/partition1/DCIM/Starred-Photos/*.JPG
and see, what is going on. Ideally you should get your slideshow working. To terminate it, press ESC . If the above command does not work, first type "qiv --help", to be sure qiv is really installed, then check carefully your path to pictures.
Brief explanation the above command:
  • qiv - calls Quick Image Viewer
  • -sfmir - is actually five options; -s is for slideshow; -f is for full-screen mode; -m is for preserving images aspect ratio and zooming; -i is to disable status bar, and -r is for random order
  • -d 8 - means 8 secs delay between images; you may want to change this value
While watching the slideshow, you can use the following keys:
  • space - to get the next picture
  • esc - to terminate the slideshow
  • s - to pause/continue slideshow.
If you do nothing, the screen should go black after 5 minutes, and this is the next problem to solve.

There is no running screen-saver on EEE PC by default, but there are some low-level power saving options. One of them is an option in xorg.conf file, which tells to set the screen black, if there were no keyboard/mouse activity for 5 mins. To avoid this type the following command:
xset s off
and check you can watch your slideshow endlessly. If all the above works, we should now put it all together.

5. Open a text editor, to do it type in the terminal:
kate
6. Enter the following set of commands:
#!/bin/sh
xset s off
qiv -sfmir -d 8 /path/to/your/pictires/*.JPG
xset s on
In the above sample change the third line with your command from step 4. First line says it is the script, second switches blank screen off, third is actually your slideshow and last restores power saving settings.

7. Click File -> Save As.. and save this file as "slideshow.sh" (without quotes).

8. Close the text editor

9. Type in the terminal:
sudo chmod +x slideshow.sh

The above command makes your "slideshow.sh" file executable.

10. Type:
./slideshow.sh

and check that everything works.

11. Type:
sudo mv slideshow.sh /usr/local/bin/
This command moves your file from your home folder to a system folder for executable files, (not supplied by the OS vendor).

12. Type:
cd /usr/local/bin

This will change your current active folder and then type:
sudo chmod +x slideshow.sh
to make the file executable again.

13. Using Launcher Tools create a new launcher in your favourite folder, like shown in the picture:



That's all!

Enjoy, but avoid using it when the computer is on battery.

TODO: Add some music.

Saturday, 31 January 2009

Asus EEE PC as E-Book reader (option 2)

Browsing through the menu in Full Desktop Mode I noticed the presence of the installed E-Book reader application at
Launch -> Xandros -> Office -> E-book reader

The application called itself FBReader and proved to be quite useful for HTML and plain texts. Surely to get the most of it the program needs to be a little bit customized.



First, add it to the list of programs, available in Easy Mode. To do this I used the tool called Launcher Tools, so the procedure was straight-forward and a new launcher "Book Reader" appeared in my Favorites tab.

The following few simple steps will allow you to make reading books more comfortable.
  1. Launch FBReader and click Preferences button

  2. Switch to Scrolling tab, select Options for Large Scrolling and choose Scrolling Mode = No Overlapping
  3. Switch to Margins tab and set your preferred margins, my choice was:
    • Left and Right margins = 8
    • Top margin = 0
    • Bottom margin = 4

  4. And now the most important thing: switch to Keys tab
  5. Click on Action for Key field, press RightArrow key, located on the right bottom edge of the keyboard, and select Large Scroll Forward action for it
  6. Click on Action for Key field again, press LeftArrow key and choose Large Scroll Backward action, like this:

Click OK or Apply.
That's all.

After the above has done, you can simply scroll pages down and up with RightArrow and LeftArrow keys respectively. You can obviously set some other options, like fonts (Styles tab) and text alignment (Format tab).

Unfortunately, FBReader does not work well for me. The reason is that I read texts in Russian sometimes, which are formatted incorrectly by FBReader - it squeezes some spaces between words to none, so option 1 (see my previous post) is still useful for me. Hopefully once I will find the way to fix this.

Saturday, 17 January 2009

Using Asus EEE-PC as E-Book reader

Lightweight and compact sub-notebook Asus EEE-PC is an ideal candidate to be used as an e-book reader. This how-to explains the simple steps which will make reading the real pleasure. I did it for my EEE-PC 701 with 800 x 480 screen resolution and Xandros pre-installed, but these recommendations can be easily adapted to any other sub-notebook model.

To convert the notebook into e-book reader we should perform some text changes to fill the whole screen and avoid scrolling. That means the text must be formatted into pages of the same size as your screen.

Let see how this could be done. As the example I will convert the book "All around the Moon" by Jules Verne, found on Project Gutenberg web site (http://www.gutenberg.org/files/16457/16457-h/16457-h.htm)

1. Open the text in your web-browser. The HTML format would be the best option, but with its absence plain text is fine as well (it will make the final file smaller). Detailed steps are as follow:
  • assuming that your notebook has already connected to the Internet, click Internet tab
  • click Web icon, this will start Firefox Web browser
  • copy the above link to your browser's address field or navigate to another book, if you like

2. Select the whole text (Ctrl+A) and Copy it into Clipboard (Ctrl+C) (do not close the browser yet).

3. Open OpenOffice Writer and paste (Ctrl+V) the text into empty document.
  • click "Show Desktop" icon on the taskbar or minimize the browser
  • switch to Work tab
  • click Documents icon, this will launch OpenOffice Writer
  • click inside the empty document (the vertical cursos should start blinking) and press Ctrl+V

4. Go to Format -> Page menu and set the new page size. Click Page tab and make the following changes:
Format: User
Width : 40 pi (picas) (it is 6.67 in or 16.9 cm)
Height: 24 pi (it is 4 in or 10.2 cm)
All margins (Left, Top, Right, Bottom): 1 pi (0.17 in or 0.42 cm)

Click OK.

Default Measurement Units can be set at Tools -> Options -> OpenOffice Writer -> General. You may obviously round the values in your preferred units, keeping approximately the same rate as 800 x 480.

5. Go to File -> Export As PDF and save the book in "My Documents/My EBooks" folder or anywhere you like.

6. Open Acrobat Reader, load your book, hide taskbar at the bottom of your screen, then press Ctrl+L to get to the full-screen mode and enjoy.

Some recommendations.

1. Between steps 4 and 5 I would change font for "Body text" style to something, what is easier to read, say DejaVu Serif (the default font can be set at Tools -> Options -> OpenOffice Writer -> Basic Font).
2. I would also suggest replacing heavy Acrobat Reader to Evince, this will free about 200 MB of the disk space.

If you have another laptop with different screen size, you will have to re-calculate your page width and height (step 4) to match your screen.

Tuesday, 22 July 2008

Playing with HDRI

High Dynamic Range Images (HDRI - Wikipedia article) became very popular recently, and I also experimented with this technique. I don't personally like unrealistic pictures you can often see in the Internet, if you search for "HDR" or "HDRI", so I usually try to preserve natural look.

To make a HDR image one has to make at least two shots of the same scene with different exposure. Many cameras have "auto-bracketing" mode, what makes this part of work quite simple. My camera (Panasonic Lumix DMC-FZ5 - DPreview) can take three shots with maximum -1EV and +1EV exposure range from the base settings. Below is the cuts from three original photos I made with such auto-bracketing. The scene is Anchor Bay at Tawharanui Regional Park, some 80 km north from Auckland, New Zealand.



ISO: 80
Shutter speed: 1/500, 1/250, 1/125
Aperture: f/4.0
Focal length: 6.0 mm (36 mm for 35 mm film)
Metering mode: Matrix
Tripod and polarizing filter.

Polarizing filter reduced reflections from water surfaces and brightness of the sky.

I cut off a small piece from original photos, which includes both very bright (clouds) and darkest parts (black rocks) of the scene. The source files were in JPEG format, as this is the only format my camera allows for auto-bracketing mode.

I loaded all three files into Qtpfsgui (http://qtpfsgui.sourceforge.net/) and created a HDR image using default program settings. Saved the result as Tawharanui.hdr and clicked Tonemap the HDR. This is the most creative and time-consuming part of work with Qtpfsgui, and the goal is to get TWO tone-mapped LDR (8 bits per channel) images: one is as good as possible and another is produced by the Fattal algorithm to improve the first (thanks to Angela Lobefaro for her post to this blog). Qtpfsgui provides 8 different algorithms for tone-mapping; I found Drago, Durand and both Reinhard are mostly suitable for first, realistic looking image, while Fattal or Mantiuk are better for "impressionist" image, aimed to pop-up first one.

In this particular case the first image was made by Reinhard'05 with the following parameters:
pregamma: 1
brightness: -10
chromatic adaptation: 1.26
light adaptation: 0.5



The second image was by Fattal with:
pregamma: 1
alpha: 0.1
beta: 0.8
saturation:1
noise reduction: 0.04
These parameters are actually default ones, except noise reduction; this was carefully adjusted to keep as many details as possible.



Obviously, both images must have the same size and should be saved on the hard drive.

Then I launched GIMP (GNU Image Manipulation Program - http://www.gimp.org/) and opened both of the images here. First steps are simple: make the "Fattal" image active, Select All (Ctrl+A) and Copy (Ctrl+C). Then switch to another image and Paste (Ctrl+V); then go to Layer -> New Layer (Shift+Ctrl+N). Now go to Channels, Paths, Undo, Layers dialog and click on layers tab (Ctrl+L). You will see two layers; Pasted Layer which holds "Fattal" image, is active and actually hides another layer (Background with "Reinhard" image) beneath. Change its Mode to Overlay and shift Opacity down to 70...30 until you think your picture is good enough. That's all.

This is not the best way, because depending on your pictures you can get better results, playing with these settings - try other layer modes like Hard Light, Soft Light, Darken or Lighten Only, Burn or Value with different Opacity settings. You can also adjust your images before blending layers.

For my picture I performed the following actions:
1. Made Background layer invisible (clicked on the eye icon on the Layers dialog)
2. Went to Colors -> Levels and moved the central slider to 0.75; this made my "impressionist" layer darker and "richer"
3. Turned back on visibility of the Background layer, still keeping Pasted Layer as selected (active)
4. Changed layer mode to Value and adjusted opacity to about 0.50
5. Cropped
6. Saved As...

Wednesday, 27 February 2008

Gnome Debian Package Finder

Gnome Package Finder is my first project in Lazarus released to the public. It is also my first published program for Ubuntu Linux or other distributions, using Debian packages.

Unlike Synaptic Package Manager, which is the main tool in Ubuntu to deal with installed and avaialble from repositories (Software Sources) packages, Gnome Package Finder only provides information about packages, it can neither install nor remove the package, and because of this, it does not require administative rights to work. It also works about twice faster for the same search.

Gnome Package Manager allows to search through package names, their short or long descriptions for the given model. The matching packages are shown in the list, which indicates also the state of the installed packages. Another possibility is to search for a file name inside the packages. This search takes much longer and the output contains package names and the full path to the matching files, in case they were installed.

When one got the list of packages, for every one in the list common information about the package can be obtained, along with its dependencies and the list of files, this package would install.



Keyboard shortcuts provide an easy way to navigate and perform all operations without involving the mouse. The help system covers most of what you may want to know about Gnome Package Finder.

The installation binary package as well as the source files can be downloaded from:
http://www.gtk-apps.org/.

It is released under the terms of Gnu General Public Licence (GPL).

Friday, 30 November 2007

How to copy Picasa Albums from Windows to Linux installation.

Since long ago Picasa for Windows had a nice feature called Album, which allowed organizing photos logically, rather than chronologically. Thanks to Google developers this feature is now available in Picasa Version 2.7.0 Build 37.3607 for Linux, and I started thinking about recovery my old missed albums, I had created years ago. Below are the steps I made to achieve this goal.

Disclaimer: Picasa is designed to prevent any manual changes in its internal files. Although it should not damage your data and picture files, I would suggest to backup the whole ~/.picasa folder with its sub-folders before you started.

It's assumed that:
1. you have both Picasa for Windows and Linux installed;
2. all your old photos, included in the albums, are presented in Picasa for Linux (they can be moved to Linux partition, but the folder structure should remain the same in general);
3. the goal is to copy Picasa Albums from Windows to Linux without re-creating them manually;
4. we work in Linux and have access to Windows partition with old Picasa files.
5. you know how to use Picasa and other tools involved, so I tell you what to do rather than what key to press.

Abstract

Picasa keeps information about albums in separate files located
in Windows:
[windows_drive]\Documents and Settings\[user_name]\Local Settings\Application Data\Google\Picasa2Albums\25a8e096c46096317ee356c5246889b3

in Linux:
~/.picasa/drive_c/Documents and Settings/[user_name]/Local Settings/Application Data/Google/Picasa2Albums/75adfd2e119b03b77391bf21408baf92

where
[windows_drive] is where Windows was installed, usually C:

[user_name] is user name

~ - is your home folder

25a8e096c46096317ee356c5246889b3 and 75adfd2e119b03b77391bf21408baf92 are folder names, generated by Picasa (on my computer); they will differ on your machine, I will call them [album_folder_name].

Each album is a single XML file, called like 8c5a839b4c1b71cfb65d100652642063.pal, I will call it [album_file.pal].

Next to Picasa2Albums is another folder Picasa2 with lots of sub-folders and files, do not touch them.

I did everything using default Gnome GUI tools, like Nautilus and GEdit, without using terminal and root access.

Some information used in the explanation below was found at:
http://forensicir.blogspot.com/2007/07/picasa.html


Steps

1. Open you favourite file manager (Nautilus) and go to
[windows_drive]/Documents and Settings/[user_name]/Local Settings/Application Data/Google/Picasa2Albums/[album_folder_name]
(I have changed backslashes to slashes as we work in Linux)

2. Select all [album_files.pal] and make Copy (Ctrl+C, for example)

3. Go to /tmp and create a new folder, called, for example, PicasaAlbums, then copy your files into that folder (Ctrl+V).

4. Start Picasa for Linux and create a dummy album, which includes at least one photo, same as in the old album, you are going to move. We need this step, because the location of the same file differs between Windows and Linux, and we have to find this difference.
If you moved your photos, included in the albums, so their relative locations have also changed, you have to include more than one picture from different locations to your dummy album.

5. Close Picasa.

6. Go to
~/.picasa/drive_c/Documents and Settings/[user_name]/Local Settings/Application Data/Google/Picasa2Albums/[album_folder_name]
and double click on the [album_file.pal] you have just created. This should open the file in your default text editor (GEdit in my case).

7. Go to
/tmp/PicasaAlbums
and double click on the [album_file.pal], which should contain the same pictures. It will be open in the text editor as well.

If I created a dummy album with two files in it, it would look like this in Linux:
(I have changed angle brackets to square brackets to prevent interference with HTML)

[picasa2album]
[dbid]75adfd2e119b03b77391bf21408baf92[/dbid]
[albumid]91339fd27a046527764eab636a88273d[/albumid]
[property name="token" type="string" value="]album:91339fd27a046527764eab636a88273d"]
[property name="unread" type="flag" value="0"]
[property name="description" type="string" value=""]
[property name="uid" type="string" value="91339fd27a046527764eab636a88273d"]
[property name="location" type="string" value=""]
[property name="name" type="string" value="Dummy"]
[property name="date" type="real64" value="38997.427211"]
[property name="category" type="num" value="0"]
[files]
[filename]$My Documents\PicasaDocuments\Photography\10-October-2006\07102006\P1020492.JPG[/filename]
[filename]$My Documents\PicasaDocuments\Photography\10-October-2006\07102006\P1020466.JPG[/filename]
[/files]
[/picasa2album]

And the beginning of one of my old album with the same files, as it was in Windows:

[picasa2album]
[dbid]25a8e096c46096317ee356c5246889b3[/dbid]
[albumid]55273da2ae671b7ad3fa26365dc9f5eb[/albumid]
[property name="victorrull_lh" type="num64" value="1949171729"]
[property name="unread" type="flag" value="0"]
[property name="uid" type="string" value="55273da2ae671b7ad3fa26365dc9f5eb"]
[property name="token" type="string" value="]album:55273da2ae671b7ad3fa26365dc9f5eb"]
[property name="name" type="string" value="Horse Riding"]
[property name="location" type="string" value="Helensville, Muriwai Beach"]
[property name="description" type="string" value="Horse riding and Muriwai Beach"]
[property name="date" type="real64" value="38997.427211"]
[property name="category" type="num" value="0"]
[files]
[filename][C]\Data\Photography\Panasonic Lumix DMC-FZ5\10-October-2006\07102006\P1020492.JPG[/filename]
[filename][C]\Data\Photography\Panasonic Lumix DMC-FZ5\10-October-2006\07102006\P1020466.JPG[/filename]
.....

I moved these two files, after I had abandoned Picasa for Windows, but now we can find out the difference:
[C]\Data\Photography\Panasonic Lumix DMC-FZ5\10-October-2006\07102006\P1020492.JPG
$My Documents\PicasaDocuments\Photography\10-October-2006\
07102006\P1020492.JPG

8. Switch to the file in /tmp/PicasaAlbums, and call Replace dialogue. Fill in the following fields:
Search For: [C]\Data\Photography\Panasonic Lumix DMC-FZ5
Replace With: $My Documents\PicasaDocuments\Photography
(change the above samples to your real models)
and click Replace All.

9. Make sure everything has changed properly. Save the file. Repeat two last steps, if you need more changes.

10. Copy the SINGLE [album_file.pal] you have just edited from /tmp/PicasaAlbums to

~/.picasa/drive_c/Documents and Settings/[user_name]/Local Settings/Application Data/Google/Picasa2Albums/[album_folder_name]

Important Notice: As I have already mentioned Picasa prevents modification of its internal files. The folder Picasa2 contains a lot of binary files, which keep information about existing albums, including their Hash-sums. But there is a weakness in this protection - if one adds a single album file to the folder, Picasa will accept it. If one adds two or more files at once, or tries to edit existing album file, Picasa will not allow this. Usually it just removes those files, but I am afraid there can be more serious consequences. Also do not try to manipulate with these files while Picasa is running, I neither did it myself nor want you were the first victim of this.

11. Launch Picasa and make sure the new album has appeared in the Albums section.

12. Close Picasa and repeat the steps 7...11 for other album files.

That's all. This worked for me (Picasa Version 2.7.0 Build 37.3607, 0 for Linux) and I hope this will work for you.