比较容易读懂,在这就不翻译了。这里总结下:图片压缩其实很简单,去掉不用的部分,选择合适的存储格式根据图片质量要求进行压缩(重点参见第二节第二段)。
Author: Susie Sahim, Web Designer and Google Doodler
Recommended skills: Basic image manipulation
When you optimize every line of code for your website, don’t forget about your static content - including images. Simple improvements can drastically decrease your download size, without diminishing the site’s quality.
Here are a few tips to help you make your web graphics load faster
Crop out excess white space
Sometimes you have extra space or padding around graphics so that they don’t touch accompanying text or web page elements. Instead, crop out that space and use CSS to create the padding around the graphic.
Use the best file format
For images containing flat illustrations or artwork, use the 8-bit PNG or GIF format and reduce the number of colors in the palette. Some image programs such as PhotoShop allow you to save the image for the web and fine-tune the image settings. By reducing the color palette from 256 to something like 32, you greatly reduce the size of the file. The less colors that the image has, the smaller the file size is going to be.
For very detailed and colorful artwork or for photographics, JPG and 24-bit PNG are typically used because they have a much larger color palette. While a 24-bit PNG results in superior image quality, this comes at the price of a larger file size. When you can, use JPG instead and adjust the quality setting so you can compress the image as much as possible within your desired tolerance for image quality.
To compare and contrast, here are the file sizes of the above graphic in various formats:
- JPG, 60 quality - 32K
- PNG-8, 256 colors - 37K
- GIF, 256 colors - 42K
- PNG-24 - 146K
Also note that JPG has an option called “Progressive” mode. This option adds multiple copies of the image at lower resolution to make the image appear quickly on the screen, while progressively improving in quality. But it also increases the overall size of the image.
PNG also has a similar feature called “Interlaced”. You may want to turn this feature off so that the full image downloads quicker.
Because the 8-bit PNG and GIF formats have the potential to result in much smaller image files, try to keep this in mind when creating graphics and illustrations for your site. Try to keep the amount of colors to a minimum and use flat graphics instead of photographs. This way you can create images with palettes of 16 colors, keeping the file size extremely small and fast to download.