Album/Tutorial.pm untested

filter: Statementstmt 0.0% 0 / 4 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 1 Podpod n/a totaltotal 0.0% 0 / 5 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
CRAP 2.0
1 package Album::Tutorial;
2  
3 # NOTE: This is a documentation-only module.
4  
5 use strict;
6  
7 our $VERSION = "1.901.0";
8  
9 =pod
10  
11 =head1 NAME
12  
13 Album::Tutorial - How to use the Album program
14  
15 =head1 SYNOPSIS
16  
17 This tutorial describes the basic use of the Album program to create
18 and maintain browser based photo albums.
19  
20 =head1 DESCRIPTION
21  
22 =head2 Getting started
23  
24 To get started, create a new directory and cd to it. Create a
25 subdirectory 'large' and put some pictures there. If you have
26 installed the 'album' tool in your execution path, you can now execute
27 it as follows:
28  
29 $ album -v
30 No info.dat, adding images from large
31 info.dat: Cannot update (does not exist)
32 Number of entries = 7 (7 added)
33 mkdir index
34 mkdir icons
35 Creating icons: first-gr.png first.png ... sound.png movie.jpg
36 im023.jpg: thumbnail OK
37 im024.jpg: thumbnail OK
38 im025.jpg: thumbnail OK
39 im026.jpg: thumbnail OK
40 im027.jpg: thumbnail OK
41 im028.jpg: thumbnail OK
42 im029.jpg: thumbnail OK
43 Creating pages for 7 images
44 (Needed to write 7 image pages)
45 Creating pages for 1 index
46 (Needed to write 1 index page)
47  
48 Your results will vary, but be similar to this example run. What you
49 can see is that 'album' found 7 images in the 'large' directory,
50 created index and icons directories, created thumbnails by
51 resizing the images, and finally created the HTML pages. You can
52 inspect your first photo album by opening file 'index/index001.html' with your
53 favorite browser. You can click on any image to see the larger
54 version. Navigation buttons are provided to the left of the image. You
55 can also navigate from the keyboard: space (next), backspace
56 (previous), enter (larger image), and 'd' (index).
57  
58 It is interesting to run 'album' again:
59  
60 $ album -v
61 No info.dat, adding images from large
62 info.dat: Cannot update (does not exist)
63 Number of entries = 7 (7 added)
64 .......[7]
65 Creating pages for 7 images
66 (No image pages needed updating)
67 Creating pages for 1 index
68 (No index pages needed updating)
69  
70 'album' tries to avoid doing unnecessary work as much as possible. In
71 this case, all thumbnails and image and index pages are up to date.
72 The line of periods shows progress, one period for each image
73 processed.
74  
75 =head2 Protecting your work
76  
77 'album' not only tries to avoid doing unnecessary work, but it is also
78 very careful to not destroy your original images, nor any other
79 changes you may have made.
80  
81 In general, 'album' will I<never> overwrite or modify:
82  
83 =over 4
84  
85 =item *
86  
87 anything in the import directories (see below);
88  
89 =item *
90  
91 any images in the 'large' directory (which is considered 'original work');
92  
93 =item *
94  
95 any images in the 'medium' and 'index' directories (but see
96 B<--clobber> below);
97  
98 =item *
99  
100 any icons, so it is safe to customize these;
101  
102 =back
103  
104 =head2 Adding medium sized images
105  
106 The purpose of medium sized images is easy browsing by having a
107 consistent and convenient size. The default size shows normal 4:3
108 images completely on an 1024x768 screen in the browser's full screen
109 mode.
110  
111 To add medium sized images (and also specify an album title):
112  
113 $ album -v --medium --title "My First Album"
114 No info.dat, adding images from large
115 info.dat: Cannot update (does not exist)
116 Number of entries = 7 (7 added)
117 mkdir medium
118 im023.jpg: medium OK
119 im024.jpg: medium OK
120 im025.jpg: medium OK
121 im026.jpg: medium OK
122 im027.jpg: medium OK
123 im028.jpg: medium OK
124 im029.jpg: medium OK
125 Creating pages for 7 images
126 (Needed to write 14 image pages)
127 Creating pages for 1 index
128 (Needed to write 1 index page)
129  
130 Again, 'album' only does the work needed, re-using the work already
131 done.
132  
133 =head2 Adding image descriptions
134  
135 As can be seen from the example runs, 'album' looks for a file
136 'info.dat'. This file can be used to:
137  
138 =over 4
139  
140 =item *
141  
142 control what images must be shown
143  
144 =item *
145  
146 the order in which they must be shown
147  
148 =item *
149  
150 whether rotation is necessary
151  
152 =item *
153  
154 set tag and description information
155  
156 =item *
157  
158 control other settings
159  
160 =back
161  
162 The format of 'info.dat' is simple. Empty lines and lines starting with
163 a '#' are ignored. Data lines contain the name of an image file,
164 followed by its description. Control lines start with an '!' mark.
165  
166 'album' can fill 'info.dat' for you. To obtain this, create an empty
167 'info.dat' file, and run 'album':
168  
169 $ touch info.dat
170 $ album -v --medium --title "My First Album"
171 No info.dat, adding images from large
172 Updating info.dat
173 Number of entries = 7 (7 added)
174 .......[7]
175 Creating pages for 7 images
176 (No image pages needed updating)
177 Creating pages for 1 index
178 (No index pages needed updating)
179  
180 Upon completion, 'info.dat' will look similar to:
181  
182 # album control file generated by album 1.19, Tue Jun 1 22:39:41 2004
183 !title My First Album
184 !medium
185 # New entries added by album 1.19, Tue Jun 1 22:39:41 2004
186 !tag
187 im023.jpg
188 im024.jpg
189 im025.jpg
190 im026.jpg
191 im027.jpg
192 im028.jpg
193 im029.jpg
194  
195 You can now add a description for each image following the file name,
196 for example:
197  
198 !tag 2004/06/01
199 im023.jpg Sunrise
200 im024.jpg Overview
201 im025.jpg Across the lake
202 im026.jpg Catch of the day
203 im027.jpg Fishermen
204 im028.jpg Swimming cows
205 im029.jpg Moon over Clew Bay
206  
207 Re-run the program (no need for B<--medium> and B<--title> anymore):
208  
209 $ album -v
210 Number of entries = 7
211 .......[7]
212 Creating pages for 7 images
213 (Needed to write 14 image pages)
214 Creating pages for 1 index
215 (Needed to write 1 index page)
216  
217 There are no complaints anymore about a missing 'info.dat', but
218 there's also no message 'adding images from ./large'. In other words,
219 the only images shown are the ones named in the control file. New
220 images added to the 'large' directory will be ignored. We'll see later
221 what to do about that.
222  
223 =head2 Summary of 'info.dat' control commands
224  
225 The first line can be used to designate a coding system, in case the
226 information needs to contain non-ASCII characters. For example, to
227 designate that the data is in ISO 8895.1 (Latin-1) encoding, use:
228  
229 # -*- coding: iso8859-1 -*-
230  
231 Most settings can also obtained with command line options, as shown.
232  
233 =over
234  
235 =item B<!title> I<XXX>
236  
237 Sets the title to I<XXX>, override with B<--title>.
238  
239 =item B<!home> I<XXX>
240  
241 Provides an 'up' link on the index pages. Override with B<--home>.
242 Note that this link is relative to the location of the index directory.
243  
244 =item B<!page> I<N>B<x>I<M>
245  
246 Sets the layout to I<N> rows (B<--rows>) and I<M> columns (B<--columns>).
247  
248 =item B<!thumbsize> NNN
249  
250 Specifies the desired width for thumbnail images (B<--thumbsize>).
251  
252 =item B<!medium>
253  
254 Includes medium sized images (B<--medium>) of default size.
255  
256 =item B<!mediumsize> I<NNN>
257  
258 Specifies the desired width for medium sized images (B<--mediumsize>).
259 To enforce this width, even if the original image is smaller, specify
260 C<!> after the size.
261  
262 =item B<!tag> I<XXX>
263  
264 Sets the tag line for all subsequent images. Cancel with an empty
265 B<!tag> command.
266  
267 =item B<!caption>
268  
269 Sets the caption code for index pages (B<--caption>). It must be a
270 sequence of B<f> (file name), B<s> (size, WxH), B<c> (caption), B<t>
271 (tag line). If no B<!caption> has been used, the default value is
272 B<fct>.
273  
274 =item B<!dateformat> I<XXX>
275  
276 Sets the default date format as used for the tag lines for new images.
277 I<XXX> must be a valid strftime(2) date format string, for example:
278  
279 !dateformat %a %e %B %Y
280  
281 =item B<!icon>
282  
283 Produce a file C<icon.jpg> to be used as an icon for this album
284 (B<--icon>). The icon is of thumbnail size, and contains a small
285 lookalike of the first index page.
286  
287 B<!icon> may be followed by a something true or false (B<--noicon>).
288 Default is true.
289  
290 =item B<!locale> I<XXX>
291  
292 Set the locales for sorting and date formats to I<XXX>.
293  
294 =back
295  
296 B<album> can read values for settings from configuration files.
297 Settings can be set as in C<info.dat>, the leading exclamation mark is
298 optional in this case. By default, the configuration files used are
299 C<.albumrc> in the current directory, and C<.albumrc> in the user's
300 home directory. The order of precedence is:
301  
302 =over
303  
304 =item 1. command line options
305  
306 =item 2. C<info.dat>
307  
308 =item 3. user config file C<.albumrc> in current directory
309  
310 =item 4. user config file C<.albumrc> in the home directory
311  
312 =back
313  
314 Environment variable ALBUMCONFIG can be used to designate user
315 config files. It should be set to a colon-separated list of file names
316 to be processed in order of precedence.
317  
318 =head2 Importing new images
319  
320 An important feature of 'album' is importing new images from an
321 external source. For example, you can import new images from a CD-ROM,
322 or from a digital camera.
323  
324 Assuming you mounted a CD-ROM with new images, execute 'album' as
325 follows:
326  
327 $ album -v --import /mnt/cdrom --update
328 Updating info.dat
329 Number of entries = 9 (2 added)
330 .......[7]
331 im030.jpg: copy medium thumbnail OK
332 im031.jpg: copy medium thumbnail OK
333 Creating pages for 9 images
334 (Needed to write 18 image pages)
335 Creating pages for 1 index
336 (Needed to write 1 index page)
337  
338 Two new images were found on the CD-ROM, copied to the 'large'
339 directory, and processed as usual. 'info.dat' has been updated with
340 the new entries. Note that images found on the CD-ROM that already
341 exist in 'large' (i.e., have the same name) are skipped.
342  
343 =head2 Using EXIF information
344  
345 When importing images from a digital camera, 'album' can use the EXIF
346 information that is present in these files:
347  
348 =over 4
349  
350 =item *
351  
352 it will use the time stamp rename it to YYYYMMDDhhmmssSSSS (where SSSS
353 is a sequence number);
354  
355 =item *
356  
357 it will set the modification time of the file to the time stamp;
358  
359 =item *
360  
361 while copying the image, it will be rotated if necessary,
362 according to the 'orientation' property in the EXIF information.
363  
364 =back
365  
366 To enable EXIF processing, add the B<--exif> command line option, or
367 specify the import directory with B<--dcim> instead of B<--import>:
368  
369 $ ls -l /mnt/camera/dcim/101msdcf
370 -rwxr-xr-x 1 jv jv 2347808 Jun 25 12:08 /mnt/camera/dcim/101msdcf/dsc00052.jpg
371 -rwxr-xr-x 1 jv jv 1327475 Jun 25 12:05 /mnt/camera/dcim/101msdcf/dsc00053.jpg
372 $ album -v --dcim /mnt/camera/dcim/101msdcf --update
373 Updating info.dat
374 Number of entries = 11 (2 added)
375 .........[ 9]
376 200405171843310052.jpg: link medium thumbnail OK
377 200405171845030053.jpg: copy rotate medium thumbnail OK
378 Creating pages for 11 images
379 (Needed to write 22 image pages)
380 Creating pages for 1 index
381 (Needed to write 1 index page)
382  
383 The file 'dsc00052.jpg' has now been imported as
384 '200405171843310052.jpg'. 'album' tries to link to the image, if that
385 is not possible, the image will be coped. File 'dsc00053.jpg' must be
386 rotated, so it will always be a copy.
387  
388 If you hover the mouse over the file name in the index page, or over
389 the title on the image pages, a pop-up will show a selection of
390 information from the EXIF data.
391  
392 =head2 Embedding other albums
393  
394 In the file 'info.dat' you can also enter names of HTML documents to
395 refer to arbitrary other information you want to include in your
396 album. You can use this to embed (more precisely: refer to) other
397 albums. For example:
398  
399 20040910/index.html Pictures of an exhibition
400  
401 This will store in the album a reference to another album. If at the
402 given location a file 'icon.jpg' exists, this will be used in the
403 album as thumbnail image. To generate a sample icon for an album to be
404 included, run the album program with command line option --icon.
405  
406 The reference will only be present on the index pages. When following
407 the 'previous' and 'next' links of image pages, these references will
408 be skipped.
409  
410 Note that when you click on an external reference thumbnail, a new
411 browser window will be opened to show the referenced information.
412  
413 =head2 Journal mode
414  
415 I<Warning: Journal mode is still under development and may change in
416 future versions.>
417  
418 Journal mode is enabled with the control B<!journal> in C<info.dat>.
419  
420 When journal mode is enabled, the data from C<info.dat> is considered
421 to be a series of paragraphs. Paragraphs are separated using one or
422 more empty lines.
423  
424 The first line of a paragraph may contain image info, preceeded by an
425 asterisk and whitespace. For example:
426  
427 !journal
428  
429 !tag 2004/06/01
430  
431 A bright, shiny day.
432  
433 * im023.jpg Sunrise
434 This morning, we were surprised by a fantastic sunrise like
435 we have never seen before.
436  
437 * im024.jpg Overview
438 This picture shows an overview of the area.
439  
440 This way it is possible to attach extended pieces of text to a images.
441  
442 An additional series of pages is generated, the journal pages. Each
443 journal page contains the extended text and thumbnail images of all
444 entries that belong to a single tag. The idea is that the tags are
445 dates, and each journal page contains the text and images of a single
446 day.
447  
448 If the extended text starts with C<< < >> it is assumed to be HTML and
449 included literally.
450  
451 The medium and large image pages have an additional icon to jump to
452 the journal entry for an image. The extended text can be also viewed
453 on the medium and large image pages when the mouse is placed over the
454 info at the right side above the image, e.g., C<My First Album: Image
455 1 of 9>.
456  
457 Note that journal mode can not be mixed with normal mode.
458  
459 =head2 External formats and style sheets
460  
461 I<Warning: External formats and style sheets are still under
462 development and may change in future versions.>
463  
464 Internally, 'album' uses formats (templates) to build the generated
465 HTML pages, and cascading style sheets (CSS) to specify how the
466 browser should show the pages. Formats and style sheets can be
467 exported (written to external directories), and 'album' will then use
468 the external information. So you can have ultimate control over how
469 pages must look like.
470  
471 =head2 External formats
472  
473 When 'album' is run with B<--extformats> it will create a directory
474 'formats' and, in this directory, the HTML templates for all types of
475 pages that 'album' will generate. Existing files in this directory
476 will B<not> be overwritten, so it is safe to change the templates to
477 your liking. When 'album' is run again to process images, it will use
478 the templates from the 'formats' directory if they are available.
479  
480 The templates are plain HTML and contain variables that will be
481 substituted with actual values. Some of the variables are:
482  
483 =over 12
484  
485 =item $title
486  
487 The title of the album.
488  
489 =item $css
490  
491 The code to get the style sheet of this page. This can be in-line
492 specifications, or a link to an external stylesheet.
493  
494 =item $ltop
495  
496 Index and image pages only: The text above each image, left.
497  
498 =item $rtop
499  
500 Index and image pages only: The text above each image, right.
501  
502 =item $vbuttons
503  
504 The navigation buttons, arranged vertically.
505  
506 =item $hbuttons
507  
508 The navigation buttons, arranged horizontally.
509  
510 =item $jscript
511  
512 The javascript for keyboard navigation.
513  
514 =item $image
515  
516 Image pages only: The actual image.
517  
518 =item $lbot
519  
520 Image pages only: The text below the image, left.
521  
522 =item $rbot
523  
524 Image pages only: The text below the image, right.
525  
526 =item $contents
527  
528 Index pages only: The table with all the images for this page.
529  
530 =item $tag
531  
532 Journal pages only: The tag for this page.
533  
534 =item $journal
535  
536 Journal pages only: The journal for this page.
537  
538 =back
539  
540 =head3 External style sheets
541  
542 When 'album' is run with B<--extcss> it will create a directory 'css'
543 and, in this directory, the css style sheets for all types of pages
544 that 'album' will generate. Existing files in this directory will
545 B<not> be overwritten, so it is safe to change the templates to your
546 liking. When 'album' is run again to process images, it will use the
547 external style sheets if they are available.
548  
549 To obtain good results, the style sheets must match the formats.
550 'album' will try to verify this by reading the first line of the style
551 sheets and the formats, and verify that it contains a version
552 indication of the form
553  
554 ALBUM-FMT-VERSION: <major>.<minor> (for formats)
555 ALBUM-CSS-VERSION: <major>.<minor> (for style sheets)
556  
557 For all style sheet - format pairs, the major numbers must be the
558 same.
559  
560 Older versions of 'album' always created external style sheets. As a
561 consequence, if you upgrade to the newer version, you'll get a fatal
562 error the first time you run 'album'.
563  
564 *************************************************************************
565 Existing style sheet ... is not compatible with this version.
566 It has probably been created by an older version of this program, or it
567 has been modified manually.
568  
569 If you did not change any style sheets, just remove the css directory and
570 try again.
571  
572 If you did modify the style sheets move them away to a backup location,
573 run the program with '--extcss', and apply your changes to the new style
574 sheets.
575 *************************************************************************
576  
577 We apologise for the inconvenience.
578  
579 =head2 Keyboard navigation
580  
581 While browsing the album, some actions can be performed from the keyboard.
582  
583 The C<Enter> key will go to an enlarged version of the image, if available.
584  
585 The C<Space> key will advance to the next page.
586  
587 The C<Backspace> key will advance to the previous page.
588  
589 Key C<d> will go to the index page.
590  
591 Key C<u> will go up, i.e., the reverse of the C<Enter> key.
592  
593 Key C<j> will go to the journal entry of the current image.
594  
595 =head2 Additional notes
596  
597 The B<--clobber> command line option will force regeneration of all
598 medium and thumbnail images, and HTML pages. It will not force
599 re-import of the 'large' images. To completely rebuild everything
600 save info.dat, remove all the files in the album directory (including
601 .cache), restore info.dat and re-run the 'album' program.
602  
603 The digital camera import is designed for cameras that adhere to the
604 ISO DCF standard. Handling of MPG movies and voice images is probably
605 specific for my Sony DSC-V1.
606  
607 When importing images from different camera's, there's an extremely
608 small chance that the EXIF information would lead to identical file
609 names. This can only happen if the pictures were taken at the exact
610 same time (according to the camera's notion of time!), and have the
611 same internal sequence number.
612  
613 When parsing C<info.dat>, Album treats anything up to a known file
614 name extension to be part of the file name. In general, this means
615 that you can safely enter file names with whitespace and other
616 uglyness.
617  
618 Known file name extensions are C<jpg>, C<jpeg>, C<png>, and C<gif> for
619 images, C<mpg>, C<mpeg>, C<mov>, and C<avi> for movies, and C<html>
620 and C<htm> for links.
621  
622 =head1 AUTHOR AND CREDITS
623  
624 Johan Vromans (jvromans@squirrel.nl) wrote this module.
625  
626 =head1 COPYRIGHT AND DISCLAIMER
627  
628 This program is Copyright 2004,2007 by Squirrel Consultancy. All
629 rights reserved.
630  
631 This program is free software; you can redistribute it and/or modify
632 it under the terms of either: a) the GNU General Public License as
633 published by the Free Software Foundation; either version 1, or (at
634 your option) any later version, or b) the "Artistic License" which
635 comes with Perl.
636  
637 This program is distributed in the hope that it will be useful, but
638 WITHOUT ANY WARRANTY; without even the implied warranty of
639 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either the
640 GNU General Public License or the Artistic License for more details.
641  
642 =cut
643  
644 1;
645  
646 # $Id: Tutorial.pm,v 1.12 2007/05/31 21:01:34 jv Exp $