Bug 6471 - Huge thumbnails being generated in PNG format
: Huge thumbnails being generated in PNG format
Status: CLOSED FIXED
Product: Logitech Media Server
Classification: Unclassified
Component: Misc
: 7.0
: PC Windows XP
: P2 normal (vote)
: 7.x
Assigned To: Michael Herger
http://forums.slimdevices.com/showthr...
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2007-12-26 13:51 UTC by Jim McAtee
Modified: 2009-09-08 09:16 UTC (History)
2 users (show)

See Also:
Category: ---


Attachments
rectangular cover in Default skin (24.04 KB, image/jpeg)
2008-04-01 06:28 UTC, Michael Herger
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jim McAtee 2007-12-26 13:51:13 UTC
I use a thumbnail size of 130px and I'm finding that the png files that are generated and sent to Firefox are often 1 1/2 to 3 times as large as the originals, which are all JPEGs.  Similar things are happening with 96x96 and 50x50 pixel images shown in the status pane and playlist.

Here's an example of a cover that is orginally a 200x200 pixel JPEG.  As a point of reference, the 130 pixel thumbnail in SlimServer 6.5 was a 5k JPEG.

http://zolx.com/images/covers/Tonic_Sugar/cover.jpg]Original Artwork - 12k
http://zolx.com/images/covers/Tonic_Sugar/cover_130x130_p.png]130x130 - 40k
http://zolx.com/images/covers/Tonic_Sugar/cover_96x96_p.png]96x96 - 23k
http://zolx.com/images/covers/Tonic_Sugar/cover_50x50_p.png]50x50 - 7k

I don't see quite such a disparity when the artwork is larger, say a 30kB 300x300 image.  Those 130x130px thumbnails tend to be about the same size or slightly smaller than the orginal.  Though that's still much larger than I would expect.

See the forum discussion.  Using PNG for artwork thumbnails probably was a mistake.
Comment 1 Blackketter Dean 2007-12-26 13:59:09 UTC
Are the cover art images also PNGs in Jive?  Should they be JPEGs?

Comment 2 Ben Klaas 2007-12-26 14:10:34 UTC
Yes, they are rendered as PNGs in Jive. This was done so alpha channel transparency would be available, particularly for creating non-standard aspect ratio art with padding that was actually tranparent.

If you request a "cover.jpg" with a URL that asks for "cover_130x130_p.png", cover.png is converted to a 130x130 pixel PNG that is padded with alpha channel tranparency if it isn't 130x130 square. FWIW, this image is then cached by SqueezeCenter (Jive will also cache it).

I'm not offering a solution with this comment, merely stating how it currently works.

Comment 3 Jim McAtee 2007-12-26 17:09:59 UTC
(In reply to comment #2)
> Yes, they are rendered as PNGs in Jive. This was done so alpha channel
> transparency would be available, particularly for creating non-standard aspect
> ratio art with padding that was actually tranparent.

Is it necessary in the Jive interface for some reason to have only square album art images?
Comment 4 Ben Klaas 2007-12-26 18:18:06 UTC
> Is it necessary in the Jive interface for some reason to have only square album
> art images?

for UI layout reasons, it's necessary for Jive to have a space that fills the same dimensions.

Dean thinks that an 8bit PNG will not have the same size issues, so we may be going to that as a workaround.

Comment 5 Michael Herger 2007-12-26 23:44:21 UTC
Ok, now that bug's assigned to me - what's the action? I read the discussion on campfire. Is the consensus to go the 8-big way?
Comment 6 Blackketter Dean 2007-12-27 05:28:35 UTC
I think that we should test the 8-bit PNG approach and verify that the image quality is sufficient and that it works on all platforms.

I proposed this change in the engineering campfire:

					# if the source image was a png and GD can output png data
					# then return a png, else return a jpg
					if (($returnedType eq "png" || $transparentRequest eq 'png') && GD::Image->can('png') ) {
						$newImage->trueColorToPalette();
						$newImageData = $newImage->png;
						$requestedContentType = 'image/png';

Also play with:
						$newImage->trueColorToPalette(1,256);

and:
						$newImage->trueColorToPalette(0,256);

This uses PNG as a kind of lossy compression, alas it's a compression scheme that works for many graphics but is not one that often looks bad for photographic images.    Can you try it out?
Comment 7 Ben Klaas 2007-12-27 06:33:13 UTC
The other key thing to verify is that the image size is not as big as when using trueColor
Comment 8 Blackketter Dean 2007-12-27 07:40:50 UTC
Bad news.  My suggested code change didn't work.  GD doesn't know how to do 8-bit alpha blended images. 

We'll have to reinvestigate post-7.0
Comment 9 Ben Klaas 2007-12-27 07:44:47 UTC
Just so it doesn't get lost in the ether, Andy's idea from Campfire yesterday:

Andy G. hmm what about requesting the image without a file extension, then we can return whatever we want, right?
return the most-optimized file format depending on the file
I think the underlying SDL stuff handles it all, we just say "resize this image to x/y"
so I bet it will work

an extensionless image will require changes in several spots (SC, SC skins, Jive). This should really be taken up post-7.0.
Comment 10 Jim McAtee 2007-12-27 14:19:22 UTC
For the Jive layout problems, do the images have to be square with alpha transparency, or would it be sufficient to resize them so that they all _fit_ within the same sized square area?  In other words, resize them so that both the width and the height don't exceed a particular size, maintain the aspect ratio, but don't pad.

For example, if an 80x80 pixel space is the goal:

Original: 200(w)x185(h)
Resized:  80x74

Original: 325x400
Resized:  65x80
Comment 11 Jim McAtee 2008-01-06 00:07:18 UTC
This isn't going to be addressed for 7.0?  You're actually planning on releasing software that sends 40k "thumbnails" to web browsers?

On a 100Mbps LAN the problem isn't always noticeable, but it's immediately apparent with connections across the Internet with less bandwidth.  Couldn't jpegs be sent to the web browser and then whatever else for the jive interface?
Comment 12 Andy Grundman 2008-01-07 21:03:56 UTC
I agree it would be nice to fix this for 7.0, but given that most people use SC on a LAN it's not a high priority.

Using no extension and having SC determine the best type of file to serve should work.

I think we'd want to do this:

Source Image                Served as
-------------------------------------
Square anything             JPEG
Non-square anything         Transparent PNG (GIF for IE6)
Comment 13 Blackketter Dean 2008-01-08 07:07:29 UTC
Andy, I think that is a reasonable compromise for the first release, with the caveat that if the source file is a png, we don't send a JPEG.  
Comment 14 Michael Herger 2008-01-16 09:20:59 UTC
Targetting for 7.1 - though I doubt the bandwidth is an issue here. Processing many files imho adds much more to the overhead.
Comment 15 Jim McAtee 2008-03-30 22:27:08 UTC
I don't follow Jive developements as closely, but my understanding is that with bug 7642 and change 18102, now only JPEG thumbnails are being rendered for that platform.  Is that for both square and non-square originals?

If that's the case, then would it be time to eliminate the use of PNGs in all of the precached web interface thumbnails for non-square originals?  There was never any reason to use PNG for that platform.
Comment 16 Andy Grundman 2008-03-31 07:01:08 UTC
Jive gets JPEG all the time, the web still gets PNG for non-square images so they can be transparently padded.
Comment 17 Jim McAtee 2008-03-31 11:19:39 UTC
(In reply to comment #16)
> Jive gets JPEG all the time, the web still gets PNG for non-square images so
> they can be transparently padded.

But wasn't the whole need for transparent padding to make square images a Jive thing in the first place?

Michael, is this necessary for the Default skin, or can you just as easily position non-square JPEGs?
Comment 18 Michael Herger 2008-04-01 06:28:38 UTC
Created attachment 3178 [details]
rectangular cover in Default skin

No need to have cover art as squares in the web UI.
Comment 19 Andy Grundman 2008-04-01 06:35:40 UTC
That would be great if the web UI can request images using the same 'o' option that Jive uses.
Comment 20 Michael Herger 2008-04-24 08:17:20 UTC
Andy - could you please give me a pointer where this would have to be introduced?
Comment 21 Andy Grundman 2008-04-24 08:35:49 UTC
You should be able to request images as 'cover_100x100_o' which would give you back an image that is resized to 100 for the larger dimension, with the other dimension being whatever is needed to maintain the aspect ratio.
Comment 22 Michael Herger 2008-05-28 03:53:01 UTC
change 20254 - use _o parameter for coverart display
Comment 23 Chris Owens 2008-07-30 15:30:14 UTC
This bug has now been fixed in the 7.1 release version of SqueezeCenter!  Please download the new version from http://www.slimdevices.com if you haven't already.  

If you are still experiencing this problem, feel free to reopen the bug with your new comments and we'll have another look.
Comment 24 Chris Owens 2009-07-31 10:15:33 UTC
Reduce number of active targets for SC