2013-04-14

HOWTO: radical lossless JPEG image optimization (in Linux)

(The sample commands are tested under Debian Wheezy).

First of all, don't forget to install the JPEG manipulating programs package:
# apt-get install libjpeg-progs
And it's the optimization itself:
$ jpegtran -copy none -progressive input.jpg > output.jpg
Notes:
  1. yes, it produces a progressive JPEG output image; if you don't like it (or it's unsupported in the target environment), use -optimize switch instead of -progressive (but the output image size will be bigger);
  2. there's also a non-recommended option (an -arithmetic switch) to enable arithmetic coding; it allows a more efficient compression than traditional Huffman coding does, but (unfortunately) it's not widely supported in JPEG decoders due to some historical patent restrictions;
  3. -copy none option removes all extra markers (comments, tags, thumbnails and other metadata) from the output; if you need to save them, use -copy comments (or even -copy all) option instead;
  4. you can add a -grayscale option, and it will omit color data from the output image without re-encoding (very useful for grayscale / black & white / monochrome images);
  5. more reading:

2013-04-11

HOWTO: convert audio CD image (FLAC + CUE) to MP3 tracks in Linux

Imagine you've archived your favourite audio CD into FLAC/CUE pair format (or maybe you've purchased some album in that digital downloadable lossless audio format, who knows), and now you want to convert it to the standard MP3 files for playing that album in your good old digital music player.

Let the files be processed in Debian GNU/Linux environment (sample commands tested in Debian 7.0 "Wheezy", and should also work for all Debian-based distros, e. g. Ubuntu, Mint etc.; Bash shell is assumed to be installed & used by default).

First of all, you should install all the necessary tools: FLAC (for decoding FLAC to WAV), LAME (to convert WAV to MP3), cuetools (to parse the CUE sheet) and shntool (to cut the big WAV file into smaller tracks according to the CUE sheet breakpoints).
# apt-get install flac lame cuetools shntool
Then the conversion process itself begins.
$ flac -d MyMusic.flac
$ cuebreakpoints MyMusic.cue | shnsplit MyMusic.wav
$ rm MyMusic.wav
$ for file in split-track*.wav; do lame -V0 $file; done
$ rm split-track*.wav
The output files are by default MP3 VBR V0, 44.1 KHz, Joint Stereo; it should be decent for most situations.
After conversion, you can process split-track*.mp3 files with your favourite media tagger application.
Enjoy.

2013-04-07

Default Sudo lecture

Here is a standard Sudo lecture, which can be seen at the user's first sudo run time (the following is an unmodified quote extracted from the sudo-$VERSION/plugins/sudoers/check.c source file found in the original sudo 1.8.6p7 source tarball):
#define DEFAULT_LECTURE "\n" \
    "We trust you have received the usual lecture from the local System\n" \
    "Administrator. It usually boils down to these three things:\n\n" \
    "    #1) Respect the privacy of others.\n" \
    "    #2) Think before you type.\n" \
    "    #3) With great power comes great responsibility.\n\n"
References:
  1. Sudo Main Page