Skip to content

Instantly share code, notes, and snippets.

@andy-thomason
Created July 18, 2017 09:16
Show Gist options
  • Save andy-thomason/f41e62c6e773299811e3354cce2436d2 to your computer and use it in GitHub Desktop.
Save andy-thomason/f41e62c6e773299811e3354cce2436d2 to your computer and use it in GitHub Desktop.
Extract a thumbnail from a camera JPEG file using libexif
#include <stdio.h>
#include <libexif/exif-loader.h>
// Note: no error handling and no cleanup for clarity.
int main()
{
ExifLoader *loader = exif_loader_new();
exif_loader_write_file(loader, "IMG_20170422_132409.jpg");
ExifData *ed = exif_loader_get_data(loader);
ed = exif_loader_get_data(loader);
if (ed && ed->data && ed->size) {
fwrite(ed->data, 1, ed->size, fopen("thumb.jpg", "wb"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment