[Slim-Checkins] r8754 - in /trunk/server: Changelog6.html
Slim/Music/Artwork.pm Slim/Web/Graphics.pm
dsully at svn.slimdevices.com
dsully at svn.slimdevices.com
Tue Aug 1 11:58:37 PDT 2006
Author: dsully
Date: Tue Aug 1 11:58:36 2006
New Revision: 8754
URL: http://svn.slimdevices.com?rev=8754&view=rev
Log:
Bug: 3850
Description: JPEG images come in different forms.. use the base header bytes for identification.
Because GD can't auto-identify image types, use the correct constructor to create a GD::Image object.
Modified:
trunk/server/Changelog6.html
trunk/server/Slim/Music/Artwork.pm
trunk/server/Slim/Web/Graphics.pm
Modified: trunk/server/Changelog6.html
URL: http://svn.slimdevices.com/trunk/server/Changelog6.html?rev=8754&r1=8753&r2=8754&view=diff
==============================================================================
--- trunk/server/Changelog6.html (original)
+++ trunk/server/Changelog6.html Tue Aug 1 11:58:36 2006
@@ -454,6 +454,7 @@
<li><a href="http://bugs.slimdevices.com/show_bug.cgi?id=3842">#3842</a> - Playing a magic favorite has some problems.</li>
<li><a href="http://bugs.slimdevices.com/show_bug.cgi?id=3843">#3843</a> - Undefined subroutine &Slim::Networking::Async::Socket::UDP::msg</li>
<li><a href="http://bugs.slimdevices.com/show_bug.cgi?id=3844">#3844</a> - Synced players - problem moving track past 'now playing' ...</li>
+ <li><a href="http://bugs.slimdevices.com/show_bug.cgi?id=3850">#3850</a> - Some cover art is not resized for gallery view thumbnails</li>
</ul>
</ul>
Modified: trunk/server/Slim/Music/Artwork.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Music/Artwork.pm?rev=8754&r1=8753&r2=8754&view=diff
==============================================================================
--- trunk/server/Slim/Music/Artwork.pm (original)
+++ trunk/server/Slim/Music/Artwork.pm Tue Aug 1 11:58:36 2006
@@ -116,11 +116,21 @@
return 'image/png';
- } elsif ($$body =~ /^.*?(\xff\xd8\xff\xe0..JFIF)/) {
+ } elsif ($$body =~ /^GIF(\d\d)([a-z])/) {
+
+ return 'image/gif';
+
+ } elsif ($$body =~ /^.*?(\xff\xd8\xff)/) {
my $header = $1;
- # jpeg images must start with ff d8 ff e0 or they are not jpeg,
+ # See http://www.obrador.com/essentialjpeg/headerinfo.htm for
+ # the JPEG header spec.
+ #
+ # jpeg images must start with ff d8 or they are not jpeg,
+ # the next table will always start with ff as well, so look
+ # for that. JFIF is an addition to the standard, we've seen
+ # baseline images (bug 3850) without a JFIF header.
# sometimes there is junk before.
$$body =~ s/^.*?$header/$header/;
Modified: trunk/server/Slim/Web/Graphics.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Web/Graphics.pm?rev=8754&r1=8753&r2=8754&view=diff
==============================================================================
--- trunk/server/Slim/Web/Graphics.pm (original)
+++ trunk/server/Slim/Web/Graphics.pm Tue Aug 1 11:58:36 2006
@@ -7,8 +7,14 @@
use Slim::Utils::Misc;
use Slim::Utils::Cache;
+my %typeToMethod = (
+ 'image/gif' => 'newFromGifData',
+ 'image/jpeg' => 'newFromJpegData',
+ 'image/png' => 'newFromPngData',
+);
+
{
- #art resizing support by using GD, requires JPEG support built in
+ # Artwork resizing support by using GD, requires JPEG support built in
my $canUseGD = eval {
require GD;
if (GD::Image->can('jpeg')) {
@@ -88,15 +94,12 @@
if ($cachedImage && $cachedImage->{'mtime'} != $mtime) {
$cachedImage = undef;
}
-
}
unless ($cachedImage) {
($imageData, $contentType, $mtime) = $obj->coverArt($image);
-
- }
-
+ }
}
unless ($cachedImage || $imageData) {
@@ -112,7 +115,6 @@
($body, $mtime, $inode, $size) = Slim::Web::HTTP::getStaticContent("html/images/cover.png");
$contentType = "image/png";
$imageData = $$body;
-
}
}
@@ -125,16 +127,22 @@
$::d_artwork && msg(" got cover art image $contentType of ". length($imageData) . " bytes\n");
- if (serverResizesArt()) {
+ if (serverResizesArt() && $typeToMethod{$contentType}) {
# If this is a thumb, a size has been given, or this is a png and the background color isn't 100% transparent
# then the overhead of loading the image with GD is necessary. Otherwise, the original content
# can be passed straight through.
if ($image eq "thumb" || $requestedWidth || ($contentType eq "image/png" && ($requestedBackColour >> 24) != 0x7F)) {
+ # Bug: 3850 - new() can't auto-identify the
+ # ContentType (for things like non-JFIF JPEGs) - but
+ # we already have. So use the proper constructor for
+ # the CT. Set the image to true color.
+
GD::Image->trueColor(1);
- my $origImage = GD::Image->new($imageData);
+ my $constructor = $typeToMethod{$contentType};
+ my $origImage = GD::Image->$constructor($imageData);
if ($origImage) {
@@ -338,5 +346,4 @@
return ($destX, $destY, $destWidth, $destHeight);
}
-
1;
More information about the checkins
mailing list