Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

If I open a picture file, lets say with an PNG extension, I will see bunch of code. Now let say I want to get some information from the picture mechanically. So the question here is what is the first step here, do I need to parse the picture?. If so how can I get the grammar for picture files? (PNG, JPEG, etc.)

UPDATE: Found an issue with my thinking!. Parsers are for text-based languages, however pictures are binary files. So, I dont think we need to parse them we need to go in the opposite direction and turn them into abstract syntax trees, wondering how to do so without knowing the grammar!

share|improve this question

closed as off-topic by Jim G., MichaelT, gnat, Bart van Ingen Schenau, GlenH7 Nov 3 '13 at 12:53

  • This question does not appear to be about software development within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

Specific to PNG, but this wikipedia article ( en.wikipedia.org/wiki/Portable_Network_Graphics ) should help get you started. Also what are you wanting to do with these image files once you've parsed them? –  Jamie Taylor Jul 13 '12 at 8:17
I'd use an existing image library and let it transform the images to pixel arrays –  ratchet freak Jul 13 '12 at 8:25
You do not open up an image file and see a "bunch of code" - you see a "bunch of encoded data". You see magic number, headers, sub-headers, various segment headers and their content and you see (possibly compressed) raw data, maybe several pages of them, MipMaps possibly, and so on. There is no real syntax so a AST doesn't make much sense here. What you can do is dump it all into structs and test them like any other variable - test the first 4 bytes (magic number), and even uncompress and build an image from the raw data - or use any mathmatical type analysis on it. –  Wolf5370 Jul 13 '12 at 17:52
you are so far from understanding basic concepts and theories of what you desire to do, nothing constructive will come out of this question in this context. If you have a specific question about a specific thing like how some specific operation in OpenCV works, then come back and ask here. Or about some specific function works in a library go to stackoverflow.com. But as it stands, you question and your comment show a very shallow superficial understanding of image processing in general, and information storage. It is too much knowledge to teach you in the comments here. This isn't a forum. –  Jarrod Roberson Jul 14 '12 at 4:07
This question appears to be off-topic because it does not demonstrate a minimal understanding of the problem being solved. –  Jim G. Nov 2 '13 at 1:44

1 Answer 1

common image file formats are usually public available on the internet. for example:

but you don't really want/need to read through whose specifications. open source image libraries are what you want to take a look at. depending on which language you are most familiar with, try out

each of them is quite popular and well documented. one of these will very well serve your needs ;)

what can be done with a image library often includes file type detection(file extension is unnecessary), meta data reading/writing, resizing, cropping, trasformation, file format conversion, basic image generation, etc. for advanced features, like OCR(Optical character recognition) and photo optimization, there are other tools that focus on each.

share|improve this answer

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