Image Optimization

2019-06-08 01:47发布

问题:

I want to know like converting an image (gif or jpeg) to png8 using yslow smushit will increase the speed of the site performance? Will that work in ie6?

回答1:

It depends on the image. PNG is suited to images with blocks of color, whereas jpeg is good for photo type images. Smushit will shave off any extraneous bytes, reducing the filesize, but if you have many small images in separate files, then you should consider spriting them in order to reduce the number of connections required to load your page.

Reducing the filesize will help, but reducing the number of files helps the most (typically).



回答2:

It will make it quicker to download. PNG (AFAIK) will always be a smaller file size than GIF because it uses a better compression algorithm. Although some programs like Photoshop add a little overhead with meta data. It's also lossless, meaning you won't lose any of the image's quality.

It will work in IE6 because it supports PNG8. PNGs with 24 bit alpha transparency are not supported in IE6. There is a hack, but it's not optimal, though it is better than nothing.



回答3:

There are a lot of factors involved here:

  • the size in pixels of the image
  • the size in (mega)bytes of the image
  • the speed at which the image can be sent to the user. This is a combination of the speed of your server and the speed of the user's connection.
  • the time it takes the browser to read the image and convert it to a bitmap for display
  • the speed of the user's computer/graphics card combination.

I'm not sure that converting images to png is going to make that big a difference to your site's performance unless you know that the bottleneck is due to the size (in bytes) of your images. If the users have a slow connection then this isn't really going to help.



回答4:

Your question is very vague. I'll try answering anyway.

First of all, performance has two ends: The viewer of your site and the machine(s) where it runs on. The viewer will definitely benefit from smaller (in regard to filesize) images since it allows the page to load faster. For the server, the difference is usually not important, unless you are close to peak bandwidth of the connection.

For (non-animated) GIF images a conversion to PNG8 should be painless and beneficial, as PNG compresses much better. Also Internet Explorer 6 doesn't exhibit problems displaying PNG images with a 1 bit alpha channel (which is essentially what GIF has, too). When using an 8 bit alpha channel IE6 will have display artifacts.

Converting JPEG images to PNG will almost certainly increase the file size and won't improve image quality, so I'd advise against it.