Tuesday, 24 March 2009

EEE PC as Photo Frame - Slideshow selection dialogue

After your slide show is up and running you may want to add some improvements - the ability to create as many slideshows as you like and choose one as you clicked on the icon.



To make this possible our slideshow script should be able to:
  1. find slideshows located under some base folder
  2. display the list where we can choose one from
  3. pass our choice to the viewer program (qiv)
The resulting script is shown below:

#!/bin/sh
ssPath="/home/user/MMC-SD/partition1/DCIM/"
cd $ssPath
ssList=$(ls -dx *)
ssFolder=$(zenity --list --title="Choose Slideshow" --column="Folder" $ssList)
if [ -n "$ssFolder" ] ; then
xset s off -dpms
# mpg321 --random --quiet /home/user/MMC-SD/partition1/MISC/audio/*.mp3 &
qiv -sfmir -d 8 $ssPath$ssFolder/*
# killall mpg321
xset s on +dpms
fi
As you may have noticed I commented the commands related to background music.

To implement new features, mentioned above, I introduced three variables:
  • ssPath - my base folder, each its sub-folder is a slideshow (you must change its value to your actual location)
  • ssList - the list of all found slideshows
  • ssFolder - what I chose from ssList
Look at the picture below.



It shows a file manager, which displays my directory tree. The address bar shows my base folder - "/home/user/MMC-SD/partition1/DCIM/", this value is directly assigned to ssPath.
ssPath="/home/user/MMC-SD/partition1/DCIM/"
The folder DCIM contains only sub-folders, every one of them is a separate slideshow. The command
ls -dx *
lists them in a single row, and this is assigned to ssList:
ssList=$(ls -dx *)

Then I use the command zenity which displays a nice dialog, as shown on the first picture. The result (my choice) is assigned to ssFolder:
ssFolder=$(zenity --list --title="Choose Slideshow" --column="Folder" $ssList)
Zenity was installed on my computer by default, so I think it should be same on yours.

The next step is to make sure ssFolder is not empty, so the rest of the script is executed if the below command returned TRUE:
if [ -n "$ssFolder" ] ; then
The rest is pretty much similar to what I explained in the previous post. The only difference is this command:
qiv -sfmir -d 8 $ssPath$ssFolder/*
qiv should play all files in my selected folder ($ssFolder), attached to the full path (the base folder ssPath). You should avoid having non-image files in that folder, or you may try -n option, which tells qiv to filter files by their magic numbers instead of extensions.

Enjoy!

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).