Getting images ready for the web, email and social media

Pixel size versus file size, resize before compressing, JPG, PNG or WebP, social crops, metadata and favicons, with a measured 1600×1200 walkthrough.

Most image problems in an office come down to one confusion: pixel size and file size are different things, and the tool that fixes one is not the tool that fixes the other. Pixel size is how many pixels wide and tall the image is; it decides how large the picture appears and whether it is sharp. File size is how many bytes it occupies; it decides whether it loads, whether the email goes through, and whether the upload form accepts it. This guide separates the two, explains the format and quality decisions, covers crops for social media, metadata and favicons, and ends with a 1600 × 1200 photo prepared for a web page and for an email, with the output dimensions measured.

Resize before you compress

A photo from a phone is often 4000 pixels wide. A web page column is 800 to 1200 pixels wide, and an email preview is narrower still. Compressing the 4000-pixel file harder does reduce the bytes, but every pixel the browser then throws away was paid for in quality. The order is always: resize to the pixel size the destination will show, then compress what remains. Halving both dimensions removes three quarters of the pixels before any compression has happened.

Aspect Ratio Calculator does the arithmetic. Enter the original width and height and one new dimension; it fills in the other and shows the simplified ratio. For 1600 × 1200 it reports 4:3, and a new width of 1200 gives a height of 900; 800 gives 600. It works the other way too: a new height of 628 gives a width of 837. Enter 1200 × 628, the Facebook link size, and the ratio comes out as 300:157, which tells you a 4:3 photo cannot be resized into it without cropping.

Resize Image loads the file, fills in its current width and height, and keeps the ratio locked by default, so typing a new width updates the height. The output keeps the input format, PNG in, PNG out, and is named after the dimensions: photo-1600x1200-1200x900.png. Untick the ratio lock only when you really want a stretched image. Enlarging never adds detail; the browser only interpolates.

JPG, PNG or WebP

Three formats cover office use. JPG is for photographs and anything with gradients; it is lossy, with a quality setting, and has no transparency. PNG is for screenshots, diagrams, logos and anything with text or flat colour; it is lossless and supports transparency, which is why a photo saved as PNG is far larger than it needs to be. WebP does both jobs, usually in fewer bytes, and every current browser displays it; email clients and older office software are less reliable, so JPG and PNG remain the safe choice for attachments.

Convert Image Format re-encodes to JPG, PNG or WebP at a fixed quality of 92%. When converting to JPG it first paints a white background, so a transparent logo comes out on white rather than on black. The output is named after the original with the new extension: photo-1600x1200.jpg. Image File Size Estimator is for deciding before committing: choose a format and quality, and it shows the original size, the estimated size and the percentage change, re-estimating each time you move the slider; its download button hands you that encoded file.

The quality setting

Compress Image re-encodes at the quality you set, 75% by default, and reports the before and after in kilobytes. Two behaviours matter. A JPG stays a JPG, named -compressed.jpeg. A PNG is written out as WebP, because the tool's job is fewer bytes and a lossless re-encode would not deliver them; if the destination requires PNG, this is the wrong tool, and resizing is the only way to shrink a PNG here. For photographs, 75 to 85% is the usual range: below 70 the blocking becomes visible in skies and skin, and above 90 the file grows for no visible gain. Compress once, from the resized original. Re-compressing a compressed JPG adds artefacts on top of artefacts.

Crops for social media

Each platform wants a fixed shape, and a 4:3 photo matches none of them. Social Media Image Crop has six presets: Instagram square 1080 × 1080, Instagram portrait 1080 × 1350, story 1080 × 1920, Facebook link 1200 × 628, YouTube thumbnail 1280 × 720 and LinkedIn 1200 × 627. It crops the largest region of the source that has the target shape and scales it to the exact size. When the source is wider than the target shape, the crop is centred horizontally; when it is taller, the position setting (top, centre, bottom) chooses which part survives, which matters for faces and headlines. Output is always JPG at 90%, named with the preset size: the 1600 × 1200 photo produced photo-1600x1200-1200x628.jpg at exactly 1200 × 628, a 1080 × 1920 story with the top position, and a 1080 × 1080 square. For a crop at arbitrary coordinates, Crop Image takes x, y, width and height in pixels and writes a PNG.

What the file says about you

A photo straight from a phone carries EXIF data: camera model, date and time, and often the GPS position where it was taken. Web pages and social networks generally strip this on upload; email attachments and files placed on a shared drive do not. Remove Image Metadata handles one or many files at once by redrawing each image through a canvas and re-encoding it, which discards everything that was not pixels. PNG stays PNG and WebP stays WebP; anything else, including JPG, is written as JPG at 92%. The result is a ZIP named metadata-clean-images.zip containing photo-1600x1200-clean.png and so on. Because the image is re-encoded, do this as the last step, after resizing and compressing, or the cleaning pass will be undone by the next tool.

Favicons and icons

A site icon is needed in several sizes at once. Favicon PNG Generator takes one image and renders 16, 32, 48, 180, 192 and 512-pixel squares, each with its own download button, named favicon-16x16.png and so on. The source is fitted inside the square on a transparent background, so a non-square image is letterboxed rather than stretched. Start from a square PNG of at least 512 pixels with a simple shape; a 400 × 400 logo produced all six without complaint, but the 16-pixel version of anything detailed is a smudge.

Batches

Three batch tools return a ZIP. Batch Image Resizer has three modes: fit inside a width and height, exact size, and width only with the height following. Fit inside keeps proportions but also enlarges images smaller than the box: a 400 × 400 logo in a 1200 × 1200 box came out at 1200 × 1200. Width only at 800 gave 800 × 600, 800 × 800 and 800 × 200 for a photo, a logo and a banner, each named with its new size. PNG stays PNG; other formats become JPG at the quality you set. Batch Image Compressor re-encodes every file to the format you choose, JPG, WebP or PNG, at one quality, and reports the total before and after in megabytes; Batch Image Format Converter does the same conversion without the size report. For a mixed folder, resize first, then compress, in two passes.

Walkthrough: one photo, two destinations

The source is photo-1600x1200.png, a 1600 × 1200 PNG of 142 KB. It is wanted at 1200 pixels wide on a web page and at 800 pixels wide as an email attachment. Both destinations show it on screen, so JPG is the format, and neither needs transparency.

  1. Check the ratio. Aspect Ratio Calculator, 1600 × 1200: 4:3. New width 1200 gives height 900; new width 800 gives height 600.
  2. Resize for the web. Resize Image loads the file showing 1600 and 1200 with the ratio locked. Type 1200 in the width box; the height box changes to 900. Process. Output photo-1600x1200-1200x900.png, measured at 1200 × 900.
  3. Resize for email. Same tool, width 800; the height box reads 600. Output photo-1600x1200-800x600.png, measured at 800 × 600.
  4. Convert to JPG. Convert Image Format, each file in turn, format JPG. Outputs photo-1600x1200-1200x900.jpg at 1200 × 900 and photo-1600x1200-800x600.jpg at 800 × 600.
  5. Compress the web copy. Compress Image on the 1200 × 900 JPG at 75%. Output photo-1600x1200-1200x900-compressed.jpeg, still 1200 × 900. The email copy at 800 × 600 can be sent as it is from step 4.
  6. Strip metadata if the original came from a camera. Remove Image Metadata on the finished files, last.

The dimensions are quoted rather than the byte counts because the sample is a synthetic gradient, which compresses very differently from a photograph; the ratios would not carry over to your files. The sequence does: resize to the display size, convert to the display format, compress once, clean last.

Before you upload or attach

  • Open the output and check the pixel size matches what you typed; the filename carries it.
  • If the destination lists a maximum file size, test the compressed file against it rather than guessing.
  • Keep the original. Every step here writes a new file, and a resized copy cannot be enlarged back.
  • For anything with transparency or text, stay with PNG or WebP; a JPG of a screenshot is blurry around every letter.

像素尺寸與檔案大小的差別、先縮放再壓縮、JPG/PNG/WebP 的選擇、社群裁切、中繼資料與網站圖示,並以一張 1600×1200 的照片實作。

辦公室裡大多數的圖片問題都來自同一個混淆:像素尺寸與檔案大小是兩回事,修其中一個的工具修不了另一個。像素尺寸是圖片有多少像素寬、多少像素高,決定圖看起來多大、清不清楚。檔案大小是它佔多少位元組,決定載不載得出來、郵件寄不寄得出去、上傳表單收不收。本文把兩者分開談,說明格式與品質的取捨,涵蓋社群媒體裁切、中繼資料與網站圖示,最後把一張 1600 × 1200 的照片分別為網頁與電子郵件準備好,並量測輸出尺寸。

先縮放,再壓縮

手機拍的照片常常有 4000 像素寬。網頁欄位寬 800 到 1200 像素,郵件預覽更窄。把 4000 像素的檔案壓得更狠確實能減少位元組,但瀏覽器之後丟掉的每一個像素都是用畫質換來的。順序永遠是:先縮到目的地會顯示的像素尺寸,再壓縮剩下的部分。寬高各減半,在任何壓縮發生之前就已經去掉四分之三的像素。

長寬比例計算器負責算術。輸入原始寬高與新的其中一邊,它會補上另一邊並顯示約分後的比例。1600 × 1200 得到 4:3,新寬度 1200 對應高度 900;800 對應 600。反過來也行:新高度 628 對應寬度 837。輸入 Facebook 連結圖的 1200 × 628,比例會是 300:157,這告訴你 4:3 的照片不裁切是縮不進去的。

調整圖片尺寸載入檔案後會填入目前的寬高,預設鎖定比例,所以輸入新寬度時高度會跟著更新。輸出沿用輸入格式,PNG 進 PNG 出,檔名帶著尺寸:photo-1600x1200-1200x900.png。只有真的要把圖拉變形時才取消鎖定比例。放大不會增加細節,瀏覽器只是在內插。

JPG、PNG 還是 WebP

辦公用途三種格式就夠了。JPG 用於照片與任何有漸層的圖;它是有損的,有品質設定,不支援透明。PNG 用於截圖、圖表、標誌與任何有文字或平塗色塊的圖;它是無損的,支援透明,這也是為什麼存成 PNG 的照片遠比需要的大。WebP 兩種工作都能做,通常位元組更少,所有現行瀏覽器都能顯示;郵件軟體與較舊的辦公軟體就沒那麼可靠,所以附件仍以 JPG 與 PNG 最保險。

圖片格式轉換以固定 92% 的品質重新編碼成 JPG、PNG 或 WebP。轉成 JPG 時會先鋪一層白底,所以透明的標誌會落在白色而不是黑色上。輸出以原檔名加新副檔名命名:photo-1600x1200.jpg。圖片檔案大小估算用來在決定前先看:選好格式與品質,它會顯示原始大小、估計大小與變化百分比,每次拉動滑桿都重新估算;它的下載按鈕會把那個編碼後的檔案交給你。

品質設定

壓縮圖片以你設定的品質(預設 75%)重新編碼,並以 KB 回報前後大小。有兩個行為要注意。JPG 仍是 JPG,檔名加上 -compressed.jpeg。PNG 則會被寫成 WebP,因為這個工具的任務是減少位元組,無損重編碼做不到;若目的地要求 PNG,這就不是對的工具,在這裡縮放是縮小 PNG 的唯一方法。照片通常落在 75 到 85%:低於 70 天空與皮膚會出現可見的方塊,高於 90 檔案變大卻看不出差別。只壓縮一次,而且從縮放後的原檔壓。對已壓縮的 JPG 再壓一次,只是在瑕疵上疊瑕疵。

社群媒體裁切

每個平台都要固定的形狀,而 4:3 的照片一個都不符。社群媒體圖片裁切有六個預設:Instagram 正方形 1080 × 1080、Instagram 直式 1080 × 1350、限時動態 1080 × 1920、Facebook 連結 1200 × 628、YouTube 縮圖 1280 × 720 與 LinkedIn 1200 × 627。它從來源圖裁出符合目標形狀的最大區域,再縮放到精確尺寸。來源比目標形狀更寬時,裁切水平置中;更高時,位置設定(上、中、下)決定留下哪一段,這對人臉與標題很重要。輸出一律是 90% 的 JPG,檔名帶預設尺寸:1600 × 1200 的照片產出了正好 1200 × 628 的 photo-1600x1200-1200x628.jpg、以「上」位置裁出的 1080 × 1920 限時動態,以及 1080 × 1080 的正方形。要用任意座標裁切,圖片裁剪接受以像素表示的 x、y、寬、高,輸出 PNG。

檔案透露了你什麼

手機直接拍出的照片帶有 EXIF 資料:相機型號、日期時間,常常還有拍攝地點的 GPS 位置。網頁與社群平台上傳時通常會去掉這些;郵件附件與放在共用磁碟上的檔案不會。移除圖片中繼資料可一次處理一個或多個檔案,做法是把每張圖透過畫布重畫再重新編碼,像素以外的東西全部丟掉。PNG 仍是 PNG,WebP 仍是 WebP;其他格式包括 JPG 都以 92% 寫成 JPG。結果是名為 metadata-clean-images.zip 的 ZIP,裡面是 photo-1600x1200-clean.png 等檔案。因為圖片會被重新編碼,這一步要放在最後,在縮放與壓縮之後做,否則清理的結果會被下一個工具抵銷。

網站圖示

網站圖示需要一次準備好幾種尺寸。Favicon PNG 產生器從一張圖產生 16、32、48、180、192 與 512 像素的正方形,各有自己的下載按鈕,檔名為 favicon-16x16.png 等。來源圖會以透明背景放進正方形裡,所以非正方形的圖是留白而不是拉伸。請從至少 512 像素、造型簡單的正方形 PNG 開始;一張 400 × 400 的標誌順利產出全部六種,但任何細節豐富的圖在 16 像素下都只是一團糊。

批次處理

三個批次工具都回傳 ZIP。批量調整圖片尺寸有三種模式:限制框內(指定寬高)、指定尺寸,以及僅依寬度(高度跟隨)。限制框內會維持比例,但也會把比框小的圖放大:400 × 400 的標誌放進 1200 × 1200 的框,出來是 1200 × 1200。僅依寬度設 800,照片、標誌與橫幅分別得到 800 × 600、800 × 800 與 800 × 200,檔名各自帶著新尺寸。PNG 仍是 PNG;其他格式以你設定的品質變成 JPG。批量圖片壓縮把每個檔案以同一個品質重新編碼成你選的 JPG、WebP 或 PNG,並以 MB 回報總量前後;批量圖片格式轉換做同樣的轉換,但不回報大小。混雜的資料夾分兩趟處理:先縮放,再壓縮。

實作:一張照片,兩個目的地

來源是 photo-1600x1200.png,一張 1600 × 1200、142 KB 的 PNG。網頁上要 1200 像素寬,郵件附件要 800 像素寬。兩個目的地都在螢幕上顯示,所以格式是 JPG,也都不需要透明。

  1. 確認比例。長寬比例計算器,1600 × 1200:4:3。新寬度 1200 對應高度 900;新寬度 800 對應高度 600。
  2. 為網頁縮放。調整圖片尺寸載入檔案後顯示 1600 與 1200,比例鎖定。在寬度框輸入 1200,高度框變成 900。執行。輸出 photo-1600x1200-1200x900.png,量測為 1200 × 900。
  3. 為郵件縮放。同一個工具,寬度 800,高度框顯示 600。輸出 photo-1600x1200-800x600.png,量測為 800 × 600。
  4. 轉成 JPG。圖片格式轉換,兩個檔案輪流,格式 JPG。輸出 1200 × 900 的 photo-1600x1200-1200x900.jpg 與 800 × 600 的 photo-1600x1200-800x600.jpg。
  5. 壓縮網頁版。對 1200 × 900 的 JPG 用壓縮圖片,75%。輸出 photo-1600x1200-1200x900-compressed.jpeg,仍是 1200 × 900。800 × 600 的郵件版直接用第 4 步的結果即可。
  6. 若原檔來自相機,去掉中繼資料。最後對完成的檔案跑移除圖片中繼資料。

這裡引用尺寸而不是位元組數,因為樣本是人工合成的漸層圖,壓縮表現和真正的照片差很多,比例數字套不到你的檔案上。順序則套得上:縮到顯示尺寸、轉成顯示格式、壓縮一次、最後清理。

上傳或附加之前

  • 開啟輸出檔,確認像素尺寸和你輸入的一致;檔名就帶著它。
  • 若目的地列有檔案大小上限,拿壓縮後的檔案實際測,不要用猜的。
  • 保留原檔。這裡每一步都會寫出新檔,縮小過的副本放不回去。
  • 任何帶透明或文字的圖,留在 PNG 或 WebP;截圖存成 JPG,每個字母周圍都會糊。