~mdw
/
tgal
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
mason/.perl-lib/TrivGal.pm: Use GraphicsMagick rather than Imlib2.
[tgal]
/
mason
/
.perl-lib
/
TrivGal.pm
diff --git
a/mason/.perl-lib/TrivGal.pm
b/mason/.perl-lib/TrivGal.pm
index
4e5527b
..
f498894
100644
(file)
--- a/
mason/.perl-lib/TrivGal.pm
+++ b/
mason/.perl-lib/TrivGal.pm
@@
-30,8
+30,8
@@
use autodie qw{:all};
use Errno;
use Exporter qw{import};
use File::stat;
use Errno;
use Exporter qw{import};
use File::stat;
+use Graphics::Magick;
use Image::ExifTool qw{};
use Image::ExifTool qw{};
-use Image::Imlib2;
use Image::Size qw{};
use User::pwent;
use POSIX;
use Image::Size qw{};
use User::pwent;
use POSIX;
@@
-259,6
+259,11
@@
package TrivGal::Image {
sub wd ($) { my ($me) = @_; $me->_getexif; return $me->{wd}; }
sub ht ($) { my ($me) = @_; $me->_getexif; return $me->{ht}; }
sub wd ($) { my ($me) = @_; $me->_getexif; return $me->{wd}; }
sub ht ($) { my ($me) = @_; $me->_getexif; return $me->{ht}; }
+ sub _check_gm ($) {
+ my ($rc) = @_;
+ "$rc" and die "failed to hack `$me->{img}': $rc";
+ }
+
sub scale ($$;$) {
my ($me, $scale, $forcep) = @_;
my $m = HTML::Mason::Request->instance;
sub scale ($$;$) {
my ($me, $scale, $forcep) = @_;
my $m = HTML::Mason::Request->instance;
@@
-284,22
+289,16
@@
package TrivGal::Image {
} else {
my $img = $me->{img};
unless (defined $img) {
} else {
my $img = $me->{img};
unless (defined $img) {
- $me->_getexif;
- $img = $me->{img} = Image::Imlib2->load($me->{imgpath});
- if ($me->{rot}) { $img->image_orientate($me->{rot}); }
- if ($me->{flip}) { $img->flip_horizontal(); }
+ $img = $me->{img} = Graphics::Magick->new;
+ _check_gm $img->Read($me->{imgpath});
}
my ($dir, undef, $ext) = TrivGal::split_path $thumb;
}
my ($dir, undef, $ext) = TrivGal::split_path $thumb;
- my $ty = $TYPE{lc $ext} or die "unknown type `$ext'";
- my $sc = $sz/$me->sz;
- my $scaled = $img->create_scaled_image($sc*$wd, $sc*$ht);
-
- $scaled->image_set_format($ty->imlibfmt);
- $scaled->set_quality(90);
- my $new = "$TMP/t$$-$ext";
+ $img = $img->Clone;
+ my $new = "$TMP/t$$-thumb$ext";
+ _check_gm $img->Resize(geometry => $sz);
make_path $TMP, { mode => 0771 };
make_path $TMP, { mode => 0771 };
-
$scaled->sav
e($new);
+
_check_gm $img->Writ
e($new);
make_path $dir, { mode => 0771 };
rename $new, $thumb;
$url = $thumburl;
make_path $dir, { mode => 0771 };
rename $new, $thumb;
$url = $thumburl;