Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 10-06-2005, 09:32 PM   #1
LQ Newbie
Registered: Sep 2005
Location: USA western
Distribution: fedora core 4
Posts: 10

Rep: Reputation: 0
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?
Old 10-06-2005, 11:06 PM   #2
LQ Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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:
<= 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:


The Gimp:

'Hope that helps .. PSM
Old 10-07-2005, 12:20 AM   #3
Senior Member
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,284

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
In addition, is a good resource for finding details about various file formats (not just graphics).
Old 10-07-2005, 12:37 AM   #4
LQ Newbie
Registered: Sep 2005
Location: USA western
Distribution: fedora core 4
Posts: 10

Original Poster
Rep: Reputation: 0
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.
Old 10-07-2005, 01:16 AM   #5
LQ Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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.

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

'Hope that helps .. PSM


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Looking to extract image properties in C++ plisken Programming 1 11-24-2005 08:22 AM
Finding Image Magick Binary Cyric Slackware 1 10-17-2004 09:28 PM
Finding information about the current shell atirya_yodha Linux - Newbie 3 03-18-2004 01:30 PM
Need help finding information for Mandrake. CyberLord_7 Mandriva 3 10-15-2003 03:30 PM
perl script to insert image information rhuser Programming 1 03-12-2003 05:23 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:13 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration