<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>eddie.Yang's  creative &#187; web design</title>
	<atom:link href="http://www.ediyang.com/tag/web-design/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ediyang.com</link>
	<description>Creative change lives</description>
	<lastBuildDate>Wed, 14 Jul 2010 02:06:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>网页中图片格式选择与压缩</title>
		<link>http://www.ediyang.com/image-optimization/</link>
		<comments>http://www.ediyang.com/image-optimization/#comments</comments>
		<pubDate>Thu, 11 Jun 2009 12:40:00 +0000</pubDate>
		<dc:creator>eddie</dc:creator>
				<category><![CDATA[others]]></category>
		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://www.ediyang.com/%e7%bd%91%e9%a1%b5%e4%b8%ad%e5%9b%be%e7%89%87%e6%a0%bc%e5%bc%8f%e9%80%89%e6%8b%a9%e4%b8%8e%e5%8e%8b%e7%bc%a9/</guid>
		<description><![CDATA[我们知道在制作网页过程中图片占了一个十分重要的地位.尽管网速越来越快,但是图片太大依然是造成网页载入速度过慢的最重要原因之一.那么到底在GIF,PNG,JPG这些格式我们要选择哪一种作为候选格式,而哪种图片格式可以让图片更小,却拥有更好的图片质量呢?
]]></description>
			<content:encoded><![CDATA[<p>我们知道在制作网页过程中图片占了一个十分重要的地位.尽管网速越来越快,但是图片太大依然是造成网页载入速度过慢的最重要原因之一.</p>
<p>那么到底在GIF,PNG,JPG这些格式我们要选择哪一种作为候选格式,而哪种图片格式可以让图片更小,却拥有更好的图片质量呢?</p>
<p>1.图片格式</p>
<p><strong>GIF</strong></p>
<p>GIF最突出的地方就是他支持动画,同时GIF也是一种无损的图片格式,也就是说你在修改图片之后,图片质量并没有损失.再者GIF支持半透明(全透明或是全不透明).<br />
根据Google的说法,GIF适用于很小或是较简单的图片(10&#215;10以下或是3种颜色以下的图片).</p>
<p><strong>PNG</strong></p>
<p>首先,PNG包括了<strong>PNG-8</strong>跟<strong>真彩色-PNG</strong>(PNG-24 or PNG-32).那PNG相对于GIF最大的优势是:</p>
<ul>
<li>通常体积会更小</li>
<li>支持alpha(全透明)</li>
</ul>
<p>但是我们知道PNG是不支持动画的.</p>
<p>同时需要留意IE6是可以支持PNG-8的,但是在处理PNG-24的透明时会显示会灰色.相关例子可以参考<a href="http://www.sitepoint.com/blogs/2007/09/18/png8-the-clear-winner/">sitepoint</a>.</p>
<p>通常图片保存为PNG-8会在同等质量下获得比GIF更小的体积,而全透明的图片我们现在只能使用PNG-24.但是请留意在保存图片在PNG-8与GIF中进行比较.因为定律并不一直正确.</p>
<p><strong>JPG</strong></p>
<p>JPG所能显示的颜色比GIF,PNG要多的多,同时得到很好的压缩,所以JPG很适用于保存数码照片.但是注意它是一种失真压缩,这意味着你每次修改图片都会造成像素失真.</p>
<p>看了上面的介绍你应该对使用哪种格式保存哪种图片有了大概的了解.简单的说就是:</p>
<p><em>一句话:</em><strong>小图片或网页基本元素(如按钮),考虑PNG-8或GIF.照片则考虑JPG.</strong></p>
<h3>2.图片的压缩</h3>
<p>首先,我们如果是在Photoshop中制作的图片或是网站素材,在保存图片时,切记选择&#8221;文件-存储为Web和设备所用格式&#8221;.因为这样往往在同等质量下能获得更小的图片体积(相比直接&#8221;存储为&#8221;).请看下图:</p>
<p><img title="1" src="http://www.ediyang.com/wp-content/uploads/2009/06/1.gif" alt="Photoshop保存网页专用图片" /><br />
<strong>Smush it!</strong><br />
在按照上面方法存储图片之后,其实还是可以继续压缩图片大小的,而且我谈论的是不对图片质量造成损失的方法.</p>
<p>Smush it!包含在著名的著名插件YSlow之中,并确保已经安装了Firebug.使用方法很简单,只需要在YSlow中打开&#8221;tool&#8221;下的All Smush it! 将会跳转到一个新页面,对当前网页的图片进行压缩.而这些压缩都是在不损失图片质量下进行的.所以你大可放心.<br />
<img title="2" src="http://www.ediyang.com/wp-content/uploads/2009/06/2.png" alt="smush it" /><br />
6-15更新:由于&#8221;<strong>实践是检验真理的惟一方式</strong>&#8220;,那么我现在用Smush it!对本网站及<a href="http://vikiworks.com/">vikiworks.com</a>分别进行测试,结果显示<a href="http://www.ediyang.com ">ediyang.com</a>首页的图片压缩了6.52K,而<a href="http://vikiworks.com/">vikiworks.com</a>的首页压缩结果<strong>十分惊人</strong>,竟是46K,截图如下:<br />
<img class="alignnone size-full wp-image-738" title="smuchitresult" src="http://www.ediyang.com/wp-content/uploads/2009/06/smuchitresult.PNG" alt=" 网页中图片格式选择与压缩" width="493" height="168" /><br />
由此可见Smuch it!真的是图片压缩的<strong>一大利器</strong>.<br />
如果你想要单独压缩某一张图片,你可以到<br />
<a title="http://developer.yahoo.com/yslow/smushit/index.html" href="http://developer.yahoo.com/yslow/smushit/index.html">http://developer.yahoo.com/yslow/smushit/index.html</a><br />
只要填写图片的网址就可以进行压缩了.</p>
<p><em>Tips:</em>先在PS中保存为web格式图片,然后再使用Smush it!压缩图片.</p>
<h4>3.其他资料</h4>
<p>当然,如果你想要更深刻地了解这些知识,你可以选择下面的文章进行阅读:</p>
<p><a title="http://code.google.com/speed/page-speed/docs/payload.html#CompressImages" href="http://code.google.com/speed/page-speed/docs/payload.html#CompressImages">http://code.google.com/speed/page-speed/docs/payload.html#CompressImages</a></p>
<p><a title="http://yuiblog.com/blog/2008/10/29/imageopt-1/" href="http://yuiblog.com/blog/2008/10/29/imageopt-1/">http://yuiblog.com/blog/2008/10/29/imageopt-1/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ediyang.com/image-optimization/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->