Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Does there exist a program for Linux that can display raw binary data?

Each byte in my binary files represent a pixel, so it would be very useful if something like this exists where I could say

program_name --input=dat001.bin --width=200 --height=100

and it would display the pixels.

I wonder if gnuplot, can be used for this...?

share|improve this question
Question does not make sense. To display raw binary data, it must be converted to a human readable form. Usually this form is hexadecimal, which you can use hd to format. Then you ask to see an image. If it is an image, then it is going to be in an image format ( like bmp ) that will at the very least, have a header that identifies the format, the width, height, color depth, and maybe also have a color palette attached. – psusi Jun 8 '11 at 1:12
@psusi While the title would be better How to display raw pixel data, the intent of this question is clear, and totally makes sense to me. ("I want a program to let me specify the image meta data") Does it make more sense in hindsight (or perhaps after editing) to you also? – Nathan Kidd Sep 1 at 12:54
@NathanKidd, ahh, yes.. if you know it is an image using a specific format but has no header, rather than being just arbitrary binary data... got ya. – psusi Sep 4 at 17:56

4 Answers 4

To see the "raw binary data", I would use the hex dump command hd or hexdump

$ hd -C a.txt
00000000  61 0a 61 61 0a 61 61 61  0a 61 61 61 61 0a 61 61  ||
00000010  61 61 61 0a 62 62 62 0a  62 62 62 62 0a 62 62 62  |aaa.bbb.bbbb.bbb|
00000020  62 62 0a 3c 62 65 67 69  6e 3e 0a 61 61 61 61 61  |bb.<begin>.aaaaa|
00000030  61 0a 61 61 61 61 61 61  61 0a 61 61 61 61 61 61  |a.aaaaaaa.aaaaaa|
00000040  61 61 0a                                          |aa.|

I don't know of any image format that consists of unstructured bytes - is the data 8-bit RGB values? If the file contains 30000 bytes is that RGB for 100x100 pixels or RGB for 50x200 pixels or RGB for 200x50 pixels or something else? Is there a palette? You have to know something about the organisation of the data!

To view it as an image I would use the NetPBM utilities or maybe ImageMagick to convert it to a form understood by an image viewer

If the above can't do the job I'd investigate writing a small Perl script

share|improve this answer
Where can I get this? I just did yum search hd on my Fedora desktop, and it didn't have it. – Sandra Jun 7 '11 at 23:36
OKay. I need to see the pxiels as graphic... – Sandra Jun 7 '11 at 23:37
The binary might be called hexdump. On SuSE it is in the util-linux package. – Turbo J Jun 8 '11 at 0:30
FWIW it's also hexdump in Arch. – Sparhawk Oct 11 '14 at 12:20
up vote 6 down vote accepted

Okay, gnuplot can do it.

share|improve this answer

If not wanting to view it directly but rather convert it the convert utility can do this:

To read from stdin, assuming 320 x 200 pixels, 8 bit gray, header of 0, saving to pic.png in PNG format.

convert -depth 8 -size 320x200+0 gray:- pic.png
share|improve this answer
For newbs like me: gray:- means format gray and - means from stdin. Thus the current command hangs waiting for stdin. I've explained it further on my answer: – Ciro Santilli 六四事件 法轮功 包卓轩 Sep 26 at 7:56

convert from ImageMagick can do it.

E.g., an 8-bit 2x3 grayscale:

printf '\x00\xFF\x88\xFF\x00\xFF' > f


convert -depth 8 -size 3x2+0 gray:f out.png

And view the output with eog for example:

nohup eog out.png &>/dev/null &

Make sure to zoom a lot for such a small image.

If that wasn't the right one, change some parameter, e.g. let's make it 2x3:

convert -depth 8 -size 2x3+0 gray:f out.png

and eog automatically updates.

Command explanation:

  • -depth 8: each color has 8 bits
  • -size 2x3+0: 2x3 image. +0 means starting at offset 0 in the file. If there are metadata headers, you can skip them with the offset.
  • gray:f: the input file is f, and the format is gray, as defined at This weird notation is used because ImageMagick usually determines the format from the extension, but here there is no extension.

RGB example:

printf '\xFF\x00\x00\x00\xFF\x00\x00\x00\xFF' > f
convert -depth 8 -size 1x3+0 rgb:f out.png
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.