The feature supported in IE6, but not Chrome
blog.thomseddon.co.uk
blog.thomseddon.co.uk
Honestly, that's like changing the extension of a .rar to .zip and asking why Windows Explorer can't open it but gnome-open can.
Personally I had never thought to look what the deflate indicated and figured it was similar to sdch, now I know.
http://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Comm...
Source:
<?php
header('Content-Encoding: gzip');
header('Content-Type: image/jpeg');
$fin = fopen('test.jpg', "rb");
$fout = fopen('php://output', "w");
$gzipFilter = stream_filter_append($fout, 'zlib.deflate', STREAM_FILTER_WRITE, array('level' => 6, 'window' => 15, 'memory' => 9));
stream_copy_to_stream($fin, $fout);
stream_filter_remove($gzipFilter);
fclose($fin);
fclose($fout);
To see Chrome decode your test image, use gzencode() or set Content-Encoding to deflate.
http://www.thestudentcloud.co.uk/hn/test2.php
<?php
header('Content-Encoding: gzip');
header('Content-Type: image/jpeg');
$data = file_get_contents('test.jpg');
$gzdata = gzencode($data, 9);
$fout = fopen('php://output', "w");
fwrite($fout, $gzdata);
fclose($fout);
Second: Chrome always handles gzip with the correct headers.
1. A modern graphic file is already maximally compressed.
2. Given (1) above, an effort to compress the file further can only make it bigger (one of the paradoxes of misapplied compression).
3. So the decision to reject gzipped graphics is wise -- it educates inexperienced programmers in a subtle point about compression technology, more or less by force.
The above is true -- take a file composed of supposedly random numbers (or byte values). A good measure of the file's randomness is the inability of a well-written compression algorithm to make it smaller.
By contrast, a measure of the redundancy (of exploitable content repetitions or patterns) in a file is the degree to which it can be compressed, the ratio of its compressed versus uncompressed size. In my experience, political speeches tend to be very compressible.
I built my own archive format years ago, using bzip2 for game programming. When you compress an already compressed file the result is almost always larger, or at smallest is the same size. On top of having to be decompressed twice on the client side, this is a total waste of server resources.
EDIT: My question was in reference to the latter part of the final conclusion, Chrome sends:
Accept:/ Accept-Encoding:gzip,deflate,sdch
But doesn't actually support it. Thanks to hobbit_longon for help pointing out the error in the final point.
You want to know why people don't gzip their images? What benefit do you think you get from gziping a jpeg or png stream? Why were you trying it in the first place?
Accept:/
Accept-Encoding:gzip,deflate,sdch
But if you abide by this and send it gzip'ed it fails...why?
"We still don’t quite understand why nobody sends gzip’ed images"
The author wrote up his thoughts as a blog post and took the time to submit it looking for help understanding an issue.
You were unnecessarily rude and condescending in your response. I'm only bringing this up because your account is new. If you're going to take the time to create an account to reply to a post, why would you create an account just to leave this comment?
Read his response again. The author is asking why, if Chrome does not support gzipped images, it sends "Accept:/ Accept-Encoding:gzip,deflate,sdch" (in other words it states that it will accept any Gzipped content). This is the question no one in this thread is actually answering, instead choosing to nitpick on why the author tried to do something.
Also, calling someone an idiot because they lack understanding of a certain field in computer science? Really? Maybe you should lighten up.
I guess the browsers figure it's not worth building in support for a feature that's rarely used and creates a sub-optimal UX.
That's not why, that's just a reason why doing so is silly.
> the gzip algorithm isn't optimised as well for images as say, jpeg.
gzip is used in PNG.
Read the article; the reason is because he wasn't sending gzip data, just deflate data.
no.
Optimisation 101 is profiling.