Skip to content

junian/SharpExifTool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SharpExifTool Logo

SharpExifTool

C# Wrapper for ExifTool by Phil Harvey. Available for Windows, macOS, and Linux.

SharpExifTool on GitHub SharpExifTool latest version on NuGet SharpExifTool total downloads on NuGet


Installation

Get SharpExifTool from NuGet.

dotnet add package SharpExifTool

Usage

Init

You can create an exiftool instance by using the built-in exiftool binary.

using(var exiftool = new SharpExifTool.ExifTool())
{
 // Do something here
}

Read All EXIF / Metadata Tags

using(var exiftool = new SharpExifTool.ExifTool())
{
    await exiftool.ExtractAllMetadataAsync(filename: "image.jpg");
}

Write EXIF / Metadata Tags

using(var exiftool = new SharpExifTool.ExifTool())
{
    await exiftool.WriteTagsAsync(
        filename: "image.jpg", 
        properties: new Dictionary<string, string>
        {
            ["artist"] = ["Phil Harvey"],    
        });
}

Remove All Safe EXIF / Metadata Tags

using(var exiftool = new SharpExifTool.ExifTool())
{
    await exiftool.RemoveAllMetadataAsync(filename: "image.jpg");
}

Custom Command

For example, you want to execute the following in the command line:

exiftool -artist="Phil Harvey" -copyright="2011 Phil Harvey" a.jpg

You can do it like this in C#:

using(var exiftool = new SharpExifTool.ExifTool())
{
    await exiftool.ExecuteAsync(
        "-artist=\"Phil Harvey\"", 
        "-copyright=\"2011 Phil Harvey\"", 
        "a.jpg");
}

Development

Before starting development, install 3rd party dependencies by executing getlibs.sh (it'll only work on macOS or Unix operating system, no Windows script for now).

$ ./getlibs.sh

This will download and extract files based on .gitbinmodules content and place them under the libs directory.

To use a different version of exiftool, you can edit the .gitbinmodules file and change it with your desired version.

You can also download from official website and extract the files manually. Put them in the libs directory so it'll look something like this:

.
├── docs
│   └── README.md
├── libs
│   ├── ExifTool.Unix
│   │   ├── Makefile.PL
│   │   ├── arg_files
│   │   ├── build_geolocation
│   │   ├── config_files
│   │   ├── exiftool
│   │   ├── fmt_files
│   │   ├── lib
│   │   ├── perl-Image-ExifTool.spec
│   │   └── t
│   └── ExifTool.Win
│       └── exiftool.exe
└── src

Credits

License

This project is licensed under MIT License.


Made with ☕ by Junian.dev.