@capawesome/capacitor-exif
v0.1.2
Published
Capacitor plugin to read, write and remove EXIF metadata from image files on Android and iOS.
Maintainers
Readme
Capacitor Exif Plugin
Capacitor plugin to read, write and remove EXIF metadata from image files.
Features
- 📖 Read: Read typed EXIF tags like GPS position, camera model, and capture date.
- ✍️ Write: Update EXIF tags in place without touching the rest of the file.
- 🕵️ Privacy: Strip GPS positions and other sensitive metadata before uploading images.
- 💎 Lossless: The pixel data is never re-encoded, so the image quality is not affected.
- 🖼️ HEIC support: Read and write HEIC metadata natively, which JavaScript libraries can not do.
- ⚡ Native performance: Files are processed natively and never loaded into the WebView memory.
- 🔒 App Store safe: Uses only official platform APIs.
- 🤝 Compatibility: Works alongside the File Picker, File Compressor and Photo Editor plugins.
- 📦 CocoaPods & SPM: Supports CocoaPods and Swift Package Manager for iOS.
- 🔁 Up-to-date: Always supports the latest Capacitor version.
Missing a feature? Just open an issue and we'll take a look!
Use Cases
The Exif plugin is typically used whenever an app needs to work with photo metadata, for example:
- Privacy protection: Strip GPS positions and other sensitive metadata from photos before uploading them to a server.
- Photo organization: Read the capture date and GPS position to sort and group photos.
- Metadata correction: Fix a wrong capture date or add a missing GPS position without re-encoding the image.
- Camera details: Display camera and lens information such as ISO, aperture, and exposure time in a photo detail view.
Compatibility
| Plugin Version | Capacitor Version | Status | | -------------- | ----------------- | -------------- | | 0.x.x | >=8.x.x | Active support |
Installation
You can use our AI-Assisted Setup to install the plugin. Add the Capawesome Skills to your AI tool using the following command:
npx skills add capawesome-team/skills --skill capacitor-pluginsThen use the following prompt:
Use the `capacitor-plugins` skill from `capawesome-team/skills` to install the `@capawesome/capacitor-exif` plugin in my project.If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:
npm install @capawesome/capacitor-exif
npx cap syncAndroid
Variables
This plugin will use the following project variables (defined in your app’s variables.gradle file):
$androidxExifInterfaceVersionversion ofandroidx.exifinterface:exifinterface(default:1.4.2)
iOS
No additional configuration is required for this plugin.
Configuration
No configuration required for this plugin.
Usage
The following examples show how to read the EXIF metadata of an image, write EXIF tags to an image, and remove the EXIF metadata from an image.
Read the EXIF metadata of an image
Read typed EXIF tags such as the GPS position, camera model, and capture date from an image file. Only available on Android and iOS:
import { Exif } from '@capawesome/capacitor-exif';
const readExif = async () => {
const { tags } = await Exif.readExif({
path: 'file:///path/to/photo.jpg',
});
console.log('GPS position:', tags.gpsLatitude, tags.gpsLongitude);
};Write EXIF tags to an image
Update EXIF tags in place. Only the provided tags are updated and the pixel data is never re-encoded. Only available on Android and iOS:
import { Exif } from '@capawesome/capacitor-exif';
const writeExif = async () => {
await Exif.writeExif({
path: 'file:///path/to/photo.jpg',
tags: {
dateTimeOriginal: '2026:01:15 10:30:00',
gpsLatitude: 51.503364,
gpsLongitude: -0.127625,
},
});
};Remove the EXIF metadata from an image
Strip all EXIF metadata from an image file in place, for example to protect the privacy of your users before an upload. By default, the orientation tag is kept so that the image is not suddenly displayed rotated. Only available on Android and iOS:
import { Exif } from '@capawesome/capacitor-exif';
const removeExif = async () => {
await Exif.removeExif({
path: 'file:///path/to/photo.jpg',
});
};API
readExif(...)
readExif(options: ReadExifOptions) => Promise<ReadExifResult>Read the EXIF metadata of an image file.
Only available on Android and iOS.
| Param | Type |
| ------------- | ----------------------------------------------------------- |
| options | ReadExifOptions |
Returns: Promise<ReadExifResult>
Since: 0.1.0
removeExif(...)
removeExif(options: RemoveExifOptions) => Promise<void>Remove the EXIF metadata from an image file in place.
The pixel data is never re-encoded, so the image quality is not affected.
Only available on Android and iOS.
| Param | Type |
| ------------- | --------------------------------------------------------------- |
| options | RemoveExifOptions |
Since: 0.1.0
writeExif(...)
writeExif(options: WriteExifOptions) => Promise<void>Write EXIF metadata to an image file in place.
Only the provided tags are updated. All other tags remain unchanged. The pixel data is never re-encoded, so the image quality is not affected.
Only available on Android and iOS.
| Param | Type |
| ------------- | ------------------------------------------------------------- |
| options | WriteExifOptions |
Since: 0.1.0
Interfaces
ReadExifResult
| Prop | Type | Description | Since |
| ---------- | --------------------------------------------- | ------------------------------------------------- | ----- |
| tags | ExifTags | The EXIF tags that were read from the image file. | 0.1.0 |
ExifTags
The EXIF tags of an image file.
Every property is optional and only present if the tag exists in the file.
| Prop | Type | Description | Since |
| ---------------------- | -------------------- | ------------------------------------------------------------------------------------------------------------------ | ----- |
| dateTimeOriginal | string | The date and time when the image was originally captured in the EXIF date format YYYY:MM:DD HH:MM:SS. | 0.1.0 |
| exposureTime | number | The exposure time in seconds. | 0.1.0 |
| fNumber | number | The F number (aperture) of the lens. | 0.1.0 |
| flash | boolean | Whether or not the flash fired when the image was captured. | 0.1.0 |
| focalLength | number | The focal length of the lens in millimeters. | 0.1.0 |
| gpsAltitude | number | The altitude in meters above (positive) or below (negative) sea level. | 0.1.0 |
| gpsLatitude | number | The latitude in signed decimal degrees. Positive values are north of the equator, negative values are south. | 0.1.0 |
| gpsLongitude | number | The longitude in signed decimal degrees. Positive values are east of the prime meridian, negative values are west. | 0.1.0 |
| iso | number | The ISO speed rating (photographic sensitivity). | 0.1.0 |
| lensModel | string | The model of the lens. | 0.1.0 |
| make | string | The manufacturer of the camera. | 0.1.0 |
| model | string | The model of the camera. | 0.1.0 |
| orientation | number | The orientation of the image as defined by the EXIF specification (1-8). | 0.1.0 |
| pixelHeight | number | The height of the image in pixels. | 0.1.0 |
| pixelWidth | number | The width of the image in pixels. | 0.1.0 |
| software | string | The name of the software that was used to create or edit the image. | 0.1.0 |
ReadExifOptions
| Prop | Type | Description | Since |
| ---------- | ------------------- | ------------------------------------------------------------------------------------------------------------- | ----- |
| path | string | The path to the image file to read the EXIF metadata from. Local file paths and file:// URIs are supported. | 0.1.0 |
RemoveExifOptions
| Prop | Type | Description | Default | Since |
| --------------------- | -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------- | ----- |
| keepOrientation | boolean | Whether or not to keep the orientation tag when removing the EXIF metadata. This is enabled by default so that images are not suddenly displayed rotated after the metadata has been removed. | true | 0.1.0 |
| path | string | The path to the image file to remove the EXIF metadata from. Local file paths and file:// URIs are supported. | | 0.1.0 |
WriteExifOptions
| Prop | Type | Description | Since |
| ---------- | ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | ----- |
| path | string | The path to the image file to write the EXIF metadata to. Local file paths and file:// URIs are supported. | 0.1.0 |
| tags | WritableExifTags | The EXIF tags to write to the image file. Only the provided tags are updated. All other tags remain unchanged. | 0.1.0 |
WritableExifTags
The writable subset of the EXIF tags.
| Prop | Type | Description | Since |
| ---------------------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
| dateTimeOriginal | string | The date and time when the image was originally captured in the EXIF date format YYYY:MM:DD HH:MM:SS. | 0.1.0 |
| exposureTime | number | The exposure time in seconds. | 0.1.0 |
| fNumber | number | The F number (aperture) of the lens. | 0.1.0 |
| flash | boolean | Whether or not the flash fired when the image was captured. | 0.1.0 |
| focalLength | number | The focal length of the lens in millimeters. | 0.1.0 |
| gpsAltitude | number | The altitude in meters above (positive) or below (negative) sea level. | 0.1.0 |
| gpsLatitude | number | The latitude in signed decimal degrees. Positive values are north of the equator, negative values are south. Must be provided together with gpsLongitude. | 0.1.0 |
| gpsLongitude | number | The longitude in signed decimal degrees. Positive values are east of the prime meridian, negative values are west. Must be provided together with gpsLatitude. | 0.1.0 |
| iso | number | The ISO speed rating (photographic sensitivity). | 0.1.0 |
| lensModel | string | The model of the lens. | 0.1.0 |
| make | string | The manufacturer of the camera. | 0.1.0 |
| model | string | The model of the camera. | 0.1.0 |
| orientation | number | The orientation of the image as defined by the EXIF specification (1-8). | 0.1.0 |
| software | string | The name of the software that was used to create or edit the image. | 0.1.0 |
Format Support
The plugin can read EXIF metadata from any image format that the platform supports. Writing and removing EXIF metadata is a lossless in-place operation that is only supported for the following formats:
| Format | Read (Android) | Read (iOS) | Write & Remove (Android) | Write & Remove (iOS) | | --------- | -------------- | ---------- | ------------------------ | -------------------- | | JPEG | ✅ | ✅ | ✅ | ✅ | | PNG | ✅ | ✅ | ✅ | ❌ | | WebP | ✅ | ✅ | ✅ | ❌ | | HEIC/HEIF | ✅ | ✅ | ❌ | ✅ | | DNG/RAW | ✅ | ✅ | ❌ | ❌ |
Calling writeExif(...) or removeExif(...) with an unsupported format rejects with the UNSUPPORTED_FORMAT error code.
Lossless Metadata Writes
A metadata plugin that degrades the image quality is broken. This plugin therefore guarantees that the pixel data is never decoded or re-encoded:
- On Android, the
ExifInterfacelibrary rewrites only the metadata segments of the file in place. - On iOS, the
CGImageDestinationCopyImageSourceAPI copies the compressed image data unchanged and only replaces the metadata.
Privacy: Strip Metadata Before Upload
Images taken with a smartphone usually contain the exact GPS position, the device model, and the capture date. To protect the privacy of your users, remove this metadata before uploading images to a server:
import { Exif } from '@capawesome/capacitor-exif';
const prepareUpload = async (path: string) => {
// Remove the GPS position and all other EXIF metadata.
// The orientation is kept so that the image is not displayed rotated.
await Exif.removeExif({ path });
};Limitations
Android
- Vendor-specific maker notes and other unknown tags may survive
removeExif(...)since theExifInterfacelibrary can only remove known tags.
iOS
- HEIC files store the orientation at the container level, so the
orientationtag can not be changed and is always kept, even withkeepOrientationset tofalse. - HEIC files may keep the
softwareanddateTimeOriginaltags afterremoveExif(...). GPS data and device identity tags (make,model,lensModel) are always removed.
FAQ
How is this plugin different from other similar plugins?
It reads, writes and removes EXIF metadata directly on the image file on Android and iOS, updating tags in place so the pixel data is never re-encoded and the image quality is untouched. It reads and writes HEIC metadata natively, processes files natively without loading them into WebView memory, and uses only official platform APIs, so it stays App Store safe. The API is fully typed, ships for both CocoaPods and Swift Package Manager, and is kept current with the latest Capacitor version.
Which platforms are supported by this plugin?
The plugin supports Android and iOS. All methods (readExif, writeExif and removeExif) are only available on these two platforms, since the files are processed natively and never loaded into the WebView memory.
Does writing or removing EXIF metadata affect the image quality?
No. Writing and removing EXIF metadata is a lossless in-place operation. The pixel data is never decoded or re-encoded, so the image quality is not affected. See Lossless Metadata Writes for details on how this is implemented on each platform.
Which image formats are supported?
Reading EXIF metadata works with any image format that the platform supports, including JPEG, PNG, WebP, HEIC/HEIF, and DNG/RAW. Writing and removing metadata is only supported for certain formats, which differ between Android and iOS (see Format Support). Calling writeExif(...) or removeExif(...) with an unsupported format rejects with the UNSUPPORTED_FORMAT error code.
Why is the orientation tag still present after calling removeExif?
The keepOrientation option is enabled by default so that images are not suddenly displayed rotated after the metadata has been removed. You can set it to false to also remove the orientation tag. Note that HEIC files on iOS store the orientation at the container level, so it is always kept there.
How do I remove the GPS position from a photo before uploading it?
Call removeExif(...) with the path to the image file. This strips the GPS position along with all other EXIF metadata in place, without affecting the image quality. See Privacy: Strip Metadata Before Upload for an example.
Can I use this plugin with Ionic, React, Vue or Angular?
Yes, the plugin is framework-agnostic. It works in any Capacitor app regardless of the web framework, including Ionic with Angular, React, or Vue, as well as plain JavaScript projects.
Related Plugins
- File Compressor: Compress images in formats like PNG, JPEG, and WebP.
- File Picker: Pick the image files whose metadata you want to read or edit.
- Photo Editor: Let the user edit a photo.
- Photo Manipulator: Headless image transforms like crop, resize, rotate, and format conversion.
Newsletter
Stay up to date with the latest news and updates about the Capawesome, Capacitor, and Ionic ecosystem by subscribing to our Capawesome Newsletter.
Changelog
See CHANGELOG.md.
License
See LICENSE.
