Quick visualization of a binary file

hugsy 2 December 2018

Reading time: 1 min

Here’s a simple trick that I learned from the amazing @scanlime to quickly (and universally) visualize the distribution of byte of any binary file, using the Portable Graymap Format (PGM) format.

On Windows:

C:\> echo P5 512 4096 255 > %TEMPDIR%\visu.pgm & ^
     type \path\to\file\to\visualize.whatever >> %TEMPDIR%\visu.pgm

Or on Linux/OSX:

$ (echo "P5 512 4096 255";
   cat /path/to/file/to/visualize.whatever) > /tmp/visu.pgm

Then open the file with any image viewer like feh or IrFanView.

evil.dll.pgm