Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

This reverts commit 4357bd2.
  • Loading branch information...
commit 7ce8302675cf8639e84f45f9272c25313386bd59 1 parent 4357bd2
@klange klange authored
Showing with 16 additions and 4 deletions.
  1. +16 −4 lib/Acoustics/Web.pm
View
20 lib/Acoustics/Web.pm
@@ -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
Collaborator

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

Please sign in to comment.
Something went wrong with that request. Please try again.