Raster graphics are made up of pixels arranged in a grid, while vector graphics use mathematical equations to define paths, points and curves. Common file formats for raster images include JPEG, TIFF, GIF and BMP, with JPEG best for photos and web due to lossy compression, and TIFF used for graphic design with lossless compression. Vector formats include AI, used for logos, and FLA for animations. Optimizing images makes them lighter and faster to download by reducing file size through lowering resolution, compression or trimming pixels, though this can degrade quality with excessive optimization.