C# Wrapper for ExifTool by Phil Harvey. Available for Windows, macOS, and Linux.
Get SharpExifTool from NuGet.
dotnet add package SharpExifTool
You can create an exiftool instance by using the built-in exiftool
binary.
using(var exiftool = new SharpExifTool.ExifTool())
{
// Do something here
}
using(var exiftool = new SharpExifTool.ExifTool())
{
await exiftool.ExtractAllMetadataAsync(filename: "image.jpg");
}
using(var exiftool = new SharpExifTool.ExifTool())
{
await exiftool.WriteTagsAsync(
filename: "image.jpg",
properties: new Dictionary<string, string>
{
["artist"] = ["Phil Harvey"],
});
}
using(var exiftool = new SharpExifTool.ExifTool())
{
await exiftool.RemoveAllMetadataAsync(filename: "image.jpg");
}
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");
}
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
- ExifTool by Phil Harvey.
- FileMeta/ExifToolWrapper: CodeBit: C# Wrapper for Phil Harvey's ExifTool
This project is licensed under MIT License.
Made with ☕ by Junian.dev.