apache / incubator-pagespeed-mod

Apache module for rewriting web pages to reduce latency and bandwidth.
http://modpagespeed.com
Apache License 2.0
696 stars 158 forks source link

Do not resize @2x.png/jpg images to constraints of src/css. #895

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Example utilizing retina.js

Page has image, image.png, it's dimensions are 64x64.

Alongside image.png on the server is image@2x.png, it's dimensions are 128x128.

retina.js detects client display is 'retina' resolution or beyond, serves the 
image@2x.png to them - however, this image has been resized by mod_pagespeed to 
64x64, because that is the constraints defined in the page.

Thus, it essentially breaks the functionality of retina.js and other similar js 
techniques for serving higher resolution assets conditionally.

This could be called a defect, but I am posting it as a feature request because 
I have a suggestion on how this could be resolved. Rather than simply ignoring 
the @2x.extension images and not resizing them - mod_pagespeed could simply 
resize them to 2x what the constraints defined in the page are. Thus retaining 
the performance gains which can be had by optimizing content, but still serving 
a '2x' sized image.

Original issue reported on code.google.com by sojugar...@gmail.com on 25 Feb 2014 at 12:00

GoogleCodeExporter commented 9 years ago

Original comment by hui...@google.com on 25 Feb 2014 at 4:56

GoogleCodeExporter commented 9 years ago
A few points about this issue.  retina.js is not something we'd heard of 
before, but it appears to come from here http://retinajs.com/.  It's not really 
a web standard as far as we can tell, but based on the material on that page, 
it does kind of fit into the Apple iOS app ecosystem.

There is also an emerging web standard, and supporting that is discussed in 
Issue 791.  Long term, that's the way to go.  Shorter term, we might want to 
consider special-casing the files following the Apple conventions for Retina 
images.

In the meantime, a simple workaround is to add this to your pagespeed.conf:
   ModPagespeedDisallow *@2x.png
   ModPagespeedDisallow *@2x.jp*g

Original comment by jmara...@google.com on 25 Feb 2014 at 9:15

GoogleCodeExporter commented 9 years ago
Hi Google guys,

Would you mind providing further instruction on what to do with retina images 
and pagespeed? I was using 2x size but obviously it started complaining. If I 
set resize_rendered_image_dimensions, obviously will look fugly in retina 
displays...

Any advice?

Original comment by tomasl...@gmail.com on 7 Mar 2015 at 10:39