diff options
author | Yorhel <git@yorhel.nl> | 2013-01-05 13:06:18 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2013-01-05 13:06:18 +0100 |
commit | 5fb01aeb58c77d2abda4e11d72be2217215a0ce5 (patch) | |
tree | 5d59608330ebb3879b9183cbe239d356aa13151f /lib/VNDB/Handler/VNEdit.pm | |
parent | a208fac4225ab8775a57c72eca0f042ee743b7bc (diff) |
Don't use Multi for processing VN cover images
I used to do this to avoid loading Image::Magick in each TUWF process,
decreasing memory usage, and lowering the blocking time by avoiding too
much processing. Memory isn't much of a problem nowadays, and processing
images is fast enough, too, so this complexity isn't necessary anymore.
(Character images and screenshots pending)
Diffstat (limited to 'lib/VNDB/Handler/VNEdit.pm')
-rw-r--r-- | lib/VNDB/Handler/VNEdit.pm | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/VNDB/Handler/VNEdit.pm b/lib/VNDB/Handler/VNEdit.pm index da318e6e..c00b9a73 100644 --- a/lib/VNDB/Handler/VNEdit.pm +++ b/lib/VNDB/Handler/VNEdit.pm @@ -4,6 +4,7 @@ package VNDB::Handler::VNEdit; use strict; use warnings; use TUWF ':html', ':xml'; +use Image::Magick; use VNDB::Func; @@ -192,13 +193,22 @@ sub _uploadimage { $frm->{_err} = [ 'toolarge' ] if length($imgdata) > 5*1024*1024; return undef if $frm->{_err}; - # get image ID and save it, to be processed by Multi + # resize/compress + my $im = Image::Magick->new; + $im->BlobToImage($imgdata); + $im->Set(magick => 'JPEG'); + my($ow, $oh) = ($im->Get('width'), $im->Get('height')); + my($nw, $nh) = imgsize($ow, $oh, @{$self->{ch_size}}); + $im->Thumbnail(width => $nw, height => $nh); + $im->Set(quality => 90); + + # Get ID and save my $imgid = $self->dbVNImageId; my $fn = imgpath(cv => $imgid); - $self->reqSaveUpload('img', $fn); + $im->Write($fn); chmod 0666, $fn; - return -1*$imgid; + return $imgid; } @@ -227,8 +237,7 @@ sub _form { vn_img => [ mt('_vnedit_image'), [ static => nolabel => 1, content => sub { div class => 'img'; p mt '_vnedit_image_none' if !$frm->{image}; - p mt '_vnedit_image_processing' if $frm->{image} && $frm->{image} < 0; - img src => imgurl(cv => $frm->{image}) if $frm->{image} && $frm->{image} > 0; + img src => imgurl(cv => $frm->{image}) if $frm->{image}; end; div; |