From da49b95f180b6fab068bdf88d4d206ca8db2f06b Mon Sep 17 00:00:00 2001 From: Yorhel Date: Sat, 18 Jul 2015 00:59:40 +0200 Subject: Handler::(VNEdit|Chars): Fix removal of alpha layer in images Apparently, imagemagick's Flatten() has some odd corner cases where it seems to do more than just remove the alpha layer. The current approach is the one recommended by the official docs: http://www.imagemagick.org/Usage/masking/#remove --- lib/VNDB/Handler/Chars.pm | 3 ++- lib/VNDB/Handler/VNEdit.pm | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/VNDB/Handler/Chars.pm b/lib/VNDB/Handler/Chars.pm index 77d92646..9909f671 100644 --- a/lib/VNDB/Handler/Chars.pm +++ b/lib/VNDB/Handler/Chars.pm @@ -458,7 +458,8 @@ sub _uploadimage { $im->BlobToImage($imgdata); my($ow, $oh) = ($im->Get('width'), $im->Get('height')); my($nw, $nh) = imgsize($ow, $oh, @{$self->{ch_size}}); - $im = $im->Flatten; + $im->Set(background => '#ffffff'); + $im->Set(alpha => 'Remove'); if($ow != $nw || $oh != $nh) { $im->GaussianBlur(geometry => '0.5x0.5'); $im->Resize(width => $nw, height => $nh); diff --git a/lib/VNDB/Handler/VNEdit.pm b/lib/VNDB/Handler/VNEdit.pm index 73201073..8a85b989 100644 --- a/lib/VNDB/Handler/VNEdit.pm +++ b/lib/VNDB/Handler/VNEdit.pm @@ -252,7 +252,8 @@ sub _uploadimage { $im->Set(magick => 'JPEG'); my($ow, $oh) = ($im->Get('width'), $im->Get('height')); my($nw, $nh) = imgsize($ow, $oh, @{$self->{cv_size}}); - $im = $im->Flatten; + $im->Set(background => '#ffffff'); + $im->Set(alpha => 'Remove'); if($ow != $nw || $oh != $nh) { $im->GaussianBlur(geometry => '0.5x0.5'); $im->Resize(width => $nw, height => $nh); -- cgit v1.2.3