Before and after image size once an image is downloaded. These values are rounded to the nearest kilobyte. If install is available, when Squoosh is installed, and what method was used to install Squoosh. Image compression is handled locally; no additional data is sent to the server. Building locally. Clone the repo,. All the images you get on the web are compressed, typically in the JPEG or GIF formats, most modems use compression, HDTV will be compressed using MPEG-2, and several file systems automatically compress files when stored, and the rest.
- Squash — Web Image Compression 2 0 30
- Squash — Web Image Compression 2 0 3 0
- Squash — Web Image Compression 2 0 32
- Squash — Web Image Compression 2 0 35
Jyrki Alakuijala, Ph.D., Google, Inc.
Vincent Rabaud, Ph.D., Google, Inc.
Last updated: 2017-08-01
Vincent Rabaud, Ph.D., Google, Inc.
Last updated: 2017-08-01
Abstract -- We compare the resource usage of WebPencoder/decoder to that of PNG in both lossless and lossy modes. We usea corpus of 12000 randomly chosen translucent PNG images from the web,and simpler measurements to show variation in performance. We haverecompressed the PNGs in our corpus to compare WebP images tosize-optimized PNGs. In our results we show that WebP is a goodreplacement for PNG for use on the web regarding both size and processingspeed.
Introduction
WebP supports lossless and translucent images, making it an alternativeto the PNG format. Many ofthe fundamental techniques used in PNG compression, such as dictionarycoding, Huffman coding and color indexing transform are supported inWebP as well, which results in similar speed and compression densityin the worst case. At the same time, a number of new features -- suchas separate entropy codes for different color channels, 2D locality ofbackward reference distances, and a color cache of recently usedcolors -- allow for improved compression density with most images.
In this work, we compare the performance of WebP to PNGs that arehighly compressed using pngcrush and ZopfliPNG. We recompressed ourreference corpus of web images using best practices, and compared bothlossless and lossy WebP compression against this corpus. In additionto the reference corpus, we chose two larger images, one photographicand the other graphical, for speed and memory use benchmarking.
Decoding speeds faster than PNG have been demonstrated, as well as 23%denser compression than what can be achieved using today's PNG format. Weconclude that WebP is a moreefficient replacement for today's PNG image format. Further, the lossyimage compression with lossless alpha support gives further possibilities inspeeding up web sites.
Methods
Command line Tools
We use the following command-line tools to measure performance:
- cwebp and dwebp. These tools that are part of the libwebp library (compiled from head).
- convert. This is a command-line tool part of ImageMagick software (6.7.7-10 2017-07-21).
- pngcrush 1.8.12 (Jul 30 2017)
- ZopfliPNG (Jul 17th 2017)
We use the command line tools with their respective control flags. Forexample, if we refer to cwebp -q 1 -m 0, it means that the cwebp toolhas been evoked with -q 1 and -m 0 flags.
Image Corpora
Three corpora were chosen:
- A single photographic image (Figure 1),
- A single graphical image with translucency (Figure 2), and
- A web corpus: 12000 randomly chosen PNG images with translucency or not, crawled from the Internet. These PNG images are optimized via convert, pngcrush, ZopfliPNG and the smallest version of each image is considered for the study.
Squash — Web Image Compression 2 0 30
Figure 1. Photographic image, 1024 x 752 pixels. Fire breathing'Jaipur Maharaja Brass Band' Chassepierre Belgium, Author: LucViatour, Photo licensed under the Creative CommonsAttribution-Share Alike 3.0 Unported license. Author website ishere.
Figure 2. Graphical image, 1024 x 752 pixels. Collage images fromGoogle Chart Tools
To measure the full capability of the existing format, PNG, we haverecompressed all these original PNG images using several methods:
- Clamp to 8 bits per component: convert input.png -depth 8 output.png
- ImageMagick(1) with no predictors: convert input.png -quality 90 output-candidate.png
- ImageMagick with adaptive predictors: convert input.png -quality 95 output-candidate.png
- Pngcrush(2): pngcrush -brute -rem tEXt -rem tIME -rem iTXt -rem zTXt -rem gAMA -rem cHRM -rem iCCP -rem sRGB -rem alla -rem text input.png output-candidate.png
- ZopfliPNG(3): zopflipng --lossy_transparent input.png output-candidate.png
- ZopfliPNG with all filters: zopflipng --iterations=500 --filters=01234mepb--lossy_8bit --lossy_transparent input.png output-candidate.png
Results
We computed compression density for each of the images in the webcorpus, relative to optimized PNG image sizes for three methods:
- WebP lossless (default settings)
- WebP lossless with the smallest size (-m 6 -q 100)
- best of WebP lossless and WebP lossy with alpha (default settings).
We sorted these compression factors, and plotted them in Figure 3.
Figure 3. PNG compression density is used as a reference, at 1.0. Thesame images are compressed using both lossless and lossy methods. Foreach image, the size ratio to compressed PNG is computed, and the sizeratios are sorted, and shown for both lossless and lossycompression. For the lossy compression curve, the lossless compressionis chosen in those cases where it produces a smaller WebP image.
WebP goes beyond PNG compression density for both libpng at maximumquality (convert) as well as ZopfliPNG (Table 1), with encoding (Table2), and decoding (Table 3) speeds being roughly comparable to those ofPNG.
Table 1. Average bits-per-pixel for the three corpora using thedifferent compression methods.
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 |
---|---|---|---|---|---|---|
photo | 12.3 | 12.2 | 10.5 | 10.1 | 9.83 | 0.81 |
graphic | 1.36 | 1.05 | 0.88 | 0.71 | 0.70 | 0.51 |
web | 6.85 | 5.05 | 4.42 | 4.04 | 3.96 | 1.92 |
Table 2. Average encoding time for the compression corporaand for different compression methods.
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 |
---|---|---|---|---|---|---|
photo | 0.500 s | 8.7 s | 0.293 s | 0.780 s | 8.440 s | 0.111 s |
graphic | 0.179 s | 14.0 s | 0.065 s | 0.140 s | 3.510 s | 0.184 s |
web | 0.040 s | 1.55 s | 0.017 s | 0.072 s | 2.454 s | 0.020 s |
Table 3. Average decoding time for the three corpora for image filesthat are compressed with different methods and settings.
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 |
---|---|---|---|---|---|---|
photo | 0.027 s | 0.026 s | 0.027 s | 0.026 s | 0.027 | 0.012 s |
graphics | 0.049 s | 0.015 s | 0.005 s | 0.005 s | 0.003 | 0.010 s |
web | 0.007 s | 0.005 s | 0.003 s | 0.003 s | 0.003 | 0.003 s |
Memory Profiling
For the memory profiling, we recorded the maximum resident set size asreported by /usr/bin/time -v
For the web corpus, the size of the largest image alone defines themaximal memory use. To keep the memory measurement better defined weuse a single photographic image (Figure 1) to give an overview ofmemory use. The graphical image gives similar results.
We measured 10 to 19 MiB for libpng and ZopfliPNG, and 25 MiB and 32 MiBfor WebP lossless encoding at settings -q 0 -m 1, and -q 95 (with adefault value of -m), respectively.
In a decoding experiment, convert -resize 1x1 uses 10 MiB for both thelibpng and ZopfliPNG generated PNG files. Using cwebp, WebP losslessdecoding uses 7 MiB, and lossy decoding 3 MiB.
Conclusions
We have shown that both encoding and decoding speeds are in the samedomain of those of PNG. There is an increase in the memory use duringthe encoding phase, but the decoding phase shows a healthy decrease,at least when comparing the behavior of cwebp to that ofImageMagick's convert.
The compression density is better for more than 99% of the web images,suggesting that one can relatively easily change from PNG to WebP.
When WebP is run with default settings, it compresses 42% better thanlibpng, and 23% better than ZopfliPNG. This suggests that WebP ispromising for speeding up image heavy websites. Edgeview 2 1 990 – cutting edge image viewer app.
References
External Links
The following are independent studies not sponsored by Google, and Googledoesn't necessarily stand behind the correctness of all their contents.
Latest version Released:
Compress responses in your Flask app with gzip, deflate or brotli.
Project description
Flask-Compress allows you to easily compress your Flask application's responses with gzip, deflate or brotli.
The preferred solution is to have a server (like Nginx) automatically compress the static files for you. If you don't have that option Flask-Compress will solve the problem for you.
How it works
Flask-Compress both adds the various headers required for a compressed response and compresses the response data.This makes serving compressed static files extremely easy.
Internally, every time a request is made the extension will check if it matches one of the compressible MIME typesand whether the client and the server use some common compression algorithm, and will automatically attach theappropriate headers.
To determine the compression algorithm, the
Accept-Encoding
request header is inspected, respecting thequality factor as described in MDN docs.If no requested compression algorithm is supported by the server, we don't compress the response. If, on the otherhand, multiple suitable algorithms are found and are requested with the same quality factor, we choose the first onedefined in the COMPRESS_ALGORITHM
option (see below).Installation
If you use pip then installation is simply:
or, if you want the latest github version:
You can also install Flask-Compress via Easy Install:
Using Flask-Compress
Squash — Web Image Compression 2 0 3 0
Flask-Compress is incredibly simple to use. In order to start compressing your Flask application's assets, the first thing to do is let Flask-Compress know about your
flask.Flask
application object.In many cases, however, one cannot expect a Flask instance to be ready at import time, and a common pattern is to return a Flask instance from within a function only after other configuration details have been taken care of. In these cases, Flask-Compress provides a simple function,
flask_compress.Compress.init_app
, which takes your application as an argument.In terms of automatically compressing your assets, passing your
flask.Flask
object to the flask_compress.Compress
object is all that needs to be done.Options
Within your Flask application's settings you can provide the following settings to control the behavior of Flask-Compress. None of the settings are required.
Option | Description | Default |
---|---|---|
COMPRESS_MIMETYPES | Set the list of mimetypes to compress here. | [ 'text/html', 'text/css', 'text/xml', 'application/json', 'application/javascript' ] |
COMPRESS_LEVEL | Specifies the gzip compression level. | 6 |
COMPRESS_BR_LEVEL | Specifies the Brotli compression level. Ranges from 0 to 11. | 4 |
COMPRESS_BR_MODE | For Brotli, the compression mode. The options are 0, 1, or 2. These correspond to 'generic', 'text' (for UTF-8 input), and 'font' (for WOFF 2.0). | 0 |
COMPRESS_BR_WINDOW | For Brotli, this specifies the base-2 logarithm of the sliding window size. Ranges from 10 to 24. | 22 |
COMPRESS_BR_BLOCK | For Brotli, this provides the base-2 logarithm of the maximum input block size. If zero is provided, value will be determined based on the quality. Ranges from 16 to 24. | 0 |
COMPRESS_DEFLATE_LEVEL | Specifies the deflate compression level. | -1 |
COMPRESS_MIN_SIZE | Specifies the minimum file size threshold for compressing files. | 500 |
COMPRESS_CACHE_KEY | Specifies the cache key method for lookup/storage of response data. | None |
COMPRESS_CACHE_BACKEND | Specified the backend for storing the cached response data. | None |
COMPRESS_REGISTER | Specifies if compression should be automatically registered. | True |
COMPRESS_ALGORITHM | Supported compression algorithms. | ['br', 'gzip', 'deflate'] |
Release historyRelease notifications | RSS feed
1.7.0
1.6.0
1.5.0
1.4.0
1.3. Adobe character animator cc 2019 v2 0 1 mac. 2 Icollections 4 3 – organize your desktop icons.
1.3.1
1.3.0
1.2.1
Squash — Web Image Compression 2 0 32
1.2.0
1.1.1
1.1.0
1.0.2
1.0.1
1.0.0
0.10.0
0.9
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size Flask-Compress-1.7.0.tar.gz (9.3 kB) | File type Source | Python version None | Upload date | Hashes |
Hashes for Flask-Compress-1.7.0.tar.gz
Squash — Web Image Compression 2 0 35
Algorithm | Hash digest |
---|---|
SHA256 | 965e832684160871b5268f97879c5e85a88569cc6e3e353a7779215664eefdad |
MD5 | 13898803b64b3dc466a778f599087b37 |
BLAKE2-256 | deeb6bb0f8cb872167752eab8b06b67724566342de873dcfd85faaf7761944d9 |