Skip to content

Strip GPS/EXIF metadata when sharing photos (opt-in setting)#1048

Open
dsremo wants to merge 1 commit into
FossifyOrg:mainfrom
dsremo:dsremo/strip-metadata-on-share
Open

Strip GPS/EXIF metadata when sharing photos (opt-in setting)#1048
dsremo wants to merge 1 commit into
FossifyOrg:mainfrom
dsremo:dsremo/strip-metadata-on-share

Conversation

@dsremo
Copy link
Copy Markdown

@dsremo dsremo commented May 13, 2026

Problem

Photos taken on modern devices embed location, timestamp, camera make/model/serial, and software signature in their EXIF block. When a user shares a photo from Fossify Gallery — through a messaging app, email, or any share-sheet target — all of that metadata travels with the file unless they explicitly strip it first. Most users don't, because the tooling is fiddly and they don't know the data is there.

Fix

Adds an opt-in toggle under Settings: "Strip GPS/EXIF metadata when sharing photos".

When enabled, shareMediumPath() and shareMediaPaths() route through MetadataStripper.stripToCacheCopy(), which:

  1. Copies the source file to cacheDir/metadata-stripped/<timestamp>-<original> so the on-disk original is untouched.
  2. Opens the copy with androidx.exifinterface.media.ExifInterface and blanks out the sensitive tag set.
  3. Returns the stripped copy's path to the share intent.

Tags stripped (47 total)

  • All GPS sub-fields: latitude, longitude, altitude, timestamp, datestamp, processing method, area info, dest bearing/distance/lat/long, image direction, speed, track.
  • All timestamp variants: DATETIME, DATETIME_ORIGINAL, DATETIME_DIGITIZED, OFFSET_TIME, OFFSET_TIME_ORIGINAL, OFFSET_TIME_DIGITIZED.
  • Device identification: MAKE, MODEL, SOFTWARE, BODY_SERIAL_NUMBER, LENS_SERIAL_NUMBER, CAMERA_OWNER_NAME.
  • Author / content metadata: ARTIST, COPYRIGHT, USER_COMMENT, IMAGE_DESCRIPTION, SUBJECT_LOCATION, SUBJECT_AREA.

Tags preserved

ORIENTATION, image width/height, color space, ICC profile, focal length, aperture, ISO, exposure, white balance — the things that affect how the image renders but don't identify the user, device, or location.

Supported file formats

JPEG, HEIC/HEIF, WebP, TIFF, PNG, DNG. Other formats (video, RAW) pass through unchanged.

Files touched

  • app/src/main/kotlin/org/fossify/gallery/helpers/MetadataStripper.kt (new, 78 lines)
  • app/src/main/kotlin/org/fossify/gallery/helpers/Config.kt (+5)
  • app/src/main/kotlin/org/fossify/gallery/helpers/Constants.kt (+1)
  • app/src/main/kotlin/org/fossify/gallery/activities/SettingsActivity.kt (+9)
  • app/src/main/kotlin/org/fossify/gallery/extensions/Activity.kt (+18 / −2)
  • app/src/main/res/layout/activity_settings.xml (+15)
  • app/src/main/res/values/strings.xml (+1)

Default behavior

Off. Existing users see no change unless they enable the toggle.

Tested

Built and installed on Android 16. Toggled on → shared a photo with GPS metadata to a file-manager → verified received file has no GPS tags via exiftool. Toggled off → original metadata preserved as before.

Photos taken on modern devices embed location, timestamp, camera serial,
and software signature in EXIF. When users share a photo from Gallery
through any share-sheet target (messaging app, email, web upload), all
of that metadata travels with the file unless they explicitly strip it
first - which most users don't, because the toolchain is fiddly and
nobody knows it's there.

This adds an opt-in toggle 'Strip GPS/EXIF metadata when sharing photos'
under Settings. When enabled, shareMediumPath() and shareMediaPaths()
copy the file to the app cache directory, blank out a comprehensive list
of sensitive EXIF tags (47 tags covering all GPS sub-fields, all timestamp
variants, camera Make/Model/Software/Serial, Artist, Copyright,
UserComment, Subject*Location, BodySerialNumber, LensSerialNumber,
CameraOwnerName), and pass the stripped copy to the share intent. The
original file on disk is untouched.

Tags preserved: orientation, image dimensions, color space, ICC profile,
focal length, aperture, ISO, exposure - the things that affect rendering
but don't identify the user, device, or location.

Supported formats: JPEG, HEIC/HEIF, WebP, TIFF, PNG, DNG. Other formats
(video, RAW) pass through unchanged.

Default: off (no behaviour change for existing users).
@dsremo dsremo requested a review from naveensingh as a code owner May 13, 2026 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant