Mail Index
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ApacheGallery] Patch to replace inline C code with native Perl
Crap. Forgot to attach the patch. Sorry.
-Jon
diff -Nur Apache-Gallery-0.5.1/INSTALL Apache-Gallery-0.5.1.new/INSTALL
--- Apache-Gallery-0.5.1/INSTALL Fri Nov 8 02:56:43 2002
+++ Apache-Gallery-0.5.1.new/INSTALL Tue Mar 11 18:46:03 2003
@@ -14,16 +14,9 @@
- URI::Escape
- Image::Info
- Image::Size
+- Image::Magick
- CGI::FastTemplate
-- Inline::C
- X11 libraries (ie, XFree86)
-- Imlib2 (http://prdownloads.sourceforge.net/enlightenment/imlib2-1.0.3.tar.gz)
-
-When installing Imlib2 from rpm, deb or other packages formats, remember
-that you need the imlib2-dev package too. On Debian this can be installed
-with:
-
-apt-get install libimlib2-dev
Then, to install Apache::Gallery run the following commands:
@@ -53,10 +46,6 @@
Copy the files from templates/ to where you pointed GalleryTemplateDir to,
copy htdocs/folder.png and htdocs/video-*.png to your Apache icons
directory and copy htdocs/gallery.css to the DocumentRoot of your gallery.
-
-Make sure your httpd can write to the temporary directory (usually /tmp).
-This will be used by the Inline module to compile the c-code used to
-access functions in Imlib2.
It is possible to include a graphical copyright notice on each picture now.
By setting the GalleryCopyrightImage PerlSetVar you can define the path
diff -Nur Apache-Gallery-0.5.1/Makefile.PL Apache-Gallery-0.5.1.new/Makefile.PL
--- Apache-Gallery-0.5.1/Makefile.PL Fri Sep 20 01:42:51 2002
+++ Apache-Gallery-0.5.1.new/Makefile.PL Tue Mar 11 18:45:25 2003
@@ -8,8 +8,8 @@
'PREREQ_PM' => {
Image::Info => 0,
Image::Size => 0,
+ Image::Magick => 0,
CGI::FastTemplate => 0,
- Inline => 0,
mod_perl => 0,
URI::Escape => 0,
Apache::Request => 0,
diff -Nur Apache-Gallery-0.5.1/README Apache-Gallery-0.5.1.new/README
--- Apache-Gallery-0.5.1/README Tue Oct 22 13:42:08 2002
+++ Apache-Gallery-0.5.1.new/README Tue Mar 11 18:46:13 2003
@@ -120,8 +120,8 @@
URI::Escape
Image::Info
Image::Size
+ Image::Magick
CGI::FastTemplate
- Inline::C
X11 libraries (ie, XFree86)
Imlib2 Remember the -dev package when using rpm, deb or other package
formats!
diff -Nur Apache-Gallery-0.5.1/lib/Apache/Gallery.pm Apache-Gallery-0.5.1.new/lib/Apache/Gallery.pm
--- Apache-Gallery-0.5.1/lib/Apache/Gallery.pm Thu Oct 24 05:41:54 2002
+++ Apache-Gallery-0.5.1.new/lib/Apache/Gallery.pm Tue Mar 11 18:47:00 2003
@@ -15,6 +15,7 @@
use Image::Info qw(image_info);
use Image::Size qw(imgsize);
+use Image::Magick;
use CGI::FastTemplate;
use File::stat;
use File::Spec;
@@ -24,14 +25,6 @@
# Regexp for escaping URI's
my $escape_rule = "^A-Za-z0-9\-_.!~*'()\/";
-use Inline C => Config =>
- LIBS => '-L/usr/X11R6/lib -lImlib2 -lm -ldl -lXext -lXext',
- DIRECTORY => File::Spec->tmpdir(),
- INC => '-I/usr/X11R6/include';
-
-use Inline 'C';
-Inline->init;
-
sub handler {
my $r = shift or Apache->request();
@@ -208,6 +201,8 @@
$tpl->assign(FILE => $file);
$tpl->assign(DATE => $imageinfo->{DateTimeOriginal} ? $imageinfo->{DateTimeOriginal} : ''); # should this really be a stat of the file instead of ''?
$tpl->assign(SRC => uri_escape($uri."/.cache/$cached", $escape_rule));
+ $tpl->assign(WIDTH => $thumbnailwidth);
+ $tpl->assign(HEIGHT => $thumbnailheight);
$tpl->parse(FILES => '.picture');
@@ -320,6 +315,8 @@
$tpl->assign(MENU => generate_menu($r));
$tpl->assign(SRC => ".cache/".$cached);
$tpl->assign(URI => $r->uri());
+ $tpl->assign(PICTURE_WIDTH => $image_width);
+ $tpl->assign(PICTURE_HEIGHT => $height);
unless (opendir(DATADIR, $path)) {
show_error($r, "Unable to access directory", "Unable to access directory $path");
@@ -353,6 +350,8 @@
$tpl->assign(URL => uri_escape($prevpicture, $escape_rule));
$tpl->assign(FILENAME => $prevpicture);
$tpl->assign(WIDTH => $width);
+ $tpl->assign(THUMB_WIDTH => $thumbnailwidth);
+ $tpl->assign(THUMB_HEIGHT => $thumbnailheight);
$tpl->assign(PICTURE => uri_escape(".cache/$cached", $escape_rule));
$tpl->assign(DIRECTION => "Prev");
$tpl->parse(BACK => "navpicture");
@@ -373,6 +372,8 @@
$tpl->assign(URL => uri_escape($nextpicture, $escape_rule));
$tpl->assign(FILENAME => $nextpicture);
$tpl->assign(WIDTH => $width);
+ $tpl->assign(THUMB_WIDTH => $thumbnailwidth);
+ $tpl->assign(THUMB_HEIGHT => $thumbnailheight);
$tpl->assign(PICTURE => uri_escape(".cache/$cached", $escape_rule));
$tpl->assign(DIRECTION => "Next");
$tpl->parse(NEXT => "navpicture");
@@ -832,76 +833,46 @@
}
-1;
-__DATA__
-__C__
+sub resizepicture {
-#include <X11/Xlib.h>
-#include <Imlib2.h>
-#include <stdio.h>
-#include <string.h>
-
-int resizepicture(char* infile, char* outfile, int x, int y, int rotate, char* copyrightfile) {
-
- Imlib_Image image;
- Imlib_Image buffer;
- Imlib_Image logo;
- int logo_x, logo_y;
- int old_x;
- int old_y;
-
- image = imlib_load_image(infile);
-
- imlib_context_set_image(image);
- imlib_context_set_blend(1);
- imlib_context_set_anti_alias(1);
-
- old_x = imlib_image_get_width();
- old_y = imlib_image_get_height();
+ my ($infile, $outfile, $width, $height, $rotate, $copyrightfile) = @_;
+ my $x;
- buffer = imlib_create_image(x,y);
- imlib_context_set_image(buffer);
-
- imlib_blend_image_onto_image(image, 0, 0, 0, old_x, old_y, 0, 0, x, y);
+ my $image = new Image::Magick;
+ $x = $image->Read($infile);
+ warn "$x" if "$x";
- imlib_context_set_image(buffer);
-
- if (rotate != 0) {
- imlib_image_orientate(rotate);
- }
- if (strcmp(copyrightfile, "") != 0) {
- logo = imlib_load_image(copyrightfile);
+ $x = $image->Resize(geometry => "$width" . "x" . "$height",
+ filter => "Box",
+ blur => 0.5);
+ warn "$x" if "$x";
- imlib_context_set_image(buffer);
+ if ($rotate != 0) {
+ $x = $image->Rotate($rotate * 90);
+ warn "$x" if "$x";
+ }
- x = imlib_image_get_width();
- y = imlib_image_get_height();
-
- imlib_context_set_image(logo);
-
- logo_x = imlib_image_get_width();
- logo_y = imlib_image_get_height();
+ if ($copyrightfile ne "") {
+ my $copyrightimage = Image::Magick->new;
+ $x = $copyrightimage->Read("png:$copyrightfile");
+ warn "$x" if "$x";
- imlib_context_set_image(buffer);
- imlib_blend_image_onto_image(logo, 0, 0, 0, logo_x, logo_y, x-logo_x, y-logo_y, logo_x, logo_y);
+ $x = $image->Composite(image => $copyrightimage,
+ compose => "Over",
+ gravity => "SouthEast");
+ warn "$x" if "$x";
- imlib_context_set_image(logo);
- imlib_free_image();
- imlib_context_set_image(buffer);
+ undef $copyrightimage;
}
- imlib_save_image(outfile);
-
- imlib_context_set_image(image);
- imlib_free_image();
-
- imlib_context_set_image(buffer);
- imlib_free_image();
+ $x = $image->Write(filename => $outfile);
+ warn "$x" if "$x";
return 1;
}
-__END__
+
+1;
=head1 NAME
@@ -1058,8 +1029,6 @@
=item B<CGI::FastTemplate>
-=item B<Inline::C>
-
=item B<X11 libraries>
(ie, XFree86)
@@ -1097,7 +1066,7 @@
=head1 SEE ALSO
-L<perl>, L<mod_perl>, L<Apache::Request>, L<Inline::C>, L<CGI::FastTemplate>,
-L<Image::Info>, and L<Image::Size>.
+L<perl>, L<mod_perl>, L<Apache::Request>, L<CGI::FastTemplate>,
+L<Image::Info>, L<Image::Magick>, and L<Image::Size>.
=cut
diff -Nur Apache-Gallery-0.5.1/templates/directory.tpl Apache-Gallery-0.5.1.new/templates/directory.tpl
--- Apache-Gallery-0.5.1/templates/directory.tpl Sun Jul 28 13:11:10 2002
+++ Apache-Gallery-0.5.1.new/templates/directory.tpl Fri Mar 7 19:30:21 2003
@@ -1 +1 @@
- <div id="folder"><a href="$FILEURL"><img border="0" src="/icons/folder.png"><br>$FILE</a></div>
+ <div id="folder"><a href="$FILEURL"><img border="0" src="/icons/folder.png" width="48" height="48"><br>$FILE</a></div>
diff -Nur Apache-Gallery-0.5.1/templates/movie.tpl Apache-Gallery-0.5.1.new/templates/movie.tpl
--- Apache-Gallery-0.5.1/templates/movie.tpl Sun Jul 28 13:11:10 2002
+++ Apache-Gallery-0.5.1.new/templates/movie.tpl Fri Mar 7 19:30:34 2003
@@ -1 +1 @@
- <div id="folder"><a href="$FILEURL"><img border="0" alt="$ALT" src="/icons/video-$TYPE.png"><br>$FILE</a></div>
+ <div id="folder"><a href="$FILEURL"><img border="0" alt="$ALT" src="/icons/video-$TYPE.png" width="48" height="48"><br>$FILE</a></div>
diff -Nur Apache-Gallery-0.5.1/templates/navpicture.tpl Apache-Gallery-0.5.1.new/templates/navpicture.tpl
--- Apache-Gallery-0.5.1/templates/navpicture.tpl Sun Jul 28 13:11:10 2002
+++ Apache-Gallery-0.5.1.new/templates/navpicture.tpl Fri Mar 7 19:33:13 2003
@@ -1 +1 @@
-<a href="$URL?width=$WIDTH" class="nav"><img src="$PICTURE"><br>$DIRECTION - $FILENAME</a>
+<a href="$URL?width=$WIDTH" class="nav"><img src="$PICTURE" width="$THUMB_WIDTH" height="$THUMB_HEIGHT"><br>$DIRECTION - $FILENAME</a>
diff -Nur Apache-Gallery-0.5.1/templates/picture.tpl Apache-Gallery-0.5.1.new/templates/picture.tpl
--- Apache-Gallery-0.5.1/templates/picture.tpl Sun Jul 28 13:11:10 2002
+++ Apache-Gallery-0.5.1.new/templates/picture.tpl Fri Mar 7 20:12:10 2003
@@ -1 +1 @@
- <a href="$FILEURL"><img alt="$FILE - $DATE" src="$SRC"></a>
+ <a href="$FILEURL"><img alt="$FILE - $DATE" src="$SRC" width="$WIDTH" height="$HEIGHT"></a>
diff -Nur Apache-Gallery-0.5.1/templates/showpicture.tpl Apache-Gallery-0.5.1.new/templates/showpicture.tpl
--- Apache-Gallery-0.5.1/templates/showpicture.tpl Wed Sep 11 13:01:31 2002
+++ Apache-Gallery-0.5.1.new/templates/showpicture.tpl Fri Mar 7 20:11:26 2003
@@ -8,7 +8,7 @@
<td colspan="3" id="picture">
<center class="nav">
Viewing picture $NUMBER of $TOTAL at $RESOLUTION pixels<br>
- <img src="$SRC"><br>
+ <img src="$SRC" width="$PICTURE_WIDTH" height="$PICTURE_HEIGHT"><br>
Size [ $SIZES ]<br>
Slideshow [ $SLIDESHOW ]
</center>