Wednesday, May 28, 2008

Linux Toolbox: pdftk

(from the man page) If PDF is electronic paper, then pdftk is an electronic staple-remover, hole-punch, binder, secret-decoder-ring, and X-Ray-glasses. Pdftk is a simple tool for doing everyday things with PDF documents. Use it to:
  • Merge PDF Documents
  • Split PDF Pages into a New Document
  • Rotate PDF Documents or Pages
  • Decrypt Input as Necessary (Password Required)
  • Encrypt Output as Desired
  • Fill PDF Forms with X/FDF Data and/or Flatten Forms
  • Generate FDF Data Stencil from PDF Forms
  • Apply a Background Watermark or a Foreground Stamp
  • Report PDF Metrics such as Metadata and Bookmarks
  • Update PDF Metadata
  • Attach Files to PDF Pages or the PDF Document
  • Unpack PDF Attachments
  • Burst a PDF Document into Single Pages
  • Uncompress and Re-Compress Page Streams
  • Repair Corrupted PDF (Where Possible)
Get it on Fedora:
> yum install pdftk

Note Unfortunately pdftk was removed from the Fedora repository due to a license issue that prevented it from being used in nuclear facilities. Yeah, right. Okay. Whatever!
You have to recompile it from the sources or... grab the final product from someone who already did it: Professor Kriehn's Fedora Repository!

Tuesday, May 27, 2008

Exporting the Graphical Display

If you need to open a graphical application on a Linux box A and see it on another one B (i.e. exporting the DISPLAY) there is one easy way if you log in from B to A with SSH:

> ssh -X -Y user@host.domain

Then you can start a graphical application on A from the remote session on B and see the output on B.

Monday, May 12, 2008

Installing Linux on the Sony Vaio PCG FX-220

I bought this notebook in August 2001. I will never buy a Sony again despite the pros for the following reasons:
  • Bad user support. If you have a problem, you have to pay to be able to speak with a Sony representative.
  • A memory slot had a problem which prevented it to be used. This is a common issue ([1]) with this series and Sony did nothing to fix that.
  • The CD/DVD reader broke in 2007 (I have a Fujitsu notebook from 1996 which is still perfectly working).
Anyways, for the last reason and the fact that I needed to reinstall from scratch recently, I needed to go with boot diskettes and a network installation. Debian 4.0 was the easiest choice from a first overview (I had already installed Debian a few years ago on this notebook).

Installation
  1. You need the boot, root and network-drivers-1 diskettes.
  2. Start at the boot with: expert hw-detect/start_pcmcia=false
  3. After that, installation starts. It might hang (it did with me) but it's a network timeout problem. Retry with a different mirror.
  4. At the end of the installation, LILO and Grub won't install. Skip that step.
  5. To reboot, use the boot diskette with the following parameters: rescue root=/dev/hda1 (replace with your settings). Load the drivers, networks-drivers-1 and 2 diskettes this time (might not be necessary but it might save your time).
  6. Log in as root. Install Grub: apt-get install grub.
  7. Configure Grub automatically creating its configuration file.
  8. Reboot.
  9. Start in single user mode because the default X.org configuration file won't work.
  10. Edit the X.org configuration file manually removing all references to screen resolutions above 1024x768 and above 16bpp (TODO to be verified, 24bpp might work)
  11. Reboot.
  12. Check that the network parameters are correctly set.
Components

USB: working out of the box.

Useful Links

Tuesday, May 06, 2008

Logitech Quickcam Pro 4000 on Linux

This post is about using a Logitech Quickcam Pro 4000 on Linux (Fedora 8) to store snapshots and producing a movie.

# Install xawtv (xawtv-3.95-7.fc8)
> yum install xawtv

# Install mencoder (mencoder-1.0-0.90.rc2.lvn8 from the livna repository)
> yum install mencoder

The xawtv package contains tools which allow you to connect to the webcam, grab pictures and videos on the fly and also produce movies from the snaps.

# Check that the webcam is recognized and broadcasting:
> xawtv -c /dev/video0 &

/dev/video0 : the device (use xawtv -hwscan to see which one it is for you)

# You can grab pictures in two ways with xawtv: using webcam or using streamer.

# grab snapshots using streamer
> streamer -c /dev/video0 -j 85 -t 1200 -r 0.03 -o office-0000.jpeg

/dev/video0 : the device
85 : JPEG quality
1200 : number of snapshots to grab
0.03 : frames per second (here it's about 1 snap every 30 seconds)
office-0000.jpeg : output file with counter to accomodate 4 digits here

# grap snapshots using webcam
> webcam webcam.conf

All configuration is read from file. My webcam.conf is:

[grab]
device = /dev/video0
text = Atlanta GA - %Y-%m-%d %H:%M:%S
#infofile = infofile.txt
fg_red = 255
fg_green = 255
fg_blue = 255
width = 320
height = 240
delay = 30
wait = 0
#input = camera
brightness = 100
#norm = pal
rotate = 0
top = 0
left = 5
bottom = -1
right = -1
quality = 85
trigger = 0
once = 0
archive = office-%Y%m%d-%H%M%S.jpg

TODO Explanation to follow...

# make movie using mencoder (you can also use streamer but I didn't try it yet)
> mencoder "mf://${CURR_DATE}/*.jpg" -msglevel all=-1 -mf fps=12:type=jpg -ovc lavc -lavcopts vcodec=mpeg4:trell:mbd=2:dc=10 -oac copy -o "movie_${CURR_DATE}.avi"

... to be continued