summaryrefslogtreecommitdiff
path: root/bin/populate-thumbs.pl
diff options
context:
space:
mode:
Diffstat (limited to 'bin/populate-thumbs.pl')
-rwxr-xr-xbin/populate-thumbs.pl48
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();
+