Permalink
Browse files

Revert "I'll do myself one better: three lines with GD"

This reverts commit 4357bd2.
  • Loading branch information...
klange committed May 4, 2012
1 parent 4357bd2 commit 7ce8302675cf8639e84f45f9272c25313386bd59
Showing with 16 additions and 4 deletions.
  1. +16 −4 lib/Acoustics/Web.pm
View
@@ -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');
@@ -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;
}

1 comment on commit 7ce8302

@klange

This comment has been minimized.

Show comment
Hide comment
@klange

klange May 4, 2012

Collaborator

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

Collaborator

klange commented on 7ce8302 May 4, 2012

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

Please sign in to comment.