# We don't care about @otherres since each of these images are
# already pretty cheap to generate, but we need the exact width so we can make
# one in the right size.
- $r->log->warn("BOX: $infobox");
if ($infobox eq 'box') {
my ($img, $width, $height);
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)) {
+ $img->Quantize(colors=>16, dither=>'False');
+
+ # Since the image is grayscale, ImageMagick overrides us and writes this
+ # as grayscale anyway, but at least we get rid of the alpha channel this
+ # way.
+ $img->Set(type=>'Palette');
+ } else {
+ # 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");
+ $err = $img->write(filename => $cachename, quality => 90, depth => 8);
+ $r->log->info("New infobox cache: $width x $height for $id.jpg");
return ($cachename, 'image/png');
}
}
}
- return if (scalar @parts == 0);
+ return 0 if (scalar @parts == 0);
# Find the required width
my $th = 0;
$th = $h if ($h > $th);
}
- return if ($tw > $img->Get('columns'));
+ return 0 if ($tw > $img->Get('columns'));
my $x = 0;
my $y = $img->Get('rows') - 24;
$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 {