Skip to content

Instantly share code, notes, and snippets.

View rob-secondstage's full-sized avatar

Rob rob-secondstage

  • Second Stage Software
  • Portland, OR
  • X @coperob
View GitHub Profile
@rob-secondstage
rob-secondstage / LocationMetadata.swift
Created July 6, 2022 21:19
Adds GPS metadata to an existing image file without re-encoding or re-compressing the image. Swift, iOS.
import AVFoundation
import CoreLocation
import OSLog
private let logger = Logger(subsystem: "utilities", category: "images")
/// Adds the GPS metadata from `location` to the image file at `url` without re-encoding the image.
/// - Note: The image at `url` must be `JPG` or `HEIC` format. `HEIF` will not work.
/// - Warning: The file at `url` will be overwritten with a new file containing the updated metadata.
/// - Parameters: