-
Notifications
You must be signed in to change notification settings - Fork 0
/
lightbox2spgm.pl
executable file
·83 lines (58 loc) · 1.82 KB
/
lightbox2spgm.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/perl
# Usage: $0 lightbox_page images_dir out_dir
#
# Corey Ford
# March 2010
use warnings;
use strict;
use autodie;
use File::Copy;
if ($#ARGV + 1 != 3) {
die "3 arguments must be provided";
}
my ($in_page, $src_dir, $out_dir) = @ARGV;
open IN_PAGE, $in_page;
open PIC_DESC, ">$out_dir/pic-desc.txt";
open PIC_SORT, ">$out_dir/pic-sort.txt";
print PIC_DESC "; Do not remove this comment (used for UTF-8 compliance)\n\n";
print PIC_SORT "; Do not remove this comment (used for UTF-8 compliance)\n\n";
while (<IN_PAGE>) {
# Get image names and captions
if (/images\/(.*?\.(?:jpg|png|gif)).*?title="(.*?)"/) {
# Copy image
copy ("$src_dir/$1", $out_dir);
# Write to pic-desc and pic-sort
print PIC_DESC "$1 | $2\n";
print PIC_SORT "$1\n";
}
}
close IN_PAGE;
# Create thumbnail directory (user will have to use genthumb)
mkdir "$out_dir/thumbnails";
# Create blank index.html
open FH, ">$out_dir/index.html";
close FH;
# Create gal-desc.txt
open FH, ">$out_dir/gal-desc.txt";
close FH;
=head1 NAME
lightbox2spgm - create an SPGM gallery from a Lightbox-enabled webpage
=head1 SYNOPSIS
lightbox2spgm lightbox_page images_dir gallery_dir
=head1 ARGUMENTS
=over
=item lightbox_page
HTML source file equipped for Lightbox
(L<http://www.lokeshdhakar.com/projects/lightbox2/>) or similar.
=item images_dir
Directory containing image files referenced by the webpage.
=item gallery_dir
An empty directory into which the gallery's files will be placed.
=back
=head1 BUGS
The script assumes that the Lightbox page will reference images in the "images/"
directory. It also expects the <a> tag to be contained on one line.
An empty "thumbnails" directory will be created in the gallery directory for
convenience, but a tool such as the "genthumb" script included with SPGM will
have to be used to actually create thumbnails.
=cut