Assorted infobox bugfixing.
authorSteinar H. Gunderson <sesse@debian.org>
Mon, 26 May 2008 19:59:53 +0000 (21:59 +0200)
committerSteinar H. Gunderson <sesse@debian.org>
Mon, 26 May 2008 19:59:53 +0000 (21:59 +0200)
files/pr0n-fullscreen.css
files/pr0n-fullscreen.js
perl/Sesse/pr0n/Common.pm

index 145dd9dc138ede207c3f328491561a18087a7c93..7f93aff2fd4e06b74a5b20528e8e1149fc419491 100644 (file)
@@ -34,7 +34,7 @@ img, #text {
        z-index: 2;
 }
 
-#preload {
+#preload, #preload_box {
        position: absolute;
        left: -2000px;
        top: -2000px;
index bbc287a2f94d75b0a90eabf487896d5d34252175..7b890036f93a695559f5ad85aec941b2e4c2ea2a 100644 (file)
@@ -194,6 +194,12 @@ function prepare_preload(img, num)
                preload.src = "data:";
                preload.parentNode.removeChild(preload);
        }
+       
+       var preload_box = document.getElementById("preload_box");
+       if (preload_box !== null) {
+               preload_box.src = "data:";
+               preload_box.parentNode.removeChild(preload_box);
+       }
 
        // grmf -- IE doesn't fire onload if the image was loaded from cache, so check for
        // completeness first; should at least be _somewhat_ better
index dbf6a054bb9074ebde584c30b3ee03d6e66c68b2..027268a2c469faeeb2b5d232d91e619753a8b341 100644 (file)
@@ -569,14 +569,23 @@ sub ensure_cached {
                        if (defined($xres) && defined($yres)) {
                                ($width, $height) = scale_aspect($width, $height, $xres, $yres);
                        }
-                       $img->Set(size=>($width . "x24"));
+                       $height = 24;
+                       $img->Set(size=>($width . "x" . $height));
                        $img->Read('xc:white');
                                
                        my $info = Image::ExifTool::ImageInfo($fname);
-                       make_infobox($img, $info, $r);
+                       if (!make_infobox($img, $info, $r)) {
+                               # Not enough room for the text, make a tiny dummy transparent infobox
+                               @$img = ();
+                               $img->Set(size=>"1x1");
+                               $img->Read('null:');
+
+                               $width = 1;
+                               $height = 1;
+                       }
                                
                        $err = $img->write(filename => $cachename);
-                       $r->log->info("New infobox cache: $width x 24 for $id.jpg");
+                       $r->log->info("New infobox cache: $width x $height for $id.jpg");
                        
                        return ($cachename, 'image/png');
                }
@@ -777,7 +786,7 @@ sub make_infobox {
                }
        }
 
-       return if (scalar @parts == 0);
+       return if (scalar @parts == 0);
 
        # Find the required width
        my $th = 0;
@@ -797,7 +806,7 @@ sub make_infobox {
                $th = $h if ($h > $th);
        }
 
-       return if ($tw > $img->Get('columns'));
+       return if ($tw > $img->Get('columns'));
 
        my $x = 0;
        my $y = $img->Get('rows') - 24;
@@ -826,6 +835,8 @@ sub make_infobox {
                $img->Annotate(text=>$part->[0], font=>$font, pointsize=>12, x=>int($x), y=>int($y));
                $x += ($img->QueryFontMetrics(text=>$part->[0], font=>$font, pointsize=>12))[4];
        }
+
+       return 1;
 }
 
 sub gcd {