Working with EXIF metadata

What is EXIF?

According to the specification, EXIF (Exchangeable image file format) is a standard that specifies the formats to be used for images, sound and tags in digital still cameras and in other systems handling the image and sound files recorded by digital still cameras. Despite the confusing definition and name of the format, EXIF is just a metadata standard. In fact, it simply defines a way to store metadata properties in a variety of well-known image and audio formats. The EXIF tag structure is borrowed from TIFF files. The specification declares a set of tags intended to store technical details such as the geolocation of the place where a picture was taken, the name of the camera owner, camera settings, etc. 

Note
Please refer to the following article to get more information on the standard.

Reading basic EXIF properties

To access EXIF metadata in a file of any supported format, GroupDocs.Metadata provides the IExif.getExifPackage method. The following are the steps to read EXIF metadata:

  1. Load a file that contains EXIF metadata
  2. Extract the EXIF metadata package using the IExif.getExifPackage method

The following code snippet gets EXIF properties of a TIFF image and displays them on the screen. 

advanced_usage.working_with_metadata_standards.exif.ReadBasicExifProperties

const metadata = new groupdocs.metadata.Metadata(Constants.TiffWithExif);
    var root = metadata.getRootPackage();
            if (root.getExifPackage() != null) {
                console.log(root.getExifPackage().getArtist());
                console.log(root.getExifPackage().getSoftware());

                // ...

                console.log(root.getExifPackage().getExifIfdPackage().getBodySerialNumber());

                // ...

                console.log(root.getExifPackage().getGpsPackage().getAltitude());

                // ...
            }

Here is a full list of tags that can be added to an EXIF package:

  • TiffAsciiTag
  • TiffByteTag
  • TiffDoubleTag
  • TiffFloatTag
  • TiffLongTag
  • TiffRationalTag
  • TiffSByteTag
  • TiffShortTag
  • TiffSLongTag
  • TiffSRationalTag
  • TiffSShortTag
  • TiffUndefinedTag

Removing EXIF metadata

To remove the EXIF package from a file just pass null to the IExif.setExifPackage method. The code sample below shows how to remove EXIF metadata from a file.

advanced_usage.working_with_metadata_standards.exif.RemoveExifMetadata

const metadata = new groupdocs.metadata.Metadata(Constants.TiffWithExif);
    var root = metadata.getRootPackage();
    root.setExifPackage(null);
    metadata.save(Constants.OutputJpeg);
}

More resources

Advanced usage topics

To learn more about library features and get familiar how to manage metadata and more, please refer to theadvanced usage section.

GitHub examples

You may easily run the code above and see the feature in action in our GitHub examples:

Free online document metadata management App

Along with a full featured Java library we provide simple, but powerful free Apps.

You are welcome to view and edit metadata of PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX, emails, images and more with our free online Free Online Document Metadata Viewing and Editing App.