]> git.sesse.net Git - pr0n/blobdiff - perl/Sesse/pr0n/Image.pm
Much better high-dpi support; makes images and text much clearer on such displays.
[pr0n] / perl / Sesse / pr0n / Image.pm
index e298dc317277e1e2613345776ba9923e84374eec..f4262e305df8e2773d97c19cb4017ac0de8900cc 100644 (file)
@@ -14,24 +14,30 @@ sub handler {
 #      }
 
        # Find the event and file name
-       my ($event,$filename,$xres,$yres);
-       my $infobox = 1;
-       if ($r->uri =~ m#^/([a-zA-Z0-9-]+)/original/(nobox/)?([a-zA-Z0-9._()-]+)$#) {
+       my ($event,$filename,$xres,$yres,$dpr);
+       my $infobox = 'both';
+       if ($r->uri =~ m#^/([a-zA-Z0-9-]+)/original/((?:no)?box/)?([a-zA-Z0-9._()-]+)$#) {
                $event = $1;
                $filename = $3;
-       } elsif ($r->uri =~ m#^/([a-zA-Z0-9-]+)/(\d+)x(\d+)/(nobox/)?([a-zA-Z0-9._()-]+)$#) {
+               $infobox = 'nobox' if (defined($2) && $2 eq 'nobox/');
+               $infobox = 'box' if (defined($2) && $2 eq 'box/');
+       } elsif ($r->uri =~ m#^/([a-zA-Z0-9-]+)/(\d+)x(\d+)(?:\@(\d+))?/((?:no)?box/)?([a-zA-Z0-9._()-]+)$#) {
                $event = $1;
-               $filename = $5;
+               $filename = $6;
                $xres = $2;
                $yres = $3;
-               $infobox = 0 if (defined($4));
-       } elsif ($r->uri =~ m#^/([a-zA-Z0-9-]+)/(nobox/)?([a-zA-Z0-9._()-]+)$#) {
+               $dpr = $4;
+               $infobox = 'nobox' if (defined($5) && $5 eq 'nobox/');
+               $infobox = 'box' if (defined($5) && $5 eq 'box/');
+       } elsif ($r->uri =~ m#^/([a-zA-Z0-9-]+)/((?:no)?box/)?([a-zA-Z0-9._()-]+)$#) {
                $event = $1;
                $filename = $3;
                $xres = -1;
                $yres = -1;
-               $infobox = 0 if (defined($2));
+               $infobox = 'nobox' if (defined($2) && $2 eq 'nobox/');
+               $infobox = 'box' if (defined($2) && $2 eq 'box/');
        }
+       $dpr //= 1;
 
        my ($id, $dbwidth, $dbheight);
        #if ($event eq 'single' && $filename =~ /^(\d+)\.jpeg$/) {
@@ -48,13 +54,10 @@ sub handler {
        $dbheight = $ref->{'height'};
 
        # Scale if we need to do so
-       my ($fname,$thumbnail) = Sesse::pr0n::Common::ensure_cached($r, $filename, $id, $dbwidth, $dbheight, $infobox, $xres, $yres);
+       my ($fname, $mime_type) = Sesse::pr0n::Common::ensure_cached($r, $filename, $id, $dbwidth, $dbheight, $infobox, $dpr, $xres, $yres);
 
        # Output the image to the user
-       my $mime_type;
-       if ($thumbnail) {
-               $mime_type = "image/jpeg";
-       } else {
+       if (!defined($mime_type)) {
                $mime_type = Sesse::pr0n::Common::get_mimetype_from_filename($filename);
        }
        $r->content_type($mime_type);