0

I noticed that when using CSS to resize a lossless png file (for normal/Retina purposes), on latest Chrome, (54.x at the time of writing), the result is blurry. blurry

When adding the following rule to the img tags

img {
   image-rendering: -webkit-optimize-contrast;
}

Then the result is better:

crispier

The problem : Safari's engine renders this quite differently (much worse)

safari

My questions

  1. how can I resize a lossless PNG without having quality problems?
  2. if resizing always causes issues, what's the alternative to handle Higher-DPI monitors? (support for https://www.sitepoint.com/how-to-build-responsive-images-with-srcset/ ?)
George Katsanos
  • 13,524
  • 16
  • 62
  • 98

4 Answers4

0

You could use @media CSS to change the URL of the image. Using an image editing software to change the size of the images so the browser doesn't have to handle scaling.

MercPls
  • 128
  • 8
0

Use media query for high resolution display like:

@media
(-webkit-min-device-pixel-ratio: 1.3),
(min--moz-device-pixel-ratio: 1.3),
(-o-min-device-pixel-ratio: 2.6/2),
(min-device-pixel-ratio: 1.3),
(min-resolution: 1.3dppx) {
   /* Retina-specific stuff here */
}

For reference: http://brettjankord.com/2012/11/28/cross-browser-retinahigh-resolution-media-queries/

Germano Plebani
  • 3,461
  • 3
  • 26
  • 38
0

Finally I opted for using srcset to do pure responsive images:

            <img
                    src="./img/logo.png"
                    srcset="./img/logo.png 1x,
                        ./img/logo@2x.png 2x"
            >
George Katsanos
  • 13,524
  • 16
  • 62
  • 98
0

use HTML srcset Attribute

<picture>
  <source media="(min-width: 650px)" srcset="img_pink_flowers.jpg">
  <source media="(min-width: 465px)" srcset="img_white_flower.jpg">
  <img src="img_orange_flowers.jpg" alt="Flowers" style="width:auto;">
</picture>

and with adobe ps proses the image

Omar bakhsh
  • 896
  • 11
  • 18