ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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!
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).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.