Skip to content

yashikota/exiftool-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

exiftool-go

Pure Go ExifTool wrapper powered by WebAssembly.

Uses zeroperl (Perl compiled to WebAssembly) and wazero (pure Go WebAssembly runtime) to provide ExifTool functionality without any external dependencies.

exiftool-go

Features

  • Pure Go: No CGO required, easy cross-compilation
  • Single Binary: WebAssembly module is embedded, distributable as a single binary
  • Full ExifTool: Uses the real ExifTool (v13.42), supporting all metadata formats (EXIF, IPTC, XMP, ICC, etc.)
  • No External Dependencies: No need to install Perl or ExifTool on the system

CLI Usage

Download binary from Releases

or

go install github.com/yashikota/exiftool-go@latest
# Read metadata
exiftool-go photo.jpg

# JSON output
exiftool-go -json photo.jpg

# Multiple files
exiftool-go photo1.jpg photo2.jpg

Library Usage

go get github.com/yashikota/exiftool-go
package main

import (
    "fmt"
    "log"

    "github.com/yashikota/exiftool-go/pkg/exiftool"
)

func main() {
    // Create ExifTool instance
    et, err := exiftool.New()
    if err != nil {
        log.Fatal(err)
    }
    defer et.Close()

    // Read metadata from image
    metadata, err := et.ReadMetadata("photo.jpg")
    if err != nil {
        log.Fatal(err)
    }

    // Print metadata
    for key, value := range metadata {
        fmt.Printf("%s: %v\n", key, value)
    }
}

API

  • New() (*ExifTool, error)

    Creates a new ExifTool instance. Call Close when done.

  • NewWithContext(ctx context.Context) (*ExifTool, error)

    Creates a new ExifTool instance with the given context.

  • (*ExifTool) Close() error

    Releases all resources associated with the ExifTool instance.

  • (*ExifTool) Version() (string, error)

    Returns the ExifTool version string.

  • (*ExifTool) ReadMetadata(filePath string) (map[string]any, error)

    Reads metadata from an image file and returns it as a map.

  • (*ExifTool) WriteMetadata(srcPath string, dstPath string, tags map[string]any) error

    Writes multiple tags to an image file. If dstPath is empty, the source file is modified in place.

  • (*ExifTool) SetTag(srcPath string, dstPath string, tag string, value string) error

    Writes a single tag to an image file. If dstPath is empty, the source file is modified in place.

How It Works

  1. zeroperl: Compiles Perl 5 interpreter to WebAssembly with WASI support
  2. wazero: Provides a pure Go WebAssembly runtime
  3. ExifTool: Perl module (Image::ExifTool) is bundled in zeroperl's WebAssembly binary
  4. This library: Wraps everything in a clean Go API

Credits

About

Pure Go ExifTool wrapper powered by WebAssembly

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages