Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Item13008: improve rendering thumbnails
- only render the first frame of a gif animation generating thumbnails
- fix orientation of thumbnail as specified in the EXIF metadata
  • Loading branch information
MichaelDaum committed Aug 28, 2014
1 parent fbc3a0e commit d553f22
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 13 deletions.
10 changes: 10 additions & 0 deletions .gitignore
@@ -0,0 +1,10 @@
*.gz
*.swp
pub/System/ImageGalleryPlugin/style.css
ImageGalleryPlugin.md5
ImageGalleryPlugin.sha1
ImageGalleryPlugin.tgz
ImageGalleryPlugin.txt
ImageGalleryPlugin.zip
ImageGalleryPlugin_installer
ImageGalleryPlugin_installer.pl
9 changes: 4 additions & 5 deletions data/System/ImageGalleryPlugin.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" date="1252914561" format="1.1" version="1.3"}%
%META:TOPICINFO{author="ProjectContributor" date="1252914561" format="1.1" version="1"}%
---+!! <nop>ImageGalleryPlugin
%TOC%

Expand Down Expand Up @@ -153,11 +153,12 @@ Note, that the $comment variable will only display =&lt;comment&gt;= , that is w
* Set SHORTDESCRIPTION = Displays image gallery with auto-generated thumbnails from attachments.
-->
| Plugin Author: | Michael Daum, Will Norris |
| Copyright &copy;: | 2002-2009, Will Norris; 2005-2012, Michael Daum http://michaeldaumconsulting.com |
| Copyright &copy;: | 2002-2009, Will Norris; 2005-2014, Michael Daum http://michaeldaumconsulting.com |
| License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) |
| Release: | %$RELEASE% |
| Version: | %$VERSION% |
| Change History: | <!-- versions below in reverse order -->&nbsp; |
| 28 Aug 2014 | only render the first frame of a gif animation generating thumbnails; fix orientation of thumbnail as specified in the EXIF metadata |
| 29 Nov 2012 | removed useless call to =expandCommonVariables=; removed non-functional <nop>UserListByPhotograph |
| 06 Jun 2011 | added support for Foswiki:Extensions/LazyLoadPlugin and Foswiki:Extensions/JQPrettyPhotoContrib; \
deferring expansion of IMAGEGALLERY until other plugins have updated the page |
Expand Down Expand Up @@ -202,9 +203,7 @@ Note, that the $comment variable will only display =&lt;comment&gt;= , that is w
| 01 Aug 2003 | Updates from feedback from a Windows installation |
| 25 Jul 2003 | Initial version |
| 15 Mar 2002 | Initial (internal) version |
| CPAN Dependencies: | %$DEPENDENCIES% |
| Other Dependencies: | |
| Perl Version: | 5.8 |
| Dependencies: | %$DEPENDENCIES% |
| Plugin Home: | Foswiki:Extensions/%TOPIC% |
| Support: | Foswiki:Support/%TOPIC% |

Expand Down
7 changes: 4 additions & 3 deletions lib/Foswiki/Plugins/ImageGalleryPlugin.pm
@@ -1,5 +1,5 @@
# Copyright (C) 2002-2009 Will Norris. All Rights Reserved. (wbniv@saneasylumstudios.com)
# Copyright (C) 2005-2011 Michael Daum http://michaeldaumconsulting.com
# Copyright (C) 2005-2014 Michael Daum http://michaeldaumconsulting.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand All @@ -15,10 +15,11 @@
# =========================
package Foswiki::Plugins::ImageGalleryPlugin;
use strict;
use warnings;

# =========================
our $VERSION = '6.11';
our $RELEASE = '6.11';
our $VERSION = '6.20';
our $RELEASE = '6.20';
our $NO_PREFS_IN_TOPIC = 1;
our $SHORTDESCRIPTION = 'Displays image gallery with auto-generated thumbnails from attachments';
our $isInitialized;
Expand Down
31 changes: 26 additions & 5 deletions lib/Foswiki/Plugins/ImageGalleryPlugin/Core.pm
@@ -1,7 +1,7 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2002-2009 Will Norris. All Rights Reserved. (wbniv@saneasylumstudios.com)
# Copyright (C) 2005-2011 Michael Daum http://michaeldaumconsulting.com
# Copyright (C) 2005-2014 Michael Daum http://michaeldaumconsulting.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand All @@ -18,10 +18,12 @@
package Foswiki::Plugins::ImageGalleryPlugin::Core;

use strict;
use warnings;

use Foswiki::Func ();
use Foswiki::Plugins ();
use constant DEBUG => 0; # toggle me
use vars qw(%imageSuffixes);
use constant TRACE => 0; # toggle me
our %imageSuffixes;

# =========================
# constructor
Expand Down Expand Up @@ -889,7 +891,10 @@ sub processImage {

# read
#writeDebug("mage->read($image->{IGP_filename})");
my $error = $this->{mage}->Read($image->{IGP_filename});
my $source = $image->{IGP_filename};
$source .= '[0]' if $source =~ /\.gif$/i; # extract the first frame only

my $error = $this->{mage}->Read($source);
#writeDebug("done read");
if ($error =~ /(\d+)/) {
#writeDebug("Read(): error=$error");
Expand All @@ -913,6 +918,22 @@ sub processImage {
return 0 if $1 >= 400;
}

# auto orient
$error = $this->{mage}->AutoOrient();
if ($error =~ /(\d+)/) {
$this->{errorMsg} = $error;
writeDebug("Error: $error");
return undef if $1 >= 400;
}

# strip of profiles and comments
$error = $this->{mage}->Strip();
if ($error =~ /(\d+)/) {
$this->{errorMsg} = $error;
writeDebug("Error: $error");
return undef if $1 >= 400;
}

# write
#writeDebug("mage->write($target)");
$error = $this->{mage}->Write($target);
Expand Down Expand Up @@ -1078,7 +1099,7 @@ sub writeInfo {
# static
sub writeDebug {
#Foswiki::Func::writeDebug("ImageGalleryPlugin - $_[0]");
print STDERR "ImageGalleryPlugin - $_[0]\n" if DEBUG;
print STDERR "ImageGalleryPlugin - $_[0]\n" if TRACE;
}

1;

0 comments on commit d553f22

Please sign in to comment.