视网膜显示:如何在Finder和Preview中以原始像素分辨率显示图像 [英] Retina display: How to display images in native pixel resolution in Finder and Preview

查看:171
本文介绍了视网膜显示:如何在Finder和Preview中以原始像素分辨率显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个伪问题,下面将分享我自己的技巧和脚本.

This is a pseudo question to share my own trick and script below.

重点是要能够在Retina显示器上逐个像素显示图像.这主要用于高分辨率图像和/或使用HDPI版本的图像的开发人员.

The point is to be able to display image pixel for pixel on Retina displays. This is mainly useful for high resolution image and/or for developers working on HDPI version of images.

仅在OS X首选项中将显示设置设置为2:1的比例时,该解决方案才能很好地发挥作用.请注意,2016年末MacBook Pro的默认设置默认未设置为2:1.您应该将其设置为中等设置,以使其正确设置.

The solution works well only if the display setting is set to 2:1 ratio in the OS X preferences. Beware, late 2016 MacBook Pro default setting is not set to 2:1 by default. You should set it on the medium setting to get it right.

推荐答案

Finder :简单的技巧是给出一个以@2x结尾的名称(在扩展名之前):my_image@2x.jpg.然后,当使用快速查看"功能时,图像为像素级.由于建议将这种命名方案用于视网膜图像,因此正常图像和HDPI图像均以预期的大小显示,而视网膜则更清晰.

Finder : the simple trick is to give a name ending with @2x (before the extension): my_image@2x.jpg . Then when using Quick Look feature the image is pixel-wise. As this naming scheme is recommended for retina images, both normal and HDPI images display at same size, as expected, the retina being sharper.

预览:在预览中,如果将图像的DPI分辨率设置为72dpi,则将其解释为普通分辨率.通过将其设置为144,您可以获得正确的显示比例.通过将显示比例更改为50%,可以在72dpi时达到相同的效果,但是比例设置不会像DPI设置那样停留在图像文件上.通过工具"->大小"菜单项对其进行更改.

Preview : In preview, the DPI resolution of an image is interpreted as normal if it is set to 72dpi. By setting it to 144, you get the right display ratio. One can achieve the same effect at 72dpi by changing the display scale to 50%, but the scale setting does not stick to the image file while the DPI setting does. Change it through the Tools->Size menu item.

下面是一个小脚本,可通过Finder自动执行144dpi设置.

Here below is a small applescript to automate 144dpi setting from the Finder.

tell application "Finder"
repeat with item_cour in selection as list
    if word 1 of (the kind of item_cour as text) is "Image" then
        set path_cour to POSIX path of (item_cour as text)
        do shell script "p_cour='" & path_cour & "';
        tags=$(xattr -px com.apple.metadata:_kMDItemUserTags \"$p_cour\");
        f_info=$(xattr -px com.apple.FinderInfo \"$p_cour\");
        sips -s dpiHeight 144 -s dpiWidth 144 \"$p_cour\";
        xattr -wx com.apple.FinderInfo '$f_info' \"$p_cour\";
        xattr -wx com.apple.metadata:_kMDItemUserTags \"$tags\" \"$p_cour\" "
        -- do shell script "convert \"" & path_cour & "\" -set units PixelsPerInch -density 144 \"" & path_cour & "\""
    end if
end repeat
end tell

由于sips命令不保留标签,因此脚本包含4行内容,可使用xattr命令获取并在修改文件后将其设置回文件中.

Since the sips command does not preserve tags, the script includes 4 lines to get and set them back to the file after it has been modified, using the xattr command.

要安装脚本,请执行以下操作:打开脚本编辑器,创建一个新文档,粘贴代码并将其保存到〜/Library/Scripts/Finder文件夹中. 确保在脚本编辑器首选项中选中Show the Script Menu选项.

To install the script: open the script editor, create a new document, paste the code and save it into the ~/Library/Scripts/Finder folder. Be sure to check the Show the Script Menu option in Script editor preference.

要使用脚本,请执行以下操作:在Finder中选择图像文件,然后从菜单中激活脚本.

To use the script: select image file(s) in Finder and activate the script from the menu.

这篇关于视网膜显示:如何在Finder和Preview中以原始像素分辨率显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆