webp图像扩展_WebP图像和性能

WebP是由Google开发的图像格式,提供无损和有损压缩,以减少在线图像的文件大小。WebP图像文件比PNG小26%,比同等质量的JPEG小25-34%。虽然它在某些情况下可能导致图像质量下降,但支持透明度,并且在压缩设置和JPEG不完全对应。WebP在Chrome、Opera和Android浏览器中受到原生支持,但在Firefox、IE和Safari中需要polyfill。尽管存在浏览器兼容性问题,但WebP仍然是图像优化的一个强有力选择。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

webp图像扩展

It's said that a picture is worth a thousand words, but online, a picture can be worth a thousand kilobytes or more! HTTP Archive shows that images make up 64% of a Web page's total size on average. With this in mind, image optimization is key, especially when you consider that up to 40% of users will abandon a request if it doesn't load within 3 seconds. The problem with image optimization comes when designers want to keep image file sizes small without sacrificing image quality. Past attempts to create new optimized image file types better than the standard JPEG, PNG and GIF formats have been unsuccessful.

据说一张图片值一千个单词,但是在网上,一张图片值一千个千字节甚至更多! HTTP存档显示,图像平均占网页总大小的64%。 考虑到这一点,图像优化是关键,尤其是当您认为如果3秒钟内未加载请求时,多达40%的用户将放弃请求。 当设计人员希望在不牺牲图像质量的情况下保持图像文件的大小较小时,就会出现图像优化的问题。 过去尝试创建比标准JPEG,PNG和GIF格式更好的新的优化图像文件类型的尝试均未成功。

输入WebP (Enter WebP)

WebP is an image file type that was created in 2010 and is currently being developed by Google. This image format provides lossless and lossy compression to images on the Internet. Several big names are campaigning for the use of WebP, most notably Google, Facebook, and Ebay.

WebP是一种图片文件类型,创建于2010年,目前由Google开发。 此图像格式为Internet上的图像提供无损和有损压缩。 有几家知名公司正在争取使用WebP,其中最著名的是Google,Facebook和Ebay

At Aristotle, we are always experimenting with techniques that improve website performance for our clients, so we ran A/B tests to understand WebP's impact on image quality and how to best implement it in our clients' projects.

在亚里斯多德,我们一直在尝试改善客户网站性能的技术,因此我们进行A / B测试以了解WebP对图像质量的影响以及如何在客户项目中最佳实施。

A major reason we considered using WebP is the smaller file size. According to Google:

我们考虑使用WebP的主要原因是文件较小。 根据Google的说法:

  • *WebP lossless image files are 26% smaller than PNGs. *

    * WebP无损图像文件比PNG小26%。 *
  • *WebP lossy images files are 25-34% smaller than JPEG images at equivalent SSIM index. *

    *在同等的SSIM索引下,WebP有损图像文件比JPEG图像小25-34%。 *
  • WebP supports lossless transparency (also known as alpha channel) with just 22% more bytes.

    WebP支持无损透明(也称为Alpha通道),其字节仅增加22%。

Aristotle's tests have found pros and cons to the WebP image format:

Aristotle的测试发现了WebP图像格式的优缺点:

ProsCons
* Smaller file size* Weak browser support
* Different compression algorithm* Artifacting has plastic appearance
* Smoother color gradations* Poor exporting interface
* Alpha channel mask
优点 缺点
*较小的文件大小 *浏览器支持薄弱
*不同的压缩算法 *伪影具有塑料外观
*更平滑的颜色渐变 *不良的导出界面
* Alpha通道遮罩

画面质量 (Image Quality)

WebP uses a new compression algorithm, so artifacting (distortion or degradation) looks different than with other file types. WebP does a nice job maintaining crisp edges in a photo but, of course, loses detail and textures as you would expect in a lossy file. Where a comparable JPEG file exhibits jittery artifacting in solid areas, WebP boasts smooth gradations down to the lowest quality settings. One downside of this is that human faces can take on a plastic or posterized appearance at lower settings.

WebP使用新的压缩算法,因此伪像(失真或降级)看起来与其他文件类型不同。 WebP可以很好地保持照片的清晰边缘,但是,当然会丢失有损文件中的细节和纹理。 可比的JPEG文件在实心区域显示出抖动的伪影,而WebP则具有平滑的渐变效果,直到最低的质量设置。 缺点之一是,人脸在较低的环境下可能会呈现出塑料或海报的外观。

Gradations Comparison

层次比较

There are a few other things to consider with the WebP image format:

WebP图像格式还需要考虑其他一些事项:

  • Compression settings don't match up "one-to-one" with JPEGs. Don't expect a 50% quality JPEG to match a 50% quality WebP. Quality drops pretty sharply on the WebP quality scale, so it's best to start at a high quality and work your way down.

    压缩设置与JPEG不“一对一”匹配。 不要指望质量为50%的JPEG与质量为50%的WebP相匹配。 质量在WebP质量等级上急剧下降,因此最好从高质量开始,然后逐步降低。

  • Another game-changing plus is the ability to add an alpha channel mask, much like a PNG. Unlike its lossless counterpart, however, you can often squeeze a usable WebP image to around 1/10 the size of its PNG equivalent. This is the real stand-out use for WebP, ushering in an army of options and features that would otherwise bring a website to a crawling halt with unwieldy file sizes. One real-world example compressed an 880kb PNG (24-bit with alpha channel) down to 41kb — a file savings of a 95%. While this is not the norm, it does illustrate the possibilities.

    Illustration Comparison

    另一个改变游戏规则的优点是能够添加Alpha通道蒙版,非常类似于PNG。 但是,与无损副本不同,您通常可以将可用的WebP图像压缩到其PNG等效图像的​​1/10左右。 这是WebP真正突出的用途,它引入了大量的选项和功能,否则将使网站的文件大小笨拙地停止。 一个真实的示例将880kb PNG(带有alpha通道的24位)压缩为41kb,节省了95%的文件。 虽然这不是规范,但确实说明了可能性。

  • To further reduce the file size, we recommend omitting the metadata by unchecking "Save Metadata" in the dialogue. For even further compression savings, select "lossy alpha channel." Quality settings for the alpha channel mirror those of the image. For example, a 50% quality image will have a 50% quality lossy alpha channel. In our testing we expected artifacting around the masked edge, but there were also noticeable compression changes to the entire image. We certainly consider it an option to further shrink file sizes, but recommend closely monitoring the image quality when doing so. Also watch for unwelcome banding in the alpha channels with gradated fades.

    Banding Comparison

    为了进一步减小文件大小,建议通过在对话框中取消选中“保存元数据”来省略元数据。 为了进一步节省压缩,请选择“有损Alpha通道”。 Alpha通道的质量设置与图像的设置相同。 例如,质量为50%的图像将具有质量为50%的有损alpha通道。 在我们的测试中,我们期望在被遮盖的边缘周围出现伪影,但是整个图像的压缩率也发生了明显变化。 我们当然认为它是进一步缩小文件大小的一种选择,但建议在执行此操作时密切监视图像质量。 还要注意在Alpha通道中逐渐渐变的不受欢迎的条纹。

We were excited to see that a Photoshop plugin-in was available for the WebP format. This allows an easy way to dial in quality settings for WebP images. The interface of the plug-in leaves something to be desired since it hasn't been fully adopted by Adobe Photoshop. At present, you cannot preview an image to assess quality settings, which is a major downside. As a workaround, you can use the Google Chrome browser for a quick comparison between files. It's also a bit awkward to access the save dialogue. To save time, we recommend setting up a keyboard shortcut to avoid repeated visits to the "Save as" drop down menu. In spite of these caveats, it's still worth the trouble.

我们很高兴看到Photoshop插件可用于WebP格式。 这提供了一种简单的方法来为WebP图像拨入质量设置。 该插件的界面尚待改进,因为Adobe Photoshop尚未完全采用它。 目前,您无法预览图像来评估质量设置,这是主要缺点。 解决方法是,您可以使用Google Chrome浏览器在文件之间进行快速比较。 访问保存对话框也有点尴尬。 为了节省时间,建议您设置键盘快捷键,以避免重复访问“另存为”下拉菜单。 尽管有这些警告,但仍然值得解决。

With significant file size savings, good quality and game-changing alpha channel, WebP seems like a real contender among other image formats. While test results were optimistic, oddly there was no clear winner between formats. WebP often performed circles around the other formats, but JPEGs or 8-bit PNGs still occasionally beat WebP in size and/or quality. Be sure to do plenty of testing on your own before implementing WebP, as it may not be ideal for your needs.

WebP具有可节省的文件大小,良好的质量和可改变游戏规则的alpha通道,因此在其他图像格式中似乎是真正的竞争者。 虽然测试结果很乐观,但奇怪的是,两种格式之间没有明显的赢家。 WebP经常围绕其他格式执行循环操作,但是JPEG或8位PNG偶尔仍会在大小和/或质量方面超过WebP。 实施WebP之前,请确保自己进行大量测试,因为它可能不理想。

Banding Comparison

实作 (Implementation)

After Aristotle designers determined that WebP would be an efficient tool to use in their process, we then turned to our developers to test implementation. WebP is only natively supported in Chrome, Opera, Opera Mini, Android Browser and Chrome for Android. Firefox, IE and Safari don't have native support, although Firefox has a history with WebP. Luckily, there are a few workarounds for the lack of browser support.

在亚里斯多德的设计师确定WebP将是在他们的过程中使用的高效工具之后,我们便选择了开发人员来测试实现。 仅Chrome,Opera,Opera Mini,Android浏览器和Chrome for Android本身支持WebP。 Firefox,IE和Safari没有本机支持,尽管Firefox具有WebP的历史。 幸运的是,由于缺乏浏览器支持,有一些解决方法。

Through our research we found three viable options for implementing WebP images. We wanted to make sure that we used the best option in terms of page size, keeping in mind that Speed Index is a key metric, and taking into account any Javascript polyfills needed. A polyfill is Javascript code that is implemented to provide technology that is not natively provided in a browser.

通过我们的研究,我们发现了三种实现WebP图像的可行选择。 我们要确保我们在页面大小方面使用了最佳选择,请记住速度索引是一个关键指标,并考虑到需要的任何Java polyfills。 polyfill是Javascript代码,其实现目的是为了提供浏览器本身不提供的技术。

We ran four experiments to consider which direction to go.

我们进行了四个实验,以考虑要走的方向。

  1. The first test used a normal JPEG as a control, and the other three tests implemented the options listed below. We used a JPEG image and a WebP image of similar quality (269 kb JPEG and a 52 kb WebP). Here you can see the results from all four tests.

    第一个测试使用普通的JPEG作为控件,其他三个测试实现了下面列出的选项。 我们使用了质量相似的JPEG图像和WebP图像(269 kb JPEG和52 kb WebP)。 在这里,您可以看到所有四个测试的结果

  2. In test two, we included a 67kb WebP polyfill provided by Dominik Homberger. It allows WebP implementation on all major browsers, even IE 6 and up. This is a helpful polyfill because it doesn't require you to change the syntax of

    in existing code, just change .jpeg or .png to .webp and the polyfill will do the work for you.

    在测试二中,我们包括了Dominik Homberger提供的67kb WebP polyfill 。 它允许在所有主流浏览器(甚至IE 6及更高版本)上实施WebP。 这是一个有用的polyfill,因为它不需要您更改 在现有代码中,只需将.jpeg或.png更改为.webp,polyfill将为您完成工作。

  3. Our next approach was to use the Picturefill polyfill to allow the use of , even if is not natively supported. This allows developers to use to use WebP if the browser supports the image format and fallback to a JPEG, PNG or other image type if WebP is not supported. (There are other amazing powers the holds, but that's not relevant to this article.)

    我们的下一个方法是使用Picturefill polyfill允许使用 , 即使 本机不支持。 这允许开发人员使用 如果浏览器支持图像格式,则使用WebP;如果不支持WebP,则回退到JPEG,PNG或其他图像类型。 (还有其他惊人的力量 成立,但这与本文无关。)

  4. The fourth test used code in the .htaccess of the server to implement WebP. This option was provided by Vincent Orback. Using this approach, the .htaccess code will look for a WebP version of each image on a page. If the browser supports WebP and there's a WebP image available it, will use the WebP image rather than the JPEG or PNG. This is helpful and saves considerable time since you don't have to change the syntax of

    in the code or the extension of your images to .webp.

    第四个测试使用服务器.htaccess中的代码来实现WebP。 此选项由Vincent Orback提供 。 使用这种方法,.htaccess代码将在页面上查找每个图像的WebP版本。 如果浏览器支持WebP,并且有可用的WebP图像,则将使用WebP图像而不是JPEG或PNG。 这是有帮助的,并节省了大量时间,因为您不必更改 在代码或图像扩展名.webp中。

After reviewing the data, we determined that the WebP polyfill (Test 2) was the smallest implementation that worked on all browsers, but we weren't impressed with the Speed Index metric for this method.

审查数据后,我们确定WebP polyfill(测试2)是在所有浏览器上均可使用的最小实现,但该方法的“速度指数”指标并未给我们留下深刻的印象。

  • Using the WebP polyfill seemed to load visually worse than the JPEG control test and the other implementations, except on iOS.

    除了在iOS上之外,使用WebP polyfill看起来在视觉上比JPEG控件测试和其他实现更糟糕。

  • We also noticed that on iOS devices, file sizes were 100 kb more than the other devices. It seems that on iOS 5.1, IE 8, and IE 9 the WebP image gets downloaded 3 times. While the 2 extra requests are not ideal, this is still smaller than the JPEG equivalent. We haven't tested this on updated iOS versions so there's a chance this may be resolved for iOS 6 and later. We are inclined to use this implementation initially because of the better browser support.

    我们还注意到,在iOS设备上,文件大小比其他设备大100 kb。 似乎在iOS 5.1,IE 8和IE 9上,WebP图像被下载了3次。 虽然这两个额外的请求不理想,但仍小于JPEG等效请求。 我们尚未在更新的iOS版本上对此进行测试,因此有可能在iOS 6及更高版本中解决此问题。 由于倾向于更好的浏览器支持,我们倾向于最初使用此实现。

展望未来 (Looking Ahead)

While the WebP polyfill is a great patch for now, we know that this implementation won't be best in the future if other browsers begin supporting WebP. Our hope is that Safari, Firefox, and IE (particularly the Spartan Browser coming in Windows 10) will embrace the WebP image format soon. Once we begin seeing a larger adoption, we will implement the method used in Test 3, using the to serve WebP images for browsers that support it and serve a JPEG or PNG file when WebP isn't supported. We plan to implement this method once Firefox begins support because the majority of visitors to our clients' websites use Chrome and Firefox.

尽管WebP polyfill目前是一个不错的补丁,但我们知道,如果其他浏览器开始支持WebP,则这种实现在将来并不是最好的。 我们希望Safari,Firefox和IE(尤其是Windows 10中的Spartan浏览器)将很快采用WebP图像格式。 一旦开始看到更大的采用率,我们将使用 在不支持WebP的情况下为支持WebP的浏览器提供WebP图像,并提供JPEG或PNG文件。 Firefox开始支持后,我们计划实施此方法,因为大多数客户网站的访问者都使用Chrome和Firefox。

WebP won't push JPEG or PNG out of the picture, but it is a superb tool to add to your arsenal. Get ready to welcome WebP and be prepared to do some of your own testing and comparison with each new project!

WebP不会将JPEG或PNG压出图片,但这是添加到您的武器库中的绝佳工具。 准备好欢迎WebP,并准备好对每个新项目进行一些自己的测试和比较!

翻译自: https://davidwalsh.name/webp-images-performance

webp图像扩展

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值