Technology Tales

Adventures & experiences in contemporary technology

ImageMagick and Ubuntu 9.04

5th May 2009

Using a command line tool like ImageMagick for image processing may sound a really counter-intuitive thing to do but there’s no need to do everything on a case by case interactive basis. Image resizing and format conversion come to mind here. Helper programs are used behind the scenes too with Ghostscript being used to create Postscript files, for example.

The subject of helper programs brings me to an issue that has hampered me recently. While I am aware that there are tools like F-Spot available, I am also wont to use a combination of shell scripting (BASH & KSH), Perl and ImageMagick for organising my digital photos. My preference for using Raw camera files (DNG & CRW) means that ImageMagick cannot access these without a little helper. In the case of Ubuntu, it’s UFRaw. However, Jaunty Jackalope appears to have seen UFRaw updated to a version that is incompatible with the included version of ImageMagick (6.4.5 as opposed to 3.5.2 at the time of writing). The result is that the command issued by ImageMagick to UFRaw -- issue the command man ufraw-batch to see the details -- is not accepted by the included version of the latter, 0.15 if you’re interested. It seems that an older release of UFRaw accepted the output device ppm16 (16-bit PPM files) but this should now be specified as ppm for the output device and 16 for the output depth. In a nutshell, where the parameter output-type did the lot, you now need both output-type and output-depth.

I thought of decoupling things by using UFRaw to create 16-bit PPM files for processing by ImageMagick but to no avail. The identify command wouldn’t return the date on which the image was taken. I even changed the type to 8-bit JPEG’s with added EXIF information but no progress was made. In the end, a mad plan came to mind: creating a VirtualBox VM running Debian. The logic was that if Debian deserves its reputation for solidity, dependencies like ImageMagick and UFRaw shouldn’t be broken and I wasn’t wrong. To make it fly though, I needed to see if I could get Guest Additions installed on Debian. Out of the box, the supported kernel version must be at least 2.6.27 and Debian’s is 2.6.26 so additional work was on the cards. First, GCC, Make and the correct kernel header files need to be installed. Once those are in place, the installation works smoothly and a restart sets the goodies in motion. To make the necessary Shared folder to be available, a command like the following was executed:

mount -t vboxfs [Shared Folder name] [mount point]

Once that deed was done and ImageMagick instated, the processing that I have been doing for new DSLR images was reinstated. Ironically, Debian’s version of ImageMagick, 6.3.7, is even older than Ubuntu’s but it works and that’s the main thing. There is an Ubuntu bug report for this on Launchpad so I hope that it gets fixed at some point in the near future. However, that may mean awaiting 9.10 or Karmic Koala so I’m glad to have the workaround in the meantime.

Some things that I’d miss on moving from Linux to Windows

17th January 2009

The latest buzz surrounding Windows 7 has caused one observer to suggest that it’s about to blast Linux from the desktop. My experiences might be positive but there are still things that I like about Linux that make me reluctant to consider switching back. Here are a few in no particular order:

Virtual Desktops (or Workspaces)

I find these very handy for keeping things organised when I have a few applications open at the same time. While I think that someone has come with a way of adding the same functionality to Windows but I’d need to go looking for that. Having everything cluttering up a single taskbar would feel a bit limiting.

Symbolic Links

If you have come across these before, they are a little hard to explain but it’s great to have to have the ability to make the contents of a folder appear in more than one place at a time without filling up your hard drive. It’s true to say that Windows 7 gets Libraries but I have a soft spot for the way that Linux does it so simply.

Lack of (intrusive) fidgeting

One of Windows’ biggest problems is that it’s such a massive target for attacks by the less desirable elements of the web community. The result is a multitude of security software vendors wanting to get their wares onto your PC and it’s when they get there that all of the fidgeting starts. The cause is the constant need for system monitoring and it eats up resources that could be used for other things. I know some packages are less intrusive than others but I do like the idea of feeling as if I am in full control of my PC rather someone else taking decisions for me (unavoidable in the world of work, I know). An example of this is Norton’s not allowing me to shut it down when it goes rogue, even when acting as Administrator. I can see the reason for this in that it’s trying to hamper the attentions of nefarious malware but it ends up making me feel less than empowered and I also like to feel trusted too. Another thing that I like is the idea of something awaiting my input rather going away and trying to guess what I need and getting it wrong, an experience that seems typical of Microsoft software.

Command Line

This is less of a miss than it used to be but there is now a learning curve with PowerShell’s inclusion with Windows 7 and it’s not something that I want to foist on myself without my having the time learning its ins and outs. It’s not a bad skill to have listed on the proverbial CV but I now know my way around bash and its ilk while knowing where to look when I want to take things further.

After these, there are other personal reasons for my sticking with Linux like memories of bad experiences with Windows XP and the way that Linux just seems to get on with the job. Its being free of charge is another bonus and the freedom to have things as you want makes you feel that you have a safer haven in this ever changing digital world. I am not sure if I’d go acquiring the final version of Windows 7 but I am certain that it will not be replacing Linux as my main home computing platform, something that come as no surprise given what I have said above.

Automating FTP I: UNIX and Linux

11th April 2008

Having got tired of repeated typing in everything at the prompt of an interactive command line FTP session and doing similar things via the GUI route, I started to wonder if there was a scripting alternative and, lo and behold, I found it after a spot of googling. There are various opportunities for its extension such as prompting for username and password instead of the risky approach of including them in a script or cycling through a directory structure but here’s the foundation stone for such tinkering anyway:

HOSTNAME='ftp.server.host'
USER='user'
PSSWD='password'
REP_SRC='source_directory'
REP__DEST='destination_directory'
FILENAME='*'

rm -rf log_file.tmp

cd "${REP_DEST}"

ftp -i -n -v <<EndFTP >>log_file.tmp 2>>log_file.tmp
open ${HOSTNAME}
user ${USER} ${PSSWD}
prompt
cd "${REP_SRC}"
mget "${FILENAME}"
EndFTP

cd ~

Filename autocompletion on the command line

19th October 2007

The Windows 2000 command line feels an austere primitive when compared with the wonders of the UNIX/Linux equivalent. Windows XP feels a little better and PowerShell is another animal altogether. With the latter pair, you do get file or folder autocompletion upon hitting the TAB key. What I didn’t realise until recently was that continued tabbed cycled through the possibilities; I was hitting it once and retyping when I got the wrong folder or file. I stand corrected. With the shell in Linux/UNIX, you can get a listing of possibilities when you hit TAB for the second time and the first time only gives you completion as far as it can go with certainty; you’ll never get to the wrong place but you may not get anywhere at all. This works for bash but not ksh88 as far as I can see. It’s interesting how you can take two different approaches in order to reach the same end.

Using Korn shell commands in scripts running under the bash shell

19th May 2007

This is actually a fairly simple one: just prefix the relevant command with "ksh" like below (in the example below, bash won’t know what to do with the print command otherwise):

ksh print "Hello, world!"

It’s also useful for running Korn shell scripts under the bash shell as well.

Recalling previous commands in the Korn shell

18th May 2007

The default shell on Solaris boxes seems to be Korn and the version that I have encountered doesn’t appear to allow obvious access to the command history. In the bash shell, the up and down cursor keys scroll through your command history for you but Korn doesn’t seem to allow this. Thankfully, there is another way: you can set up the editor vi as the default method for gaining access to the command history by adding the following line to the .profile file in your home directory:

set -o vi

Then, you can use the Vi (it’s pronounced vee-eye, apparently) commands ESC+h and ESC+j to move up and down the list of previous commands. That, or, assuming that you have access to it, just use the bash shell anyway…

  • All the views that you find expressed on here in postings and articles are mine alone and not those of any organisation with which I have any association, through work or otherwise. As regards editorial policy, whatever appears here is entirely of my own choice and not that of any other person or organisation.

  • Please note that everything you find here is copyrighted material. The content may be available to read without charge and without advertising but it is not to be reproduced without attribution. As it happens, a number of the images are sourced from stock libraries like iStockPhoto so they certainly are not for abstraction.

  • With regards to any comments left on the site, I expect them to be civil in tone of voice and reserve the right to reject any that are either inappropriate or irrelevant. Comment review is subject to automated processing as well as manual inspection but whatever is said is the sole responsibility of the individual contributor.