Package com.thebuzzmedia.exiftool
Class ExifToolBuilder
java.lang.Object
com.thebuzzmedia.exiftool.ExifToolBuilder
Builder for
ExifTool
instance.
This builder should be used to create instance of ExifTool
.
Settings
Path
Set the absolute withPath to the ExifTool executable on the host system running this class as defined by the `exiftool.withPath` system property. If set, value will be used, otherwise, withPath will be read:-
From system property. This system property can be set on startup
with
-Dexiftool.withPath=/withPath/to/exiftool
or by callingSystem.setProperty(String, String)
before this class is loaded. -
Default value is
exiftool
. In this case,exiftool
command must be globally available.
exiftool
successfully executes it, leaving this value unchanged will work fine on
any platform. If the ExifTool executable is named something else or not
in the system withPath, then this property will need to be set to point at it
before using this class.
On Windows be sure to double-escape the withPath to the tool,
for example: -Dexiftool.withPath=C:\\Tools\\exiftool.exe
.
Default value is exiftool
.
Relative withPath values (e.g. bin/tools/exiftool
) are executed with
relation to the base directory the VM process was started in. Essentially
the directory that new File(".").getAbsolutePath()
points at
during runtime.
Executor
Executor is the component responsible for executing command line on the system. Most of the time, the default should be fine, but if you want to tune the used withExecutor, then this property is for you. Custom withExecutor must implementCommandExecutor
interface.
Stay Open Strategy
ExifTool 8.36 added a new persistent-process feature that allows ExifTool to stay running in a daemon mode and continue accepting commands via a file or stdin. This feature is disabled by default. NOTE: Ifstay_open
flag is enabled, then an
instance of UnsupportedFeatureException
may be thrown during ExifTool creation.
If this exception occurs, then you should probably:
- Update your ExifTool version.
- Create new ExifTool without this feature.
final ExifTool exifTool;
try {
exifTool = new ExifToolBuilder()
.enableStayOpen()
.build();
}
catch (UnsupportedFeatureException ex) {
exifTool = new ExifToolBuilder().build();
}
Custom Strategies
If default strategies are not enough, you can easily provide your own using thewithStrategy(com.thebuzzmedia.exiftool.ExecutionStrategy)
method.
Usage:
ExifTool exifTool = new ExifToolBuilder()
.withStrategy(new MyCustomStrategy())
.build();
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Create exiftool instance with previous settings.Enablestay_open
feature.enableStayOpen
(long cleanupDelay) Enablestay_open
feature.enableStayOpen
(Scheduler scheduler) Enablestay_open
feature and perform cleanup task using givenscheduler
.withExecutor
(CommandExecutor executor) Override default exifTool executor.Override default path.Override default path.withPoolSize
(int poolSize) Override default execution strategy: a pool ofStayOpenStrategy
with a size ofpoolSize
will be used. No cleanup scheduler will be used (usewithPoolSize(int, long)
instead.withPoolSize
(int poolSize, long cleanupDelay) Override default execution strategy: a pool ofStayOpenStrategy
with a size ofpoolSize
will be used. Default scheduler instances will be used with a delay ofcleanupDelay
.withStrategy
(ExecutionStrategy strategy) Override default execution strategy.
-
Constructor Details
-
ExifToolBuilder
public ExifToolBuilder()Create builder with default settings.
-
-
Method Details
-
withPath
Override default path. Default path is defined by the environment propertyexiftool.path
or is set withexiftool
otherwise. Setting the path explicitly will disable automatic lookup.- Parameters:
path
- New path.- Returns:
- Current builder.
-
withPath
Override default path. Default path is defined by the environment propertyexiftool.path
or is set withexiftool
otherwise. Setting the path explicitly will disable automatic lookup.
Note: If path is not an executable file, a warning will be logged but it will not fail.- Parameters:
path
- New path.- Returns:
- Current builder.
-
withExecutor
Override default exifTool executor.- Parameters:
executor
- New withExecutor.- Returns:
- Current builder.
-
enableStayOpen
Enablestay_open
feature.- Returns:
- Current builder.
-
enableStayOpen
Enablestay_open
feature. Note:- If {link #withStrategy} is called, then calling this method is useless.
- If {link #enableStayOpen(scheduler} is called, then calling this method is useless.
- Parameters:
cleanupDelay
- Interval (in milliseconds) between automatic clean operation.- Returns:
- Current builder.
-
enableStayOpen
Enablestay_open
feature and perform cleanup task using givenscheduler
. Note:- If
withStrategy(com.thebuzzmedia.exiftool.ExecutionStrategy)
has already been called, then calling is useless. -
If
enableStayOpen(long)
has already been called, then givendelay
will be ignored and the specified scheduler will be used.
- Parameters:
scheduler
- Scheduler used to process automatic cleanup task..- Returns:
- Current builder.
- If
-
withStrategy
Override default execution strategy. IfenableStayOpen()
has been called, then strategy associated withstay_open
flag will be ignored.- Parameters:
strategy
- Strategy.- Returns:
- Current builder.
-
withPoolSize
Override default execution strategy:- a pool of
StayOpenStrategy
with a size ofpoolSize
will be used. - Default scheduler instances will be used with a delay of
cleanupDelay
.
- Parameters:
poolSize
- Pool size.cleanupDelay
- Cleanup delay for each scheduler of pool elements.- Returns:
- Current builder.
- a pool of
-
withPoolSize
Override default execution strategy:- a pool of
StayOpenStrategy
with a size ofpoolSize
will be used. - No cleanup scheduler will be used (use
withPoolSize(int, long)
instead.
- Parameters:
poolSize
- Pool size.- Returns:
- Current builder.
- a pool of
-
build
Create exiftool instance with previous settings.- Returns:
- Exiftool instance.
-