An open API service indexing awesome lists of open source software.

https://github.com/dsoprea/go-exif-knife

Perform surgical operations on EXIF data at the command-line with JPG, PNG, HEIC, and TIFF files.
https://github.com/dsoprea/go-exif-knife

exif heic heif image-processing jpeg png

Last synced: 8 months ago
JSON representation

Perform surgical operations on EXIF data at the command-line with JPG, PNG, HEIC, and TIFF files.

Awesome Lists containing this project

README

          

[![Build Status](https://travis-ci.org/dsoprea/go-exif-knife.svg?branch=master)](https://travis-ci.org/dsoprea/go-exif-knife)
[![codecov](https://codecov.io/gh/dsoprea/go-exif-knife/branch/master/graph/badge.svg)](https://codecov.io/gh/dsoprea/go-exif-knife)
[![Go Report Card](https://goreportcard.com/badge/github.com/dsoprea/go-exif-knife)](https://goreportcard.com/report/github.com/dsoprea/go-exif-knife)
[![GoDoc](https://godoc.org/github.com/dsoprea/go-exif-knife?status.svg)](https://godoc.org/github.com/dsoprea/go-exif-knife)

## Overview

This is a command-line tool to perform a multitude of surgical operations on the EXIF data in any file that contains it.

This tool has been written on top of [go-exif](https://github.com/dsoprea/go-exif), a complete EXIF implementation.

## Image Support

**JPEG, PNG, HEIC, and TIFF (naturally, since EXIF takes the TIFF structure) are well supported.** A byte-by-byte search will be performed for all other types of file. Writes are only supported for JEPG and PNG.

```
$ ./go-exif-knife write --filepath image.png --set-tag=ifd0,Make,testing --output-filepath /tmp/updated.png

$ ./go-exif-knife read --filepath /tmp/updated.png
IFD: Ifd
- TAG: IfdTagEntry NAME=[Make] VALUE=[testing]
```

## Install

### Get

- Get via [Github Releases](https://github.com/dsoprea/go-exif-knife/releases)
- Get via go-get and build: "go get github.com/dsoprea/go-exif-knife"

### Install

1. Make the file executable ("chmod 755 [filename]")
2. Put the binary in your path.

## Usage

This tool is comprised of one tool with multiple subcommands. The root tool and the various subcommands provide complete command-line help.

## Examples

### Read

#### Print All Tags

Output (shortened for succinctness):

```
$ ./go-exif-knife read --filepath image.jpg
IFD: Ifd
- TAG: IfdTagEntry NAME=[Make] VALUE=[samsung]
- TAG: IfdTagEntry NAME=[Model] VALUE=[SM-N920T]
- TAG: IfdTagEntry NAME=[Orientation] VALUE=[[1]]
- TAG: IfdTagEntry NAME=[Software] VALUE=[GIMP 2.8.20]
- TAG: IfdTagEntry NAME=[DateTime] VALUE=[2018:06:09 01:07:30]
- TAG: IfdTagEntry NAME=[YCbCrPositioning] VALUE=[[1]]
- TAG: IfdTagEntry
IFD: Ifd
- TAG: IfdTagEntry NAME=[ExposureTime] VALUE=[[{1 13}]]
- TAG: IfdTagEntry NAME=[FNumber] VALUE=[[{19 10}]]
- TAG: IfdTagEntry NAME=[ExposureProgram] VALUE=[[2]]
- TAG: IfdTagEntry NAME=[Flash] VALUE=[[0]]
- TAG: IfdTagEntry NAME=[FocalLength] VALUE=[[{430 100}]]
- TAG: IfdTagEntry NAME=[UserComment] VALUE=[UserComment]
- TAG: IfdTagEntry NAME=[FlashpixVersion] VALUE=[0100]
- TAG: IfdTagEntry NAME=[ColorSpace] VALUE=[[1]]
- TAG: IfdTagEntry NAME=[PixelXDimension] VALUE=[[920]]
- TAG: IfdTagEntry NAME=[PixelYDimension] VALUE=[[570]]
- TAG: IfdTagEntry
IFD: Ifd
- TAG: IfdTagEntry NAME=[InteroperabilityIndex] VALUE=[R98]
- TAG: IfdTagEntry NAME=[InteroperabilityVersion] VALUE=[0100]
- TAG: IfdTagEntry
IFD: Ifd
- TAG: IfdTagEntry NAME=[GPSVersionID] VALUE=[[2 2 0 0]]
- TAG: IfdTagEntry NAME=[GPSLatitudeRef] VALUE=[N]
- TAG: IfdTagEntry NAME=[GPSLatitude] VALUE=[[{26 1} {35 1} {12 1}]]
- TAG: IfdTagEntry NAME=[GPSAltitude] VALUE=[[{0 1}]]
- TAG: IfdTagEntry NAME=[GPSTimeStamp] VALUE=[[{1 1} {22 1} {57 1}]]
- TAG: IfdTagEntry NAME=[GPSDateStamp] VALUE=[2018:04:29]
>IFD: Ifd
- TAG: IfdTagEntry NAME=[Compression] VALUE=[[6]]
- TAG: IfdTagEntry NAME=[XResolution] VALUE=[[{72 1}]]
- TAG: IfdTagEntry NAME=[YResolution] VALUE=[[{72 1}]]
- TAG: IfdTagEntry NAME=[ResolutionUnit] VALUE=[[2]]
```

#### Print Specific Tags in All IFDs Using Name

```
$ ./go-exif-knife read --filepath image.jpg --tag Model
Model: SM-N920T
```

"--tag" can be provided multiple times.

#### Print Tag With Name and IFD

```
$ ./go-exif-knife read --filepath "assets/image.jpg" --tag Model --ifd ifd0
Model: Canon EOS 5D Mark III
```

"--tag" can be provided multiple times.

#### Print All Tags in IFD

```
$ ./go-exif-knife read --filepath image.jpg --ifd gps
IFD: Ifd
- TAG: IfdTagEntry NAME=[GPSVersionID] VALUE=[[2 2 0 0]]
- TAG: IfdTagEntry NAME=[GPSLatitudeRef] VALUE=[N]
- TAG: IfdTagEntry NAME=[GPSLatitude] VALUE=[[{26 1} {35 1} {12 1}]]
- TAG: IfdTagEntry NAME=[GPSLongitudeRef] VALUE=[W]
- TAG: IfdTagEntry NAME=[GPSLongitude] VALUE=[[{80 1} {3 1} {13 1}]]
- TAG: IfdTagEntry NAME=[GPSAltitudeRef] VALUE=[[1]]
- TAG: IfdTagEntry NAME=[GPSAltitude] VALUE=[[{0 1}]]
- TAG: IfdTagEntry NAME=[GPSTimeStamp] VALUE=[[{1 1} {22 1} {57 1}]]
- TAG: IfdTagEntry NAME=[GPSDateStamp] VALUE=[2018:04:29]
```

#### Print as JSON

```
$ ./go-exif-knife read --filepath image.jpg --ifd gps --json
{
"gpsinfo": {
"GPSAltitude": [
{
"Numerator": 0,
"Denominator": 1
}
],
"GPSAltitudeRef": "AQ==",
"GPSDateStamp": "2018:04:29",
"GPSLatitude": [
{
"Numerator": 26,
"Denominator": 1
},
{
"Numerator": 35,
"Denominator": 1
},
{
"Numerator": 12,
"Denominator": 1
}
],
"GPSLatitudeRef": "N",
"GPSLongitude": [
{
"Numerator": 80,
"Denominator": 1
},
{
"Numerator": 3,
"Denominator": 1
},
{
"Numerator": 13,
"Denominator": 1
}
],
"GPSLongitudeRef": "W",
"GPSTimeStamp": [
{
"Numerator": 1,
"Denominator": 1
},
{
"Numerator": 22,
"Denominator": 1
},
{
"Numerator": 57,
"Denominator": 1
}
],
"GPSVersionID": "AgIAAA=="
}
}
```

#### Just Print Value(s)

```
$ ./go-exif-knife read --filepath image.jpg --tag Model --just-values
SM-N920T
```

"--tag" can be provided multiple times.

### GPS

```
$ ./go-exif-knife gps --filepath image.jpg
GpsInfo
```

```
$ ./go-exif-knife gps --filepath image.jpg --json
{
"Altitude": 0,
"LatitudeDecimal": 26.586666666666666,
"LongitudeDecimal": -80.05361111111111,
"Timestamp": "2018-04-29T01:22:57Z",
"TimestampUnix": 1524964977
}
```

Include a geohash calculated with the Google S2 (Hilbert Curve) algorithm:

```
$ ./go-exif-knife gps --filepath image.jpg --json --google-s2
{
"Altitude": 0,
"LatitudeDecimal": 26.586666666666666,
"LongitudeDecimal": -80.05361111111111,
"S2LocationId": 6542766593732284747,
"Timestamp": "2018-04-29T01:22:57Z",
"TimestampUnix": 1524964977
}
```

### Thumbnail

```
$ ./go-exif-knife thumbnail --filepath image.jpg --output-filepath /tmp/thumbnail.jpg
```

### Write

```
$ ./go-exif-knife read --filepath image.jpg --tag Make
Make: samsung

$ ./go-exif-knife write --filepath image.jpg --set-tag=ifd0,Make,testing --output-filepath /tmp/updated.jpg

$ ./go-exif-knife read --filepath /tmp/updated.jpg --tag Make
Make: testing
```