[MKDoc-commit] [1.6] Accept only JPEG,
strip EXIF and thumb quality now configurable
bruno at mkdoc.demon.co.uk
bruno at mkdoc.demon.co.uk
Thu Sep 1 16:12:29 BST 2005
Log Message:
-----------
[1.6] Accept only JPEG, strip EXIF and thumb quality now configurable
Tags:
----
mkdoc-1-6
Modified Files:
--------------
mkd:
INSTALL.TXT
MODULES.TXT
mkd/MKDoc:
Config.pm
mkd/MKDoc/Site/ConfigWriter:
Httpd_Conf.pm
mkd/flo/editor:
Photo.pm
-------------- next part --------------
Index: INSTALL.TXT
===================================================================
RCS file: /var/spool/cvs/mkd/INSTALL.TXT,v
retrieving revision 1.3.2.33
retrieving revision 1.3.2.34
diff -LINSTALL.TXT -LINSTALL.TXT -u -r1.3.2.33 -r1.3.2.34
--- INSTALL.TXT
+++ INSTALL.TXT
@@ -152,7 +152,7 @@
DBD::mysql
Date::Manip
MIME::Base64 (not required when using perl-5.8.1 or later)
- Image::Magick
+ Image::Magick (5.5.8 or greater required)
XML::Parser
(the remaining packages can be found on CPAN)
Index: MODULES.TXT
===================================================================
RCS file: /var/spool/cvs/mkd/MODULES.TXT,v
retrieving revision 1.3.2.24
retrieving revision 1.3.2.25
diff -LMODULES.TXT -LMODULES.TXT -u -r1.3.2.24 -r1.3.2.25
--- MODULES.TXT
+++ MODULES.TXT
@@ -38,7 +38,7 @@
DateTime::TimeZone
# Image manipulation:
- Image::Magick v5.48
+ Image::Magick v5.5.8
# Cache management
Cache::Cache 1.01
Index: Config.pm
===================================================================
RCS file: /var/spool/cvs/mkd/MKDoc/Config.pm,v
retrieving revision 1.8.2.47
retrieving revision 1.8.2.48
diff -LMKDoc/Config.pm -LMKDoc/Config.pm -u -r1.8.2.47 -r1.8.2.48
--- MKDoc/Config.pm
+++ MKDoc/Config.pm
@@ -283,6 +283,7 @@
'flo.plugin.Photo.scaled_max_y' => get_env ('MKD__PLUGIN_PHOTO_SCALED_Y') || 384,
'flo.plugin.Photo.thumb_max_x' => get_env ('MKD__PLUGIN_PHOTO_THUMB_X') || 256,
'flo.plugin.Photo.thumb_max_y' => get_env ('MKD__PLUGIN_PHOTO_THUMB_Y') || 128,
+ 'flo.plugin.Photo.quality' => get_env ('MKD__PLUGIN_PHOTO_QUALITY') || 50,
'flo.plugin.Poll.cookie_name' => get_env ('MKD__PLUGIN_POLL_COOKIE') || 'MKD_Poll_',
'flo.plugin.Search.per_page' => get_env ('MKD__PLUGIN_SEARCH_PER_PAGE') || 10,
'flo.plugin.Sitemap.MAX_DEPTH' => get_env ('MKD__PLUGIN_SITEMAP_DEPTH') || 2,
Index: Httpd_Conf.pm
===================================================================
RCS file: /var/spool/cvs/mkd/MKDoc/Site/ConfigWriter/Httpd_Conf.pm,v
retrieving revision 1.1.2.42
retrieving revision 1.1.2.43
diff -LMKDoc/Site/ConfigWriter/Httpd_Conf.pm -LMKDoc/Site/ConfigWriter/Httpd_Conf.pm -u -r1.1.2.42 -r1.1.2.43
--- MKDoc/Site/ConfigWriter/Httpd_Conf.pm
+++ MKDoc/Site/ConfigWriter/Httpd_Conf.pm
@@ -193,6 +193,9 @@
# SetEnv MKD__PLUGIN_PHOTO_SCALED_X 640
# SetEnv MKD__PLUGIN_PHOTO_SCALED_Y 480
+# uncomment if you want to change the JPEG quality of photo thumbnails
+# SetEnv MKD__PLUGIN_PHOTO_QUALITY 50
+
# Uncomment if you want to change the amount of returned results
# per page on the search page
# SetEnv MKD__PLUGIN_SEARCH_PER_PAGE 10
Index: Photo.pm
===================================================================
RCS file: /var/spool/cvs/mkd/flo/editor/Photo.pm,v
retrieving revision 1.11.2.43
retrieving revision 1.11.2.44
diff -Lflo/editor/Photo.pm -Lflo/editor/Photo.pm -u -r1.11.2.43 -r1.11.2.44
--- flo/editor/Photo.pm
+++ flo/editor/Photo.pm
@@ -233,6 +233,7 @@
$new_image_no_slash =~ s/^.*\\//g;
my $new_image_friendly = $self->normalize_name ($new_image_no_slash);
+ return $self unless $new_image_friendly =~ /\.(jpeg|jpg|jfif|jpe)$/i;
my $dir = $self->compute_name;
my $dir_thumbnail = "$dir/thumbnail";
@@ -258,11 +259,14 @@
my $scaled_max_y = $config->get ('scaled_max_y');
my $thumb_max_x = $config->get ('thumb_max_x');
my $thumb_max_y = $config->get ('thumb_max_y');
+ my $quality = $config->get ('quality');
my $image = new Image::Magick;
my $retcode = $image->Read ("$full_dir/$new_image_friendly");
die $retcode if (defined $retcode and $retcode =~ /exception/i);
+ $image->Strip; # requires $Image::Magick::VERSION >= 5.5.8
+ $image->Set (quality => $quality);
$image->Resize (geometry => $scaled_max_x . 'x' . $scaled_max_y);
$image->Write ("$full_dir_scaled/$new_image_friendly");
$image->Resize (geometry => $thumb_max_x . 'x' . $thumb_max_y);
More information about the MKDoc-commit
mailing list