How to convert an image to retina display?

I have an 40px by 20px image with 72 Pixels / Inch.

I would like to create a Retina display version.

What should I do? Double the size? Change the resolution?

And in which format should I save it? PNG? JPG? ...

I am using this image on a web site ...


In your image editor, double the size of your image to 80px by 40px.

In your markup set the width to 40 and height to 20.

<img src="example.png" width="40" height="20" />

You should save as png if you need transparency or the image is line art. Save photographs as jpg.


My answer is convert your image into SVG

Do you have Illustrator? If so save your image as SVG (and have a png as a fallback if you want).

<img src="images/logo.svg" alt="" />
<img src="images/logo.png" alt="" />

As long as you use Modernzr which can work to get svg friendly in most browsers.

You can see it here how it's done: http://toddmotto.com/mastering-svg-use-for-a-retina-web-fallbacks-with-png-script/

Hope it helps :)


A retina display image (or high-density display image) is double the pixel size of a standard image - its scaling factor is 2.0. This means that yes, for your 40x20 pixel image, you will need to make an 80x40 pixel version (that is then displayed at double pixel density on screen). The format doesn't matter as much, both PNG and JPG will work fine (PNG will not degrade in quality with compression, but the file size will be larger than JPG).

However, the problem with high-density display images is that they take up more bandwidth, and are unnecessary for devices that don't have the high resolution or Retina displays. This means more data transferred over the network, inconveniencing mobile users and those with limited data transfer caps.

One solution is to use something like Retina.js. It's an open-source javascript client script that will automatically load the retina-sized image from your server and swap it in-place for the low-density version, if it exists. It follows Apple's standard for naming high-resolution images - @2x , so you can have HTML code like this:

<img src="/images/my_image.jpg" />

and the script will search your server also for /images/my_image@2x.jpg . If it exists, it will load it and swap it in-place without having to worry about messing with CSS.

链接地址: http://www.djcxy.com/p/71410.html

上一篇: 注册表路径查找所有安装的应用程序

下一篇: 如何将图像转换为视网膜显示?