diff options
| author | Jules Laplace <carbon@melanarchy.org> | 2013-08-02 17:14:26 -0500 |
|---|---|---|
| committer | Jules Laplace <carbon@melanarchy.org> | 2013-08-02 17:14:26 -0500 |
| commit | 79670053c7247d3a49b607960efd284e93f057e5 (patch) | |
| tree | 9617f6eefa38b2686ae409bf75cc27a340444eda /bin/populate-thumbs.pl | |
| parent | c53827d5d044ae5ca7ebb27acb404b7a8988918e (diff) | |
install.pl
Diffstat (limited to 'bin/populate-thumbs.pl')
| -rwxr-xr-x | bin/populate-thumbs.pl | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/bin/populate-thumbs.pl b/bin/populate-thumbs.pl new file mode 100755 index 0000000..ff22207 --- /dev/null +++ b/bin/populate-thumbs.pl @@ -0,0 +1,48 @@ +#!/usr/bin/perl + +$ENV{HTTPS} = "on"; + +use localbucky; + + +$dbh = DBI->connect ($dsn); + +my $doit_id = $ARGV[0]; + +if (length($doit_id)) + { + my $thread = get_thread($doit_id); + check_and_render($thread); + } +else + { + my $threads = get_threads(); + foreach my $t (@$threads) + { + check_and_render($t); + } + } + +sub check_and_render + { + my ($t) = @_; + my $path = qq($data_path/$t->{id}/.thumb); + my $printed = 0; + my $files = get_files($t->{id}); + foreach $f (@$files) + { + next unless ($f->{filename} =~ /(gif|jpe?g|png)$/i); + next unless (-e "$data_path/$f->{parent_id}/$f->{filename}"); + system($RM_PATH, "-f", "$path/t.".(lc($f->{filename}))); + if (! $printed) + { print qq(Generating thumbs for $t->{id} -- $t->{title}\n); $printed++; } + print "$f->{filename} "; + make_image_thumb({ file => $f, maxwidth => 145, maxheight => 110, key => $THUMB_LIBRARY_PREFIX }); + } + print qq(\n\n) if ($printed); + } + +# system("chown", "-R", "carbon:psacln", "$data_path"); + +$dbh->disconnect(); + |
