]> git.sesse.net Git - pr0n/blobdiff - perl/Sesse/pr0n/Common.pm
Actually implement filtering.
[pr0n] / perl / Sesse / pr0n / Common.pm
index d7a081d1f8241bc6e7e6805b63a13906461d7c3b..e12e8dc53efa85bba94a5a3221c37ab58025980f 100644 (file)
@@ -34,7 +34,7 @@ BEGIN {
                require Sesse::pr0n::Config_local;
        };
 
-       $VERSION     = "v2.40";
+       $VERSION     = "v2.41";
        @ISA         = qw(Exporter);
        @EXPORT      = qw(&error &dberror);
        %EXPORT_TAGS = qw();
@@ -129,6 +129,9 @@ sub get_query_string {
        while (my ($key, $value) = each %$param) {
                next unless defined($value);
                next if (defined($defparam->{$key}) && $value == $defparam->{$key});
+
+               # FIXME: We'll need to escape _ here somehow
+               $value =~ s/ /_/g;
        
                $str .= ($first) ? "?" : ';';
                $str .= "$key=$value";
@@ -375,10 +378,12 @@ sub ensure_cached {
                        # Use lanczos (sharper) for heavy scaling, mitchell (faster) otherwise
                        my $filter = 'Mitchell';
                        my $quality = 90;
+                       my $sf = undef;
 
                        if ($width / $nwidth > 8.0 || $height / $nheight > 8.0) {
                                $filter = 'Lanczos';
-                               $quality = 80;
+                               $quality = 85;
+                               $sf = "1x1";
                        }
 
                        if ($xres != -1) {
@@ -392,11 +397,19 @@ sub ensure_cached {
                        # Strip EXIF tags etc.
                        $cimg->Strip();
 
-                       if (($nwidth >= 640 && $nheight >= 480) ||
-                           ($nwidth >= 480 && $nheight >= 640)) {
-                               $err = $cimg->write(filename=>$cachename, quality=>$quality, interlace=>'Plane');
-                       } else {
-                               $err = $cimg->write(filename=>$cachename, quality=>$quality);
+                       {
+                               my %parms = (
+                                       filename => $cachename,
+                                       quality => $quality
+                               );
+                               if (($nwidth >= 640 && $nheight >= 480) ||
+                                   ($nwidth >= 480 && $nheight >= 640)) {
+                                       $parms{'interlace'} = 'Plane';
+                               }
+                               if (defined($sf)) {
+                                       $parms{'sampling-factor'} = $sf;
+                               }
+                               $err = $cimg->write(%parms);
                        }
 
                        undef $cimg;