LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   finding information on image properties (https://www.linuxquestions.org/questions/programming-9/finding-information-on-image-properties-370484/)

datatab1 10-06-2005 09:32 PM

finding information on image properties
 
is anyone farmiliar with bitmaps? or images in general, i need to find the width and height of an image because it is not avalible in the library i am using.

or does anyone know where to find this out?

paulsm4 10-06-2005 11:06 PM

It depends entirely on the specific format.

Most graphics formats include h/w in the header ... but not all ... and it's almost always in a different representation, and at a different offset, in the file.

You need to know what kind of format you're dealing with!

Here's a great resource that might help:

http://www.dcs.ed.ac.uk/home/mxr/gfx/2d-hi.html
<= This is just one of many similar pages you can find from "google"

I'd also consider downloading and studying the source code for either of these legendary programs:

XV:
http://www.trilon.com/xv/downloads.html

The Gimp:
http://www.gimp.org/

'Hope that helps .. PSM

btmiller 10-07-2005 12:20 AM

In addition, www.wotsit.org is a good resource for finding details about various file formats (not just graphics).

datatab1 10-07-2005 12:37 AM

hmmm, they're ok,
i just have no idea what to google for, tried some things with bitmap and format or standard, didn't work.

what should i google for? header or something?

i'll take a closer look at those resources too.

paulsm4 10-07-2005 01:16 AM

OK, let's break it down:

1. Let's assume you want to know the height and width of a file

2. You clearly need to know what the file type is before you can determine the
height and width (or, for that matter, anything ELSE about the file). Right?

3. OK: maybe you already know the file type.
Great.

Look up the file format in one of the links above (or a link you've google'd for) and find where
the height and width is stored in the file header.

4. Maybe you can find a file parser to do this (there are plenty of them out there: including
in "xv" and "The Gimp". Or, for that matter, use "Windows, <Right-click>, Properties").

5. Otherwise, you can use a hex editor and look at the bytes.

The Linux command "od -cx FILENAME | less" is a common way to do this.

The goal, of course, is to match the bytes in the file spec (from the web link) to the corresponding
bytes in the file (which you're examining with "od -cx FILENAME | less").

6. Now let's assume you DON'T know the file type.
That's OK, too.

Many files can be identified by suffix (that's how Windows Explorer works).

Most graphics files have a "magic number" in the first bytes of their header
to identify the file type. The file format links above will give you a clue about
these "magic numbers".

And, if you're on Linux, you can use the "file FILENAME" command. Which is intelligent about
a lot of different file suffixes (like Windows) and about a lot of "magic numbers" (very UNLIKE
Windows).

'Hope that helps .. PSM


All times are GMT -5. The time now is 10:41 AM.