6 use Sesse::pr0n::Common;
10 use Sesse::pr0n::Config;
12 require Sesse::pr0n::Config_local;
15 my $dbh = DBI->connect("dbi:Pg:dbname=pr0n;host=" . $Sesse::pr0n::Config::db_host,
16 $Sesse::pr0n::Config::db_username, $Sesse::pr0n::Config::db_password)
17 or die "Couldn't connect to PostgreSQL database: " . DBI->errstr;
18 $dbh->{RaiseError} = 1;
20 # TODO: Do we need to care about renders?
22 my $dir = POSIX::floor($id / 256);
23 my $base = $Sesse::pr0n::Config::image_base . "cache/$dir";
25 for my $file (<$base/$id-*-nobox.jpg>) { # TODO: --1--1.jpg, too.
26 my $fname = File::Basename::basename($file);
27 my ($width, $height) = $fname =~ /^$id-(\d+)-(\d+)-nobox\.jpg$/ or die $fname;
28 (my $jxl_file = $file) =~ s/jpg$/jxl/;
29 unless (-r $jxl_file) {
30 push @res, ($width, $height);
31 print "$id to $width x $height...\n";
34 if (scalar @res > 0) {
35 my $filename = Sesse::pr0n::Common::get_disk_location({}, $id);
37 # Look up the width/height in the database.
38 my ($dbwidth, $dbheight);
39 my $ref = $dbh->selectrow_hashref('SELECT width,height FROM images WHERE id=?', undef, $id);
40 $dbwidth = $ref->{'width'};
41 $dbheight = $ref->{'height'};
43 Sesse::pr0n::Common::make_cache({}, $filename, $id, $dbwidth, $dbheight, 'jxl', @res);