Monday, March 26, 2007

ImageMagick, Travel Pictures, and Getting Pictures to Import

I had a problem importing photos on my Ubuntu O/S. I received the following error.
An error occurred in the io-library ('Could not claim the USB device'): Could not claim interface 0 (Operation not permitted). Make sure no other program or kernel module (such as sdc2xx, stv680, spca50x) is using the device and you have read/write access to the device.

It worked fine on my old Fedora Core system so I hit the web to find the answer. It only took a few minutes, and some help from Google, to find the answer. It appears to be a bug.

Here's the link to fix it.
https://launchpad.net/ubuntu/+source/libgphoto2/+bug/91250

You can read the whole thing but here's the crux of it.

Edit /etc/udev/rules.d/45-libgphoto2.rules
replace
BUS!="usb*", GOTO="libgphoto2_rules_end"

with
SUBSYSTEM!="usb_device", GOTO="libgphoto2_rules_end"

On another subject, to change a bunch of photos at once, you can use a tool called ImageMagick. Here's a perl script I use to shrink photos for email or web posting. If you're using LINUX, you put it in a directory where your files are located and run it. At the end, you should wind up with some _sm.jpg.

#!/usr/bin/perl

## this perl script converts jpgs to smaller jpgs and set the maximum size.

$size = '640';
@files= `ls *.jpg`;
foreach $file(@files) {
chomp $file;
print "Infile is $file\n";
($outfile,$ext) = split(/\./,$file);
$outfile .= '_sm.jpg';
print "Outfile is $outfile\n";
$cmd = "convert -geometry $size $file $outfile";
print "$cmd\n";
system $cmd;
}


Here's another version that changes the formate from jpg to png. Note, you only need to change the filename extension to make this happen.

#!/usr/bin/perl

## this perl script converts jpgs to png and set the maximum size.

$size = '640';
@files= `ls *.jpg`;
foreach $file(@files) {
chomp $file;
print "Infile is $file\n";
($outfile,$ext) = split(/\./,$file);
$outfile .= '.png';
print "Outfile is $outfile\n";
$cmd = "convert -geometry $size $file $outfile";
print "$cmd\n";
system $cmd;
}

For more information about Image Magick, visit their site at http://www.imagemagick.org

No comments: