JEY exif420 v2 Documentation

Supported Metadata & EXIF Data

ExifData Struct

struct ExifData {
    std::string dateTime;
    std::string make;
    std::string model;
    std::string software;

    double exposureTime; 
    double fNumber;  
    int32_t iso;   
    double focalLength;   

    uint32_t width;
    uint32_t height;
    int16_t orientation;  
};

Importing the Image

std::ifstream file("my_photo.jpg", std::ios::binary);
if (!file) {
    std::cerr << "CRITICAL ERROR: Could not open file 'my_photo.jpg'" << std::endl;
    return 1;
}s

std::vector<uint8_t> file_bytes((std::istreambuf_iterator<char>(file)), 
                                    std::istreambuf_iterator<char>());

Use this or any other method to get the image file bytes into a std::vector. In this example the image is loaded into a variable called file_bytes. To get the ExifData from this file use the ExtractExifData() function.

ExtractExifData() Function

ExifData ExtractExifData(const std::vector<uint8_t>& buf);

You will use this function to extract the ExifData from the file bytes (std::vector). It will return ExifData.

Support The Project

This project took a lot of work and thinking to get it working properly and effeciently. It would be greatly appreciated if you would consider supporting me via Ko-Fi

ko-fi

Examples

Example usage of exif420::PrintExifData(const ExifData& data):

#include "exif420.h"
#include <iostream>
#include <vector>
#include <fstream>

int main() {
    std::ifstream file("my_photo.jpg", std::ios::binary);
    if (!file) {
        std::cerr << "CRITICAL ERROR: Could not open file 'my_photo.jpg'" << std::endl;
        return 1;
    }

    std::vector<uint8_t> file_bytes((std::istreambuf_iterator<char>(file)), 
                                     std::istreambuf_iterator<char>());

    exif420::ExifData photo_data = exif420::ExtractExifData(file_bytes);

    exif420::PrintExifData(photo_data);

    return 0;
}

An example for an output would be:

Make:         Canon
Model:        Canon EOS 40D
Software:     GIMP 2.4.5
Date/Time:    2008:05:30 15:56:01
ISO:          100
F-Number:     f/7.1
Exposure:     0.00625s
Focal Length: 135mm
Dimensions:   100x68

Example usage of extracting a single value from ExifData:

#include "exif420.h"
#include <iostream>
#include <vector>
#include <fstream>

int main() {
    std::ifstream file("my_photo.jpg", std::ios::binary);
    if (!file) {
        std::cerr << "CRITICAL ERROR: Could not open file 'my_photo.jpg'" << std::endl;
        return 1;
    }

    std::vector<uint8_t> file_bytes((std::istreambuf_iterator<char>(file)), 
                                     std::istreambuf_iterator<char>());

    exif420::ExifData photo_data = exif420::ExtractExifData(file_bytes);

    std::cout << photo_data.dateTime;

    return 0;
}

An example for an output would be:

2008:05:30 15:56:01