Published 星期六, 3月 08, 2008 by with 9 comments

[tip] 該用 PNG 還是 JPG 來存螢幕截圖


前些日子和異塵兄在討論 螢幕截圖是用 JPG 格式來存好呢,或是用 PNG 格式比較好?基於科學的精神,上網找了一下,Wikipedia 果然敘述的鉅細靡遺,PNG 和 JPG 優缺點分析如下:

JPEG can produce a smaller file than PNG for photographic (and photo-like) images since it uses a lossy encoding method specifically designed for photographic image data. Using PNG instead of a high-quality JPEG for such images would result in a large increase in filesize (often 5-10 times) with negligible gain in quality.

JPEG 在面對自然影像的時候,由於是採用失真壓縮演算法,因此壓縮率比 PNG 還要大。簡單來說,如果一張 風景照片 你用 JPG 來存,需要 1MB 的話,用 PNG 就要 5MB~10MB,雖然 PNG 檔案較大但是在視覺品質上面並沒有顯著的優越。

PNG is a better choice than JPEG for storing images that contain text, line art, or other images with sharp transitions. Where an image contains both sharp transitions and photographic parts a choice must be made between the large but sharp PNG and a small JPEG with artifacts around sharp transitions. JPEG also does not support transparency.

PNG 在處理包含文字、線條和明顯輪廓的影像 則較 JPG 來的優越,當影像有明顯輪廓邊緣,JPG 的失真演算法在處理這種邊緣上就會產生瑕疵,PNG 採用無失真演算法,因此影像品質較佳。

JPEG is a poor choice for storing images that require further editing as it suffers from generation loss, whereas lossless formats do not. This makes PNG useful for saving temporary photographs that require successive editing. When the photograph is ready to be distributed, it can then be saved as a JPEG, and this limits the information loss to just one generation.

若影像儲存在未來是需要更進一步的編輯修改的話則 PNG 是比較好的選擇,若是用 JPG 不斷的存取編輯,那麼圖像的品質就越來越差了。當影像已經編輯完畢準備散發傳播的話,JPG 則可以幫你縮小體積,卻不損失太多的畫質。

因此,寫 Blog 用的電腦視窗截圖,全面改用 PNG 吧,因為面對 這種 文字、線條和輪廓明顯的圖像,PNG 的檔案其實不會比 JPG 大多少,有時候可能還比較小呢 :)

圖像及引述文字來源 @ http://en.wikipedia.org/wiki/Portable_Network_Graphics#Comparison_with_JPEG