11

I have a raw file but I don't know the pixel format or the width of the image. I need a tool that can quickly display the data and allow me to try different formats easily. An example of such a tool for Windows would be 7yuv. What software exists for this task on Linux?

Note: This has nothing to do with digital camera raws, which is frustrating my attempts to use Google to answer this question.

7yuv

3
  • I'm guessing there are lots available (a quick search in the repos will propably give you more than enough results). The one I prefer though is digikam (I haven't tried many others though). I'm also certain that GIMP has a plugin that allows viewing and manipulating raw files.
    – VasPle
    Jun 7, 2012 at 0:19
  • Searching the repos finds nothing appropriate. Additionally, these aren't camera raws as stated in the question. Jun 7, 2012 at 12:53
  • Use can use 7yuv in Linux also through WINE. It has a silver rating so it will probably run just fine... if you can't find any linux native alternatives, give it a try.
    – VasPle
    Jun 7, 2012 at 14:38

3 Answers 3

10

Turns out Gimp can do this. Just open the file as raw, and you get this helpful dialog that allows you to preview the image:

enter image description here

4
  • 1
    How do you open the raw data file?
    – Val
    Mar 30, 2014 at 18:33
  • File->Open then change the file type to raw. Apr 1, 2014 at 23:42
  • 2
    It's only for RGB. how do you open grayscale (8bit) raw format?
    – Nathan B
    May 7, 2018 at 8:21
  • open do you open grayscale?
    – Nathan B
    Mar 10, 2021 at 17:44
6

convert from ImageMagick

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

printf '\x00\xFF\x88\xFF\x00\xFF' > in.bin

Then:

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

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:in.bin: the input file is in.bin, and the format is gray, as defined at http://www.imagemagick.org/script/formats.php This weird notation is used because ImageMagick usually determines the format from the extension, but here there is no extension.

How to view such tiny outputs like this example

The problem now is how to view the such a tiny 3x2 output accurately. A direct eog:

eog out.png

is not very good because the image is too small, and if you zoom in a lot eog uses a display algorithm that mixes up pixels continuously, which is better for most pictures, but not for such a tiny image.

One good possibility is to run:

convert out.png -scale 300x out2.png

or directly in one go with:

convert -depth 8 -size 3x2+0 gray:in.bin -scale 300x out.png

-scale is needed instead of -resize, since -resize mixes pixel colors continuously up much like eog by default.

Output:

enter image description here

Anther option is to view it in Gimp:

gimp out.png

Image editors such as Gimp must show every single pixel separately if you zoom in enough.

RGB example

printf '\xFF\x00\x00\x00\xFF\x00\x00\x00\xFF' > in.bin
convert -depth 8 -size 3x1+0 rgb:in.bin out.png

or with the -scale to make it more viewable:

convert -depth 8 -size 3x1+0 rgb:in.bin -scale 300x out.png

enter image description here

Related:

Tested on Ubuntu 16.04, ImageMagick 6.8.9.

4
  • 1
    This is a decent solution. I scripted it up with my inputs, and it works all the time.
    – C--
    Apr 12, 2019 at 18:52
  • how do i convert a mono image, 10bit, that each pixel is padded into a 16bit (2 bytes)?
    – Nathan B
    Mar 10, 2021 at 17:52
  • @NathanB I don't know and couldn't find easily after a quick Google, I'd just preprocess it in Python, let me know if you find a built-in way Mar 10, 2021 at 18:06
  • Yes found the way: convert -depth 16 -size 2688x1944+0 gray:a.png
    – Nathan B
    Mar 12, 2021 at 8:25
0

this python snippet does it:

from PIL import Image
import numpy as np


raw_img = np.fromfile("image",  dtype=np.uint8)
l = int(np.sqrt(raw_img.shape[0]/4))  # for a l x l square image
Image.frombytes(mode='RGBA', size=(l, l), data=raw_img).show()

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .