[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-08。"],[[["\u003cp\u003eWebP lossless compression is shown to be 23% better than ZopfliPNG and 42% better than libpng.\u003c/p\u003e\n"],["\u003cp\u003eWebP encoding and decoding speeds are similar to PNG, making it a viable alternative.\u003c/p\u003e\n"],["\u003cp\u003eWebP consistently achieves higher compression density than size-optimized PNGs for over 99% of tested web images.\u003c/p\u003e\n"],["\u003cp\u003eWebP offers lossy compression with alpha support, providing further opportunities for website performance improvements.\u003c/p\u003e\n"],["\u003cp\u003eAlthough WebP encoding may use more memory, decoding generally uses less memory than PNG, particularly with lossy compression.\u003c/p\u003e\n"]]],["This document compares WebP and PNG image formats, focusing on compression efficiency and processing speed. WebP, both in lossless and lossy modes, is shown to outperform highly compressed PNGs (using pngcrush and ZopfliPNG) in compression density by 23-42% on a web corpus of 12,000 images. Encoding and decoding speeds for WebP are similar to PNG, with WebP decoding showing a reduction in memory use. WebP is presented as a more efficient alternative to PNG for web use, especially for image-heavy sites.\n"],null,["*Jyrki Alakuijala, Ph.D., Google, Inc.* \n\n*Vincent Rabaud, Ph.D., Google, Inc.* \n\nLast updated: 2017-08-01\n\n**Abstract** -- We compare the resource usage of WebP\nencoder/decoder to that of PNG in both lossless and lossy modes. We use\na corpus of 12000 randomly chosen translucent PNG images from the web,\nand simpler measurements to show variation in performance. We have\nrecompressed the PNGs in our corpus to compare WebP images to\nsize-optimized PNGs. In our results we show that WebP is a good\nreplacement for PNG for use on the web regarding both size and processing\nspeed.\n\nIntroduction\n\nWebP supports lossless and translucent images, making it an alternative\nto the PNG format. Many of\nthe fundamental techniques used in PNG compression, such as dictionary\ncoding, Huffman coding and color indexing transform are supported in\nWebP as well, which results in similar speed and compression density\nin the worst case. At the same time, a number of new features -- such\nas separate entropy codes for different color channels, 2D locality of\nbackward reference distances, and a color cache of recently used\ncolors -- allow for improved compression density with most images.\n\nIn this work, we compare the performance of WebP to PNGs that are\nhighly compressed using pngcrush and ZopfliPNG. We recompressed our\nreference corpus of web images using best practices, and compared both\nlossless and lossy WebP compression against this corpus. In addition\nto the reference corpus, we chose two larger images, one photographic\nand the other graphical, for speed and memory use benchmarking.\n\nDecoding speeds faster than PNG have been demonstrated, as well as 23%\ndenser compression than what can be achieved using today's PNG format. We\nconclude that WebP is a more\nefficient replacement for today's PNG image format. Further, the lossy\nimage compression with lossless alpha support gives further possibilities in\nspeeding up web sites.\n\nMethods\n\nCommand line Tools\n\nWe use the following command-line tools to measure performance:\n\n1. cwebp and dwebp. These tools that are part of the libwebp library\n (compiled from head).\n\n2. convert. This is a command-line tool part of ImageMagick software\n (6.7.7-10 2017-07-21).\n\n3. pngcrush 1.8.12 (Jul 30 2017)\n\n4. ZopfliPNG (Jul 17th 2017)\n\nWe use the command line tools with their respective control flags. For\nexample, if we refer to cwebp -q 1 -m 0, it means that the cwebp tool\nhas been evoked with -q 1 and -m 0 flags.\n\nImage Corpora\n\nThree corpora were chosen:\n\n1. A single photographic image (Figure 1),\n\n2. A single graphical image with translucency (Figure 2), and\n\n3. A web corpus: 12000 randomly chosen PNG images with translucency or not,\n crawled from the Internet. These PNG images are optimized via convert,\n pngcrush, ZopfliPNG and the smallest version of each image is considered\n for the study.\n\n*Figure 1. Photographic image, 1024 x 752 pixels. Fire breathing\n\"Jaipur Maharaja Brass Band\" Chassepierre Belgium, Author: Luc\nViatour, Photo licensed under the Creative Commons\nAttribution-Share Alike 3.0 Unported license. Author website is\n[here](https://www.lucnix.be).*\n\n*Figure 2. Graphical image, 1024 x 752 pixels. Collage images from\n[Google Chart Tools](https://developers.google.com/chart/)*\n\nTo measure the full capability of the existing format, PNG, we have\nrecompressed all these original PNG images using several methods:\n\n1. Clamp to 8 bits per component: convert input.png -depth 8 output.png\n\n2. ImageMagick(1) with no predictors: convert input.png -quality 90\n output-candidate.png\n\n3. ImageMagick with adaptive predictors: convert input.png -quality 95\n output-candidate.png\n\n4. Pngcrush(2): pngcrush -brute -rem tEXt -rem tIME -rem iTXt -rem zTXt\n -rem gAMA -rem cHRM -rem iCCP -rem sRGB -rem alla -rem text\n input.png output-candidate.png\n\n5. ZopfliPNG(3): zopflipng --lossy_transparent input.png output-candidate.png\n\n6. ZopfliPNG with all filters: zopflipng --iterations=500 --filters=01234mepb\n --lossy_8bit --lossy_transparent input.png output-candidate.png\n\nResults\n\nWe computed compression density for each of the images in the web\ncorpus, relative to optimized PNG image sizes for three methods:\n\n1. WebP lossless (default settings)\n\n2. WebP lossless with the smallest size (-m 6 -q 100)\n\n3. best of WebP lossless and WebP lossy with alpha (default settings).\n\nWe sorted these compression factors, and plotted them in Figure 3.\n\n*Figure 3. PNG compression density is used as a reference, at 1.0. The\nsame images are compressed using both lossless and lossy methods. For\neach image, the size ratio to compressed PNG is computed, and the size\nratios are sorted, and shown for both lossless and lossy\ncompression. For the lossy compression curve, the lossless compression\nis chosen in those cases where it produces a smaller WebP image.*\n\nWebP goes beyond PNG compression density for both libpng at maximum\nquality (convert) as well as ZopfliPNG (Table 1), with encoding (Table\n2), and decoding (Table 3) speeds being roughly comparable to those of\nPNG.\n\n**Table 1.** Average bits-per-pixel for the three corpora using the\ndifferent compression methods.\n\n| Image Set | convert -quality 95 | ZopfliPNG | WebP lossless -q 0 -m 1 | WebP lossless (default settings) | WebP lossless -m 6 -q 100 | WebP lossy with alpha |\n|-----------|---------------------|-----------|-------------------------|----------------------------------|---------------------------|-----------------------|\n| photo | 12.3 | 12.2 | 10.5 | 10.1 | 9.83 | 0.81 |\n| graphic | 1.36 | 1.05 | 0.88 | 0.71 | 0.70 | 0.51 |\n| web | 6.85 | 5.05 | 4.42 | 4.04 | 3.96 | 1.92 |\n\n**Table 2.** Average encoding time for the compression corpora\nand for different compression methods.\n\n| Image Set | convert -quality 95 | ZopfliPNG | WebP lossless -q 0 -m 1 | WebP lossless (default settings) | WebP lossless -m 6 -q 100 | WebP lossy with alpha |\n|-----------|---------------------|-----------|-------------------------|----------------------------------|---------------------------|-----------------------|\n| photo | 0.500 s | 8.7 s | 0.293 s | 0.780 s | 8.440 s | 0.111 s |\n| graphic | 0.179 s | 14.0 s | 0.065 s | 0.140 s | 3.510 s | 0.184 s |\n| web | 0.040 s | 1.55 s | 0.017 s | 0.072 s | 2.454 s | 0.020 s |\n\n**Table 3.** Average decoding time for the three corpora for image files\nthat are compressed with different methods and settings.\n\n| Image Set | convert -quality 95 | ZopfliPNG | WebP lossless -q 0 -m 1 | WebP lossless (default settings) | WebP lossless -m 6 -q 100 | WebP lossy with alpha |\n|-----------|---------------------|-----------|-------------------------|----------------------------------|---------------------------|-----------------------|\n| photo | 0.027 s | 0.026 s | 0.027 s | 0.026 s | 0.027 | 0.012 s |\n| graphics | 0.049 s | 0.015 s | 0.005 s | 0.005 s | 0.003 | 0.010 s |\n| web | 0.007 s | 0.005 s | 0.003 s | 0.003 s | 0.003 | 0.003 s |\n\nMemory Profiling\n\nFor the memory profiling, we recorded the maximum resident set size as\nreported by /usr/bin/time -v\n\nFor the web corpus, the size of the largest image alone defines the\nmaximal memory use. To keep the memory measurement better defined we\nuse a single photographic image (Figure 1) to give an overview of\nmemory use. The graphical image gives similar results.\n\nWe measured 10 to 19 MiB for libpng and ZopfliPNG, and 25 MiB and 32 MiB\nfor WebP lossless encoding at settings -q 0 -m 1, and -q 95 (with a\ndefault value of -m), respectively.\n\nIn a decoding experiment, convert -resize 1x1 uses 10 MiB for both the\nlibpng and ZopfliPNG generated PNG files. Using cwebp, WebP lossless\ndecoding uses 7 MiB, and lossy decoding 3 MiB.\n\nConclusions\n\nWe have shown that both encoding and decoding speeds are in the same\ndomain of those of PNG. There is an increase in the memory use during\nthe encoding phase, but the decoding phase shows a healthy decrease,\nat least when comparing the behavior of cwebp to that of\nImageMagick's convert.\n\nThe compression density is better for more than 99% of the web images,\nsuggesting that one can relatively easily change from PNG to WebP.\n\nWhen WebP is run with default settings, it compresses 42% better than\nlibpng, and 23% better than ZopfliPNG. This suggests that WebP is\npromising for speeding up image heavy websites.\n\nReferences\n\n1. [ImageMagick](https://www.imagemagick.org/script/index.php)\n\n2. [Pngcrush](http://pmt.sourceforge.net/pngcrush/)\n\n3. [ZopfliPNG](https://github.com/google/zopfli)\n\nExternal Links\n\nThe following are independent studies not sponsored by Google, and Google\ndoesn't necessarily stand behind the correctness of all their contents.\n\n1. [Yoav Weiss Blog](https://blog.yoav.ws/2012/07/Images-Can-we-have-less)"]]