Image metadata library and tools
Exiv2 is a C++ library and a command-line utility to read, write, delete and modify Exif, IPTC, XMP and ICC image metadata.
| Exiv2 Resource | Location |
|---|---|
| Releases and Documentation | |
| Prereleases: | |
| Project Resources | |
| License (GPLv2) | |
| CMake Downloads | https://exiv2.org |
| https://pre-release.exiv2.org | |
| https://github.com/Exiv2/exiv2 | |
| COPYING | |
| https://cmake.org/download/ | |
| README.md | |
| README-CONAN.md | |
| README-SAMPLES.md | User Manual. This document |
| Conan User Manual click here | |
| Sample Code Manual. click here |
The file ReadMe.txt in a build bundle describes how to install the library on the platform. ReadMe.txt also documents how to compile and link code on the platform.
You need CMake to configure the Exiv2 project, any C++ compiler implementing the C++ 20 standard and the associated tool chain.
$ cd ~/gnu/github/exiv2 # Location of the project code
$ cmake -S . -B build -DCMAKE_BUILD_TYPE=Release # Configure the project with CMake
$ cmake --build build # Compile the project
$ ctest --test-dir build --verbose # Run tests
$ sudo cmake --install build # Run the install target (install library, public headers, application and CMake files)
This will install the library into the "standard locations". The library will be installed in /usr/local/lib, executables (including the exiv2 command-line program) in /usr/local/bin/ and header files in /usr/local/include/exiv2. The target directory for the installation can be modified by using the CMake option -DCMAKE_INSTALL_PREFIX.
CMake analyzes the project configuration from the source code directory and generates files into the build directory. It generates the project/solution/makefiles required to build the exiv2 library and command line application (and optionally sample applications and test runners). CMake also creates the files exv_conf.h and exiv2lib_export.h which contain compiler directives about the build options you have chosen and the availability of libraries on your machine.
To execute the exiv2 command line program, you should update your path to search /usr/local/bin/
$ export PATH="/usr/local/bin:$PATH"
You will also need to locate libexiv2 at run time:
$ export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH" # Linux, Cygwin, MinGW/msys2
$ export DYLD_LIBRARY_PATH="/usr/local/lib:$DYLD_LIBRARY_PATH" # macOS
I don't know why anybody would uninstall Exiv2.
$ cd ~/gnu/github/exiv2 # location of the project code
$ cmake --build build --target uninstall
These commands will run the uninstall target and remove all the files which were installed by the install target.
Note that this mechanism is not perfect and it is not able to remove the sub-directories created in the installation
path.
We recommend to use conan to download the Exiv2 external dependencies on Windows. On other platforms (macOS, Linux and others), traditionally the platform package managers have been used. However, conan can be used in any platform/architecture to bring the project dependencies. These are discussed at Platform Notes. The options to configure and compile the project using Visual Studio are similar to UNIX like systems. See README-CONAN for more information about Conan.
When you build, you may install with the following command.
> cmake --install build
This will create and copy the exiv2 build artefacts to %ProgramFiles%/exiv2. To be able to run the exiv2 command line application from any terminal you should modify your path to include %ProgramFiles%/exiv2/bin.
CMake presets (see documentation here) were added recently to the project to ease the CMake configuration process for typical configurations. The presets are defined in the file CMakePresets.json and they can be used from the terminal or interpreted by different IDEs. Please note that one needs to use a recent version of CMake (>= 3.21) supporting the presets feature.
One can list the available presets using the --list-presets option:
# Running the command from a Windows terminal
$ cmake --list-presets
Available configure presets:
"msvc" - Visual Studio cl toolchain (also usable from VS Code)
"win-debug" - Windows Debug with configured architecture
"win-release" - Windows Release with configured architecture
# Running the command from a Linux terminal
$ cmake --list-presets
Available configure presets:
"linux-debug" - Linux Debug with default architecture
"linux-release" - Linux Release with default architecture
The project configuration with a specific preset can be chosen with the CMake --preset option. For example:
$ cmake --preset linux-release
Note that the usage of CMake presets allow the project contributors to use the same set of options easily in different environments (using terminal, IDEs or CI).
There are two groups of CMake options which are relevant to the project: global CMake options and project specific ones. Here are some of the global options which are particularly useful:
| Options | Purpose (default) |
|---|---|
| CMAKE_INSTALL_PREFIX | |
| CMAKE_BUILD_TYPE | |
| BUILD_SHARED_LIBS | Where to install on your computer (/usr/local) |
| Type of build (Release) See: Debugging Exiv2 | |
| Build exiv2lib as SHARED or STATIC |
Options defined at exiv2/CMakeLists.txt include:
…
Using the command-line, these variables can be set/updated using the option -D:
$ cmake -DBUILD_SHARED_LIBS=ON -DEXIV2_ENABLE_NLS=OFF
The following Exiv2 features require external libraries:
| Feature | Package | Default | To change default | Availability |
|---|---|---|---|---|
| PNG image support | zlib | ON | -DEXIV2_ENABLE_PNG=OFF | https://zlib.net/ |
| XMP support | expat | ON | -DEXIV2_ENABLE_XMP=OFF | https://libexpat.github.io/ |
| Use Expat 2.2.6 and later | ||||
| Natural language system | gettext | OFF | -DEXIV2_ENABLE_NLS=ON | https://www.gnu.org/software/gettext/ |
| JPEG XL brob support | brotli | ON | -DEXIV2_ENABLE_BROTLI=OFF | https://github.com/google/brotli |
| Character set conversion | libiconv | Disabled for Visual Studio. | ||
| Linked when installed on UNIX like platforms. | https://www.gnu.org/software/libiconv/ |
On UNIX systems, you may install the dependencies using the distribution's package management system. Install the
development package of a dependency to install the header files and libraries required to build Exiv2. The script
ci/install_dependencies.sh is used to setup the CI images on which we build and test Exiv2. You may find that helpful in setting up your platform dependencies.
Natural language system is discussed in more detail here: Localisation
Notes about different platforms are included here: Platform Notes
You may choose to install dependences with conan. This is supported on all platforms and is especially useful for users of Visual Studio. See README-CONAN for more information.
The library libiconv is used to perform character set encoding in the tags Exif.Photo.UserComment, Exif.GPSInfo.GPSProcessingMethod and Exif.GPSInfo.GPSAreaInformation. This is documented in the exiv2 man page.
CMake will detect libiconv of all UNIX like systems including Linux, macOS, UNIX, Cygwin64 and MinGW/msys2. If you have installed libiconv on your machine, Exiv2 will link and use it.
The library libiconv is a GNU library and we do not recommend using libiconv with Exiv2 when building with Visual Studio.
There are detailed platform notes about compiling and linking in releasenotes/{platform}/ReadMe.txt
where platform: { CYGWIN | Darwin | Linux | MinGW | msvc | Unix }
In general you need to do the following:
#include
Compile your C++ code with the directive: -I/usr/local/include
Link your code with libexiv2 using the linker options: -lexiv2 and -L/usr/local/lib
The following is a typical command to build and link with libexiv2:
$ g++ -std=c++20 myprog.cpp -o myprog -I/usr/local/include -L/usr/local/lib -lexiv2
When exiv2 is installed, the files required to consume Exiv2 with CMake are installed in ${CMAKE_INSTALL_PREFIX}/lib/cmake/exiv2
You can build samples/exifprint.cpp as follows:
$ cd
$ mkdir exifprint
$ cd exifprint
$ cat - > CMakeLists.txt
## Using pkg-config to compile and link your code with Exiv2
When exiv2 is installed, the file exiv2.pc used by pkg-config is installed in `${CMAKE_INSTALL_PREFIX}/lib/pkgconfig` You will need to set the following in your environment:
```bash
$ export PKG_CONFIG_PATH="/usr/local/lib/
No open issues yet, or sync has not completed.