Skip to content

Commit

Permalink
Revert "I'll do myself one better: three lines with GD"
Browse files Browse the repository at this point in the history
This reverts commit 4357bd2.
  • Loading branch information
klange committed May 4, 2012
1 parent 4357bd2 commit 7ce8302
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions lib/Acoustics/Web.pm
Expand Up @@ -9,7 +9,8 @@ use Moose;
use Module::Load 'load';
use List::Util 'shuffle';
use LWP::Simple;
use Image::Resize;
use Image::Imlib2;
use File::Temp qw/ tempfile /;


has 'psgi_env' => (is => 'ro', isa => 'HashRef');
Expand Down Expand Up @@ -1166,9 +1167,20 @@ sub art
$albumart = "www-data/icons/cd_case.png";
}

my $image_in = Image::Resize->new($albumart);
my $image_out = $image_in->resize($size,$size);
my $buf = $image_out->png();
my $image_in = Image::Imlib2->load($albumart);
my $image_out = $image_in->create_scaled_image($size,0);
my ($fh, $filename) = tempfile(SUFFIX => '.png');
close($fh);
$image_out->image_set_format("png");
$image_out->save($filename);

open ART, "<", $filename or return [], {error => "Failed to open art file."};
binmode ART;
my ($buf, $data, $n);
while (($n = read ART, $data, 655360) != 0) {
$buf .= $data;
}
close(ART);

return [-type => $art_type], $buf;
}
Expand Down

1 comment on commit 7ce8302

@klange
Copy link
Collaborator Author

@klange klange commented on 7ce8302 May 4, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind, this didn't even work with some images, and it was very slow.

Please sign in to comment.