imagekbreducer.

Image field notes

The extension is not the format: checking what an image really is

A byte-level check of JPEG, PNG, WebP and HEIC signatures — why renaming a file does not convert it, and how to convert it properly before an upload.

When an upload form says “unsupported image” or “not a valid JPG”, the file size is often not the problem. A filename ending in .jpg is a label chosen by whatever wrote the file; the decoder reads the first bytes instead. Those two can disagree, and renaming a file does not reconcile them.

The extension is a filename, not a format

Operating systems use the extension to pick an icon and a default application. Browsers and image libraries usually do something better: they sniff the file's leading bytes and decode according to what they find. That is why a PNG renamed to .jpg still opens in a photo viewer — and why an upload validator that checks the actual encoding can still reject it, no matter what the name says.

This cuts both ways. A file can be rejected because its bytes are a format the service does not accept, or because the service's own extension check and decoder disagree about what the file is. Neither case is fixed by typing a different suffix.

What the first bytes actually say

Most common image formats announce themselves in a fixed signature at the start of the file. The values below are from the format specifications, not from guesswork.

FormatSignature at the start
PNG89 50 4E 47 0D 0A 1A 0A
JPEG (JFIF)FF D8 FF, then FF E0 for the JFIF segment
GIF47 49 46 38 (GIF8), then 37 61 or 39 61
WebP52 49 46 46 … 57 45 42 50 (RIFF … WEBP)
HEIC / HEIF66 74 79 70 at bytes 4–7, then a brand such as heic
AVIFSame ftyp box, brand avif or avis

A PNG's eight bytes are exactly the signature the specification defines; the stream then begins with an IHDR chunk. A JFIF JPEG starts with the start-of-image marker FF D8 and normally follows it with an APP0 segment beginning FF E0. GIF files spell GIF87a or GIF89a across the first six bytes. WebP is a RIFF container, so the first four bytes are RIFF and bytes 8–11 are WEBP.

HEIC and AVIF are container formats rather than one flat stream, so there is no single magic number the way there is for PNG. They are ISO base media files: bytes 4–7 are ftyp, bytes 8–11 hold the major brand as a four-character code, and a list of compatible brands follows after the four-byte minor version. The ftyp box comes first by design so that a reader can identify the file before parsing the rest; the brand registry defines what each code means, including the heic brand for HEVC-coded images.

A measured rename test

To see the difference between a label and a format, a 640 × 400 PNG was copied and given the name wrong.jpg. A real JPEG was copied and named wrong.png. Nothing else was altered.

FileFirst bytesStrict decoder
real.png89 50 4E 47 0D 0A 1A 0APNG, 640 × 400
wrong.jpg89 50 4E 47 0D 0A 1A 0ARejected as JPEG
photo.jpgFF D8 FF E0 … JFIFJPEG, 640 × 400
wrong.pngFF D8 FF E0 … JFIFRejected as PNG

Method: synthetic images were written locally with Pillow 12.3.0, copied with a new extension, then opened with the expected decoder constrained to that format; Pillow raised UnidentifiedImageError for the two mismatched pairs. The renamed copy and its original were byte-identical — wrong.jpg matched the PNG's SHA-256 59af6cb1… and wrong.png matched the JPEG's dcf2e87f… — because copying a file changes nothing inside it. A content-sniffing viewer will happily display wrong.jpg as a PNG; a validator that first requires a JPEG decoder will not.

What a real conversion changes

A conversion decodes the image and writes a new file in the target format. That is a real transformation with real side effects: bytes change, quality settings apply, and characteristics the target cannot store have to be resolved. Transparency is the clearest example.

JPEG has no alpha channel. A 200 × 120 RGBA test image with a fully transparent background was converted to JPEG in two ways: dropping the alpha channel directly, and compositing onto white first.

OutputBytesPixel that was transparent
Source PNG (RGBA)718alpha 0
JPEG, alpha dropped2,526RGB (0, 0, 0) — black
JPEG, composited on white2,835RGB (255, 255, 255) — white

Method: one synthetic image, Pillow for the conversion, and the saved JPEGs re-opened to sample the formerly transparent corner and the opaque centre. The centre colour was identical in both outputs. This is a controlled test of one encoder, not a benchmark of any conversion service. It does explain a familiar complaint: a logo or signature with a transparent background turns into a black box because the transparent pixels held no colour of their own, and the converter handed the encoder zeroes.

Image KB Reducer's PNG to JPG page describes exactly this: it composites onto white, or a colour you pick, before encoding. That is the product's published behaviour; this article did not audit the implementation.

HEIC is the mismatch most people meet

Recent iPhones can capture HEIC, and plenty of upload forms accept only JPG or PNG. The file may be genuinely HEIC with a .heic extension, or it may arrive from a sharing step that renamed or re-wrapped it. Either way, the useful question is not “what does the name say” but “what does the file contain, and can the destination decode it?”

Image KB Reducer's Convert Image page makes two claims worth quoting precisely: the source format is read from the file's own bytes, and HEIC images can be read but not produced, because the browser cannot encode HEIC. The same page says the target list only offers formats the current browser can actually encode, probed by test-encoding a one-pixel image. Those are product claims, checked against the page on 24 October 2026 and not independently reproduced here. The practical consequence is that HEIC can be an input to a conversion but never the output.

A check-and-convert workflow

  1. Inspect the file before changing anything. Open it in Image Info to see the detected format, stored dimensions, orientation and metadata blocks. Keep the original until the new file has passed.
  2. Read the destination's accepted list literally. Note the extensions and, if given, the MIME types. “JPG only” and “JPG or PNG” are different rules, and some forms also impose dimensions and a byte ceiling — the 50 KB workflow covers that part.
  3. Convert, do not rename. Use Convert Image when the pair is unusual. Use PNG to JPG when transparency needs a background colour, or JPG to PNG when you want a lossless copy for editing.
  4. Re-inspect the output. Confirm the detected format changed, the dimensions are still what you intended, the file is under any byte limit, and transparency was resolved the way you wanted. A new extension is not evidence that any of this happened.
  5. Only then upload. If the form still fails, re-read its error text. A format rejection and a size rejection are different problems, and fixing the wrong one wastes a good original.

Before you upload

  • The file's detected format matches the format the form accepts — checked, not assumed from the name.
  • Dimensions match the stated requirement, and any required orientation is applied.
  • Bytes are under the limit, measured on the saved file.
  • Transparency is preserved intentionally or flattened onto a deliberate colour.
  • The original file is kept separately in case the conversion needs to be redone.

Limits of this guide

The byte-level tests above use synthetic files and one library. Real camera files can carry maker-specific blocks, and a HEIC file's internal structure is more complex than its signature. No upload to any third-party portal was attempted for this article, so no acceptance or rejection behaviour is claimed; services differ in whether they inspect bytes, trust the extension or re-encode the file themselves. The format signatures are reproducible from the specifications cited below; the behaviour of a particular form must be read from that form's current instructions.

Browser-local processing is Image KB Reducer's published description, not an independent audit. Files containing identity documents belong only in tools whose handling you can justify.

Sources and scope

Sources checked 24 October 2026. Questions such as “file is not a valid image”, “heic renamed to jpg” and “unsupported image format upload” are hypotheses about reader intent, not measured search volumes.