What is PGM?
PGM is the greyscale member of the Netpbm family: a three-line header, then one brightness value per pixel with no compression. It is what image-processing courses, OCR pipelines and computer-vision tools pass around when they want a format with no decoder in the way.
What is WEBP?
WebP is Google's image format for the web, and the rare one that does both jobs: lossy compression that beats JPEG at the same quality, lossless compression that beats PNG, and an alpha channel either way. Every current browser reads it; older software often still does not.