Hi friends,
Can anyone tell me how to read JPEG files header using C ??
Hi friends,
Can anyone tell me how to read JPEG files header using C ??
Hello, you may want to start by telling what OS/compiler you are using and then it would be possible to suggest a graphics library for you to use to load the jpeg.
Hello Andrew,
I am actually trying to develop an backup application which backsup all the jpeg files in a backup folder.
For that I need to read the header of JPEG files.
I am using Windows-7 OS and MS Visual C++ compiler.
so can u please suggest me something so that I can get a good start ?
Basically, you just want to identify files in JPEG format through the file header? If so, maybe you could just code it yourself.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
can u give me a short example of how to do it ?
Here is the JPEG "header" format. Notice the marker that designates the file as a JPEG. Basically you would look for that marker and based on whether or not it was there would decide if it is or isn't a JPEG.
well I already have tha header format !!! look m very new to this kind of programming ..I have worked with files using C ..but that is just to an extent of reading and writing files..not much.... so can u please explain me with example !!!!!
Here is the file FAQ we have here. Read the binary files section. You are just reading in the first value of the file as designated by the file format you apparently already have.
Why wouldn't you just use the file extension?
Windows 7 does a horrible thing... it hides file extensions from the user.
Open your control panel -> Folder Settings -> View and uncheck "Hide extensions for known file types".
Now you can see that all your jpegs are actually named with a .jpg extension.
For example: FamilyPicnic turns out to be FamilyPicnic.jpg
There's no need to open the files, just copy everything with the .jpg extension.
Last edited by CommonTater; 07-11-2011 at 06:28 AM.
Tell you what... get started on the project, work it out as far as you can. If you get stuck (really stuck, not lazy stuck) post your code and I'm sure we can give you some suggestions.
In the mean time it's very easy to copy files by extension on Windows systems...
FindFirstFile Function (Windows) ... to enumerate the files
CopyFile Function (Windows) ... to do the actual copying
Hi commonTater,
well I know I can do it with file extension !!!! but still the program would require system calls to be used ..... I want to make the program absolutely portable !!!!!!! so theres where I am stuck !!!!!
There are no portable ways of dealing with the filesystem, if you need to (eg) work recursively through a directory tree. So to maximize your portability, keep this section of the code completely separate from everything else. Eg, you have a set of functions that reads the filesystem and accumulates an array of file paths to check.
This can be handed off to the jpg checking code, which can be 100% portable. Just stick to standard C: fopen() or open(), fread() or read(), etc.
It's a conclusive way of determining if a file is not a jpg; there is no conclusive way to say that it is a jpg. You have to make an educated guess.
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge