The format is a set of promises.
An image format decides what a file can hold (transparency, animation, extra brightness range), how it shrinks the pixels, and who can open it. Pick what your picture needs, and the list on the right ranks ten formats and tests each one in your browser.
Software doesn't trust the file extension. It reads a signature at the start, then finds the width and height, which every format stores in a different place and byte order. Your browser just saved the same 640 × 427 picture in each format it can write; these are the real bytes.
It depends on use: JPEG for photos, PNG for transparent graphics, WebP for web optimization, SVG for scalable logos.
WebP for photographs (25-35% smaller than JPEG). PNG for transparent graphics. SVG for icons and logos.
TIFF or high-quality JPEG for photographs. PDF or EPS for vector graphics. PNG for graphics with transparency.
JPG for photographs (smaller files). PNG for screenshots, logos, or images with transparency (sharper quality).
Raster images (JPEG, PNG) store pixel data. Vector images (SVG, AI) store mathematical paths that scale perfectly to any size.