Saturday, 21 June 2014

Fstab notes

Coupla handy fstab commands for the next time a hard drive blows up.


To list UUIDs of attached drives:
sudo blkid

To list all drives attached to the system:
sudo fdisk -l
(that's a lowercase L, not a one)

To edit fstab:
gksu gedit /etc/fstab

To enact changes you've just made to fstab:
sudo mount -a

To see what devices are currently mounted (will include stuff other than drives)
mount



Tuesday, 11 March 2014

Resizing images with Imagemagick

I like the command line-driven program Imagemagick for resizing images.  There are lots of examples on the net, but when I wanted to resize a bunch of images at once I couldn't find how to use wildcards.  Most people seem to expect you to know how to use wildcards in your expressions, which I didn't.

I wanted to take a directory of .png scans, resize them, and save them as .jpgs.  I navigate to the directory they're in using my file manager, then right-click and choose "open in terminal window".  Then I typed

convert *.png -resize 800x800 -quality 80 outputfilename.jpg

This will give you .jpgs numbered consecutively, at a maximum size of 800 vertical or 800 horizontal, while preserving aspect ratio, at fairly good quality (between 0-100).

Obviously, this will resize every .png file in the directory, but you can be more selective by giving more info for the input file

convert P1070*.png -resize 800x800 -quality 80 outputfilename.jpg

Imagemagick is staggeringly powerful for what it is, I'm not going to go into great deal of info but check out the website for more details.  It pays to become fluent with simple conversions.  You hear the old saw from diehards about how the command line is faster, and in this case I admit it's true.  Tip - I resize images often enough that I just have to up-arrow through my history in the terminal a few times to come to a recent usage, edit it, and go.

www.imagemagick.org