Wed, 03 Dec 2008

Ubuntu and Scanning

Keywords: linux ubuntu 8.10 intrepid ibex sane hp scanjet 5370C avision

Another of the things that broke when I upgraded Ubuntu to 8.10 was the scanning. To be fair, it had barely been working since the upgrade to 8.04, but with 8.10 scanimage just crashed. I debugged it a little and discovered that by uncommenting "option disable-calibration" in /etc/sane.d/avision.conf I could avoid the crash, but after scanning in one direction the scanner wouldn't return to its resting position.

Eventually, I decided that if I was going to fix the crash I'd have to build a debugging version of the code, and that if I was going to do that I should get the latest version available. It turns out that was in a CVS repository and was fairly easy to obtain and build:

cvs -z3 co sane-backends
./configure --sysconfdir=/etc --prefix=/usr/local/pkg/sane
make install

And BINGO! The crash was fixed, and I didn't had to change any code at all.

I still had the problem, which was also there in 8.04, that the preview in xsane has diagonal stripes. Do I decided to do away with xsane and replace it by a small shell script which I imaginatively named scan:



/usr/local/pkg/sane/bin/scanimage -d avision -v -p --resolution=300 "$@" > /tmp/out.pnm
convert -quality 90 -verbose /tmp/out.pnm $out
gimp $out

So now, when I scan album art, for example, (which is what I most commonly scan nowadays), I can just type scan front.jpg and the cover is scanned and thrown up in gimp for me to crop and save. This has been working well so far.

[/unix] permanent link

Tue, 02 Dec 2008

Ubuntu and Pulseaudio

Keywords: linux ubuntu 8.10 intrepid ibex pulseaudio problems solution success multimedia keys volume

I recently upgraded my desktop box from Ubuntu 8.04 (Hardy Heron) to 8.10 (Intrepid Ibex). (I've written down the names so I can look them up when I need to. At least they seem to have settled on some sort of alphabetical system nowadays.)

Anyway, one of the things that broke during the process was sound. And for me it didn't just work, which is bad and wrong. So I searched the web and discovered that 8.10 is now using pulseaudio by default and that I wasn't alone with my sound problem, with many people claiming that pulseaudio just wasn't yet ready for primetime.

So I read up a little on pulseaudio, found out lots of things I didn't really want to know, tweaked all sorts of stuff and eventually got sound out of amarok, but not flash or any of the video players. And not after I had rebooted until I messed with things again. The "solution" involved killing pulseaudio and forcing things to use alsa or oss or something, and it also broke the remaining working multimedia buttons including the volume control, the rest already having been seen off by the upgrade.

Eventually, I really needed to hear something that was on flash, so I searched the web again, and came across a page on the ubuntu forum. I followed it, I set the resample-method to the highest quality, and everything just worked again.

Well, mostly.

Some of the tracks I played caused pulseaudio to crash. So I reduced the resample-method by one notch and things seem OK there so far. I got the volume and mute multimedia keys on my keyboard to work by setting the Default Mixer Track in System/Preferences/Sound to the appropriate "Playback: ALSA" device. I got the rest to work by running the Gnome Multimedia Key's script in the amarok script manager (the author must have been a greengrocer in a previous life).

Of course, the display, the scanner and other stuff were all just as broken as before. But that's another story.

(I'm not sure whether adding the new repositories is strictly necessary - no packages were installed from them - but I can't be bothered to mess with it any more.)

[/unix] permanent link

Sun, 23 Nov 2008

Adding Pictures to Gallery

I use Gallery to display my photos. I'm mostly happy with it and have developed the following work-flow to help me add pictures with the minimum of fuss.

  • Copy the pictures onto my server. I generally do this via scp or an NFS mount.
$ cp -a /media/CAMERA/DCIM /mnt/server/pics/new
  • Run my autorotate program to name the files based the date and time the pictures were taken, split them into directories based on the date, and rotate the pictures based on the EXIF orientation information.
$ autorotate /pics/new/**/*(.)   # this is zsh syntax
  • Then I run nautilus on the created directories (in /pics/new) to look at the pictures and delete the ones I don't want. Using the icon view and setting the icon size to 400% makes it quite usable for this. I can also run my rot script here to rotate any photos that were incorrectly rotated or which came from a camera without orientation information. Finally, I make sure all the photos are in the folders I want them to be in.
  • Then I log into gallery and go into my pending directory. Here I upload the directories using Add Items / From Local Server.
  • Then I can move the directories to where I want them to live and choose the highlight pictures. Nautilus is also good for this.
  • I like the majority of my albums to be arranged chronologically, and for the album to have the date and time of the first photo in it. To easily do this I then run my set_gallery_album_dates program.
$ set_gallery_album_dates
  • When I am happy, I check the albums and then set the permissions so that they are viewable. Since this is a right pain I will generally go to the top level album and remove the permissions then add them again making sure the apply changes to sub-items box is ticked. I check this has worked by temporarily setting the display mode (in the bottom right hand corner) to guest.
  • Finally, I clean up the old files. I've spent too much time double checking old directories full of pictures against what's in the gallery.
$ rm -r /pics/new/* /pics/sorted/*
  • And the very last step, unmount the memory card, put it back in the camera and format it.

[/software/gallery] permanent link

Sat, 22 Nov 2008

Adjusting EXIF dates

Sometimes EXIF date information on pictures can be incorrect, usually because the clock on the camera is set incorrectly. To adjust a set of pictures with incorrect EXIF date information I run a command similar to:

$ exiftime -v+1y -fw *

This will add one year to all the EXIF date tags in all the pictures in the current directory. The modifiers are y, m, w, d, H, M, and S and they can be adjusted forwards with + or backwards with -.

For complete details, see the man page.

[/software/gallery] permanent link

Fri, 21 Nov 2008


To watermark a picture I run a command similar to:

$ composite -gravity Center -quality 90 -dissolve 50 watermark.png pic.jpg pic-w.jpg

[/software/gallery] permanent link

Fri, 18 Jan 2008

Debian Package Management 2

I don't often have to set up a new system, but every time I do I completely forget the very useful way that debian and ubuntu can save the set of installed packages and reinstall them later. So here it is for next time:

# dpkg --get-selections > /packages.lst
# dpkg --set-selections < /packages.lst

[/unix] permanent link

November 2022
Sun Mon Tue Wed Thu Fri Sat