A minimal image viewer that reads PPM (P6) images from stdin and displays them using SDL2.
Built to stay close to the metal: raw file parsing, manual buffers, no image libraries.
- PPM P6 (binary)
maxval = 255only
PPM itself has no fixed or recommended aspect ratio — it’s just raw pixels.
That said, for sanity and performance:
- Recommended resolution:
800×600or640×480 - Aspect ratio:
4:3or16:9 - Avoid extremely large images (PPM is uncompressed and memory-heavy)
Best rule:
👉 Use a resolution that comfortably fits on screen and matches your SDL window.
Compile using SDL2:
gcc -o main main.c `sdl2-config --cflags --libs`Then run :
cat image.ppm | ./main