30 static const unsigned char header[4] = {
'\xff',
'\xd8',
'\xff',
'\xe1'};
32 int main(
const int argc,
const char *argv[])
35 const char *fn =
"input.jpg";
36 const char *outfn =
"output.exif";
41 unsigned char lenbuf[2];
43 if (argc > 1 && !strcmp(argv[1],
"-o")) {
52 fprintf (stderr,
"Too many arguments\n");
58 fprintf (stderr,
"Could not load data from '%s'!\n", fn);
66 fprintf (stderr,
"Could not extract EXIF data!\n");
70 f = fopen(outfn,
"wb");
72 fprintf (stderr,
"Could not open '%s' for writing!\n", outfn);
77 fprintf (stderr,
"Could not write to '%s'!\n", outfn);
86 if (fwrite(lenbuf, 1, 2, f) != 2) {
87 fprintf (stderr,
"Could not write to '%s'!\n", outfn);
90 if (fwrite(buf, 1, len, f) != len) {
91 fprintf (stderr,
"Could not write to '%s'!\n", outfn);
95 fprintf (stderr,
"Could not close '%s'!\n", outfn);
99 fprintf (stderr,
"Wrote EXIF data to '%s'\n", outfn);
@ EXIF_BYTE_ORDER_MOTOROLA
Big-endian byte order.
void exif_data_unref(ExifData *data)
ExifData * exif_data_new_from_file(const char *path)
Allocate a new ExifData and load EXIF data from a JPEG file.
void exif_data_save_data(ExifData *data, unsigned char **d, unsigned int *ds)
Store raw EXIF data representing the ExifData structure into a memory buffer.
Defines the ExifData type and the associated functions.
void exif_set_short(unsigned char *b, ExifByteOrder order, ExifShort value)
Store an ExifShort value into memory in EXIF format.
Represents the entire EXIF data found in an image.