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;
};
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
ExifData ExtractExifData(const std::vector<uint8_t>& buf);
You will use this function to extract the ExifData from the file bytes (std::vector
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
#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
#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