Notes for Week 7
Our distribution uses CUPS for printing, and the following is based on that. Another
alternative for printing is lprng.
Printers are added or modified online (push "Continue" buttons as necessary):
- "Add Printer" (you will be required to provide the root password)
- "LPD/LPR Host or Printer"
- Connection: lpd://192.168.1.3/lpd
- Name: laserjet
- Make: "HP"
- Model: "HP Laserjet 4300 - CUPS+Gutenprint v5.2.9 (en)"
- "Add Printer"
- "Set Default Options"
- click on Administration tab again and "Manage Printers"
- "Administration / Set As Server Default"
You can also restrict usage of a printer to specific users using that tab.
Printer definitions are kept in /etc/cups/printers.conf.
Print spooling is handled by cupsd, the CUPS scheduling daemon.
The sequence of events in printing is typically:
A user sends print output (usually either postscript or plain text) to the print queue (or spool queue) using the
lpr command (the PRINT command in Windows).
The output, as well as a small control file, are placed in the spool directory
(/var/spool/cups). Each print request is called a job, and is numbered.
The scheduler starts a process to filter the print file as necessary. For instance, a
postscript file to a postscript printer needs no filtering, while a postscript file to a
non-postscript printer must be filtered. Each printer has an associated Postscript Printer Description
(PPD) file, which determines what, if any, filtering is necessary.
The output of the filter is then passed to the appropriate backend:
local (parallel or USB) printer driver
TCP print protocol stack for a remote LPD printer
SMB protocol stack for a Windows print share
The spooled data file is eventually removed from the spool directory.
Note that files in the spool directory are only accessible by root.
Logging is done in /var/log/cups/error_log and /var/log/cups/page_log.
Printers and print queues are manipulated using the following commands:
lpq -a will list all jobs on all queues;
cupsreject printer-name will disable spooling to a printer;
cupsaccept printer-name will enable spooling to a printer;
cupsdisable printer-name will disable unspooling from a printer after the current job finishes;
cupsenable printer-name will enable unspooling from a printer;
lprm -Pprinter-name job-number will remove a job from a printer.
Note that once a print job is sent to a networked printer, it is often
difficult to control it from the host. This is especially irritating when the printer malfunctions.
Both postscript and PDF (portable document format) files are text files whose contents
contain a description of the print output using a device-independent programming language.
PDF files may be viewed using xpdf.
Note that emacs can print a file using postscript instead of plain text, and that the
results are far superior to plain text printing (use the "Postscript Print Buffer (B+W)" command).
You should always use non-proprietary, industry standard formats for files to be shared with others.
Don't fall into that lazy trap of assuming that everyone in the world has a Windows system just like yours. If you
send everything in Word or Windows Media formats, you will be shutting a lot of people out from seeing your content.
And the world is full of poorly written web pages that only display well in one specific screen resolution.
Geeqie is an image browser which is useful for viewing image files. For image manipulation you
definitely have to try gimp (the Gnu Image Manipulation Program; free and almost as powerful as Photoshop).
- for text, always use ASCII-encoded HTML (HyperText Markup Language) 3.2 or lower
(not all browsers support higher level standards);
- for still images, use JPEG (Joint Picture Experts Group) or PNG (Portable Network Graphics) - you can adjust the quality when you save the file;
or you can use TIFF (Tagged Image File Format), or GIF (Graphics Interchange Format) for line drawings if the JPEG artifacts get you down;
- for audio, use MP3 (MPEG Layer III Audio) - use 192 Kbps if quality is a concern; and
- for video, use MPEG (Motion Picture Experts Group) with a standard codec (coder/decoder) such as MPEG-1 (used for VCDs), MPEG-2
(used for DVDs) or MPEG-4.
Note that Windows, amazingly, does not always support MPEG-4.
mplayer can be used to play virtually any format of sound or video, provided that it has been built
for the specific format you're interested in.
mplayer --help will display the basic key bindings available to control playback.
Several steps may be necessary if you wish to use mplayer in the lab to play any of the audio files mentioned here:
Run alsamixer, un-muting the master volume and setting the volume.
Optionally add any users who need audio access to the audio group.
In order to compare file formats, a 26 second video was recorded and the following files prepared:
A still image of the poet was captured from the video and stored in a variety of formats:
poem.avi (Audio Visual Interleave - 36629132 bytes) using the mjpeg (motion jpeg)
codec at 29.97 frames per
second and 320x240 (24 bits per pixel) resolution, with 11024 audio samples per second in 8 bit mono;
avi files are essentially raw audio and video, and have a 2GB size limit;
poem.mpg (5988352 bytes) from the avi file, using the mpeg2 codec; output file size
is highly dependent on both scene content and noise levels; processing time is roughly proportional to
video length (approximately 8 times longer for mjpeg denoising and encoding to mpeg2 on an Athlon 2400+);
poem.mp4 (4811372 bytes) from the avi file, using the mpeg4 codec;
poem.wav (2292904 bytes) using 44100 samples per second in 8 bit stereo
(16 bit stereo is considered CD quality); wav files are essentially raw pcm (pulse code modulation) with headers;
note that the sound quality is not improved: you cannot make a silk purse out of a sow's ear;
poem.mp3 (416288 bytes) from the wav file, at 128K bits per second data rate; output
file size and processing time are proportional to audio length;
The poems themselves can be stored in a variety of ways:
poet.tiff (230692 bytes), essentially the uncompressed raw image at 24 bits per pixel;
again note that this image comes from a jpeg original, and so the tiff quality is no better;
poet.jpg (12745 bytes), compressed at the default quality of 85%;
poet.gif (54358 bytes); notice the artifacts with enlargement;
poet.png (112638 bytes);
Note that all of the compressed formats use lossy compression (some data is lost). Also note that by far
the most efficient storage method is plain text.
poem.html (312 bytes) as ASCII-encoded text;
poem.ps (32733 bytes of postscript) as output using mozilla;
poem.pdf (7811 bytes) converted from the postscript;
poem.tiff (206554 bytes) captured at 72 pixels per square inch and 24 bits per pixel
poem.jpg (19632 bytes); notice the artifacts on enlargement;
poem.gif (5290 bytes);
poem.png (8096 bytes).
EXERCISES for Week 7:
- Use lpr <filename> to print a short text file. Examine the spool
queue, and the spool files created for the job. Send the control file in your weekly e-mail to the instructor.
- Disable spooling to the printer. Attempt to print. What happens? Re-enable spooling to the printer, but
disable printing from the queue. Attempt to print. Examine the spool queue. Finally, re-enable printing from the queue
and examine the log files. Include all log messages regarding the printing attempts in this exercise in your
weekly e-mail to the instructor.
©2015, Kenneth R. Koehler. All Rights Reserved. This
document may be freely reproduced provided that this copyright notice
Please send comments or suggestions to the author.