Mail Index
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ApacheGallery] Patch for backgrounded copyright text
Hi everybody,
on my search for an gallery i finally stumbled over a::g and i liked it. But
prefer to have a copyright-text which can always be read so i added support
for text with background.
A patch is attached. It's patched against the source from the debian-package
in testing (v. 0.99-svn050524-1), as that's the one i had. I know that that
was sub-optimal. If needed i can diff it to another source.
An addidional variable is added:
GalleryCopyrightBackgroundColor 'r,g,b,a'
If it exists a colored rectangle in the specified color is drawn beneath the
actual text.
I use it to have my white text surrounded by a transparent black box, so that
it's visible on white areas of the pictures.
An example can be found here:
http://www.tbbd.de/agex.jpg
Hope anyone finds it useful.
Cya
Arne
--- Gallery.pm 2005-05-24 13:33:29.000000000 +0200
+++ Gallery.pm.changed 2005-09-15 10:33:31.000000000 +0200
@@ -907,7 +907,7 @@
if ($width == $thumbnailwidth or $width == $thumbnailheight) {
- resizepicture($r, $fullpath, $newpath, $width, $height, $rotate, '', '', '', '', '');
+ resizepicture($r, $fullpath, $newpath, $width, $height, $rotate, '', '', '', '', '', '');
} else {
@@ -918,6 +918,7 @@
($r->dir_config('GalleryCopyrightColor') ? $r->dir_config('GalleryCopyrightColor') : ''),
($r->dir_config('GalleryTTFFile') ? $r->dir_config('GalleryTTFFile') : ''),
($r->dir_config('GalleryTTFSize') ? $r->dir_config('GalleryTTFSize') : ''),
+ ($r->dir_config('GalleryCopyrightBackgroundColor') ? $r->dir_config('GalleryCopyrightBackgroundColor') : ''),
$quality);
}
@@ -1339,7 +1340,7 @@
}
sub resizepicture {
- my ($r, $infile, $outfile, $x, $y, $rotate, $copyrightfile, $GalleryTTFDir, $GalleryCopyrightText, $text_color, $GalleryTTFFile, $GalleryTTFSize, $quality) = @_;
+ my ($r, $infile, $outfile, $x, $y, $rotate, $copyrightfile, $GalleryTTFDir, $GalleryCopyrightText, $text_color, $GalleryTTFFile, $GalleryTTFSize, $bg_color, $quality) = @_;
# Load image
my $image = Image::Imlib2->load($infile) or warn("Unable to open file $infile, $!");
@@ -1384,10 +1385,6 @@
$GalleryTTFFile =~ s/\.TTF$//i;
$image->add_font_path("$GalleryTTFDir");
- my ($r_val, $g_val, $b_val, $a_val) = split (/,/, $text_color);
-
- $image->set_colour($r_val, $g_val, $b_val, $a_val);
-
$image->load_font("$GalleryTTFFile/$GalleryTTFSize");
my($text_x, $text_y) = $image->get_text_size("$GalleryCopyrightText");
my $x = $image->get_width();
@@ -1396,6 +1393,13 @@
my $offset = 3;
if (($text_x < $x - $offset) && ($text_y < $y - $offset)) {
+ if ($bg_color ne'') {
+ my ($br_val, $bg_val, $bb_val, $ba_val) = split (/,/, $bg_color);
+ $image->set_colour($br_val, $bg_val, $bb_val, $ba_val);
+ $image->fill_rectangle ($x-$text_x-$offset, $y-$text_y-$offset, $text_x, $text_y);
+ }
+ my ($r_val, $g_val, $b_val, $a_val) = split (/,/, $text_color);
+ $image->set_colour($r_val, $g_val, $b_val, $a_val);
$image->draw_text($x-$text_x-$offset, $y-$text_y-$offset, "$GalleryCopyrightText");
} else {
Apache2::RequestUtil->request->log_error("Text is to big for the picture.\n");