forked from mayanklahiri/easyexif
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mayank Lahiri
committed
Dec 3, 2014
1 parent
16c9cac
commit 6127e6b
Showing
19 changed files
with
976 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
The following people have contributed patches or issues to EasyEXIF: | ||
|
||
Seth Fowler | ||
Val Malykh | ||
Carlos Apablaza Brito | ||
Simon Fuhrmann | ||
Toshiaki Ohkuma | ||
pet.b.hunt | ||
Jason Moey |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
Copyright (c) 2014, Mayank Lahiri | ||
Copyright (c) 2010-2015 Mayank Lahiri | ||
mlahiri@gmail.com | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
-- Redistributions of source code must retain the above copyright notice, | ||
this list of conditions and the following disclaimer. | ||
-- Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESS | ||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN | ||
NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | ||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, | ||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,74 @@ | ||
easyexif | ||
======== | ||
|
||
Tiny ISO-compliant C++ EXIF parsing library, third-party dependency free. | ||
A tiny ISO-compliant C++ EXIF parsing library. | ||
|
||
EasyEXIF is a tiny, lightweight C++ library that parses basic information out of EXIF files. It uses only the std::string library and is otherwise pure C++. You pass it the the binary contents of an entire JPEG file, and it parses out a few of the most important EXIF fields for you. | ||
|
||
Why use this library? __Include one .h file, compile one .cc file, and that's it.__ | ||
|
||
Sometimes you just need to quickly extract basic information from a JPEG file's EXIF headers: the time the image was taken (not the file timestamp, the camera's internal time), the F-stop or exposure time, GPS information embedded in the EXIF file, what the camera make and model was, etc. Unfortunately, all the EXIF libraries out there are not very lightweight or easy to integrate into larger programs. EasyEXIF aims to solve that problem, and is released under a very liberal BSD License for use practically anywhere. | ||
|
||
### Features: | ||
|
||
1. Supports common Exif fields including GPS, ISO speed, etc. | ||
2. Extensively documented in the source. | ||
3. Valgrind tested for memory leaks. | ||
4. Handles corrupt JPEGs. | ||
5. Compiles without complaints using `-Wall -Wextra -Werror -pedantic -ansi` on gcc v4.8.2 | ||
6. No uses of new/malloc. | ||
|
||
### License | ||
|
||
BSD. | ||
|
||
### Contributions | ||
|
||
Reasonable pull requests are gladly accepted. | ||
|
||
The following people have committed patches to EasyExif. | ||
|
||
* Seth Fowler | ||
* Val Malykh | ||
* Carlos Apablaza Brito | ||
* Simon Fuhrmann | ||
* Toshiaki Ohkuma | ||
* pet.b.hunt | ||
* Jason Moey | ||
|
||
|
||
### Example: | ||
|
||
|
||
```C++ | ||
#include "exif.h" | ||
|
||
EXIFInfo result; | ||
result.parseFrom(JPEGFileBuffer, BufferSize); | ||
|
||
printf("Camera make : %s\n", result.Make.c_str()); | ||
printf("Camera model : %s\n", result.Model.c_str()); | ||
printf("Software : %s\n", result.Software.c_str()); | ||
printf("Bits per sample : %d\n", result.BitsPerSample); | ||
printf("Image width : %d\n", result.ImageWidth); | ||
printf("Image height : %d\n", result.ImageHeight); | ||
printf("Image description : %s\n", result.ImageDescription.c_str()); | ||
printf("Image orientation : %d\n", result.Orientation); | ||
printf("Image copyright : %s\n", result.Copyright.c_str()); | ||
printf("Image date/time : %s\n", result.DateTime.c_str()); | ||
printf("Original date/time: %s\n", result.DateTimeOriginal.c_str()); | ||
printf("Digitize date/time: %s\n", result.DateTimeDigitized.c_str()); | ||
printf("Subsecond time : %s\n", result.SubSecTimeOriginal.c_str()); | ||
printf("Exposure time : 1/%d s\n", (unsigned) (1.0/result.ExposureTime)); | ||
printf("F-stop : f/%.1f\n", result.FNumber); | ||
printf("ISO speed : %d\n", result.ISOSpeedRatings); | ||
printf("Subject distance : %f m\n", result.SubjectDistance); | ||
printf("Exposure bias : %f EV\n", result.ExposureBiasValue); | ||
printf("Flash used? : %d\n", result.Flash); | ||
printf("Metering mode : %d\n", result.MeteringMode); | ||
printf("Lens focal length : %f mm\n", result.FocalLength); | ||
printf("35mm focal length : %u mm\n", result.FocalLengthIn35mm); | ||
printf("GPS Latitude : %f deg\n", result.GeoLocation.Latitude); | ||
printf("GPS Longitude : %f deg\n", result.GeoLocation.Longitude); | ||
printf("GPS Altitude : %f m\n", result.GeoLocation.Altitude); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#include <stdio.h> | ||
#include "exif.h" | ||
|
||
int main(int argc, char *argv[]) { | ||
if (argc < 2) { | ||
printf("Usage: demo <JPEG file>\n"); | ||
return -1; | ||
} | ||
|
||
// Read the JPEG file into a buffer | ||
FILE *fp = fopen(argv[1], "rb"); | ||
if (!fp) { | ||
printf("Can't open file.\n"); | ||
return -1; | ||
} | ||
fseek(fp, 0, SEEK_END); | ||
unsigned long fsize = ftell(fp); | ||
rewind(fp); | ||
unsigned char *buf = new unsigned char[fsize]; | ||
if (fread(buf, 1, fsize, fp) != fsize) { | ||
printf("Can't read file.\n"); | ||
delete[] buf; | ||
return -2; | ||
} | ||
fclose(fp); | ||
|
||
// Parse EXIF | ||
EXIFInfo result; | ||
int code = result.parseFrom(buf, fsize); | ||
delete[] buf; | ||
if (code) { | ||
printf("Error parsing EXIF: code %d\n", code); | ||
return -3; | ||
} | ||
|
||
// Dump EXIF information | ||
printf("Camera make : %s\n", result.Make.c_str()); | ||
printf("Camera model : %s\n", result.Model.c_str()); | ||
printf("Software : %s\n", result.Software.c_str()); | ||
printf("Bits per sample : %d\n", result.BitsPerSample); | ||
printf("Image width : %d\n", result.ImageWidth); | ||
printf("Image height : %d\n", result.ImageHeight); | ||
printf("Image description : %s\n", result.ImageDescription.c_str()); | ||
printf("Image orientation : %d\n", result.Orientation); | ||
printf("Image copyright : %s\n", result.Copyright.c_str()); | ||
printf("Image date/time : %s\n", result.DateTime.c_str()); | ||
printf("Original date/time: %s\n", result.DateTimeOriginal.c_str()); | ||
printf("Digitize date/time: %s\n", result.DateTimeDigitized.c_str()); | ||
printf("Subsecond time : %s\n", result.SubSecTimeOriginal.c_str()); | ||
printf("Exposure time : 1/%d s\n", (unsigned) (1.0/result.ExposureTime)); | ||
printf("F-stop : f/%.1f\n", result.FNumber); | ||
printf("ISO speed : %d\n", result.ISOSpeedRatings); | ||
printf("Subject distance : %f m\n", result.SubjectDistance); | ||
printf("Exposure bias : %f EV\n", result.ExposureBiasValue); | ||
printf("Flash used? : %d\n", result.Flash); | ||
printf("Metering mode : %d\n", result.MeteringMode); | ||
printf("Lens focal length : %f mm\n", result.FocalLength); | ||
printf("35mm focal length : %u mm\n", result.FocalLengthIn35mm); | ||
printf("GPS Latitude : %f deg (%f deg, %f min, %f sec %c)\n", | ||
result.GeoLocation.Latitude, | ||
result.GeoLocation.LatComponents.degrees, | ||
result.GeoLocation.LatComponents.minutes, | ||
result.GeoLocation.LatComponents.seconds, | ||
result.GeoLocation.LatComponents.direction); | ||
printf("GPS Longitude : %f deg (%f deg, %f min, %f sec %c)\n", | ||
result.GeoLocation.Longitude, | ||
result.GeoLocation.LonComponents.degrees, | ||
result.GeoLocation.LonComponents.minutes, | ||
result.GeoLocation.LonComponents.seconds, | ||
result.GeoLocation.LonComponents.direction); | ||
printf("GPS Altitude : %f m\n", result.GeoLocation.Altitude); | ||
|
||
return 0; | ||
} |
Oops, something went wrong.