Class DefaultImageMagickDetector
java.lang.Object
com.broadleafcommerce.asset.service.support.DefaultImageMagickDetector
- All Implemented Interfaces:
ImageMagickDetector
Executes the ImageMagick 7
magick --version command, falling back to the ImageMagick 6
convert --version command, and examines the output to determine whether the ImageMagick
commandline utility is available on the current machine.- Author:
- Samarth Dhruva (samarthd)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanDetermines if the ImageMagick commandline utillity is available on the current machine.protected booleanindicatesImageMagickAvailable(Process magickVersionCommand) Determines whether the given--versionprocess indicates a working ImageMagick installation.protected Processprotected ProcessRuns the ImageMagick 7magick --versioncommand.
-
Constructor Details
-
DefaultImageMagickDetector
public DefaultImageMagickDetector()
-
-
Method Details
-
imageMagickAvailable
public boolean imageMagickAvailable()Description copied from interface:ImageMagickDetectorDetermines if the ImageMagick commandline utillity is available on the current machine.- Specified by:
imageMagickAvailablein interfaceImageMagickDetector- Returns:
- true if ImageMagick is available, false otherwise
-
indicatesImageMagickAvailable
protected boolean indicatesImageMagickAvailable(Process magickVersionCommand) throws InterruptedException Determines whether the given--versionprocess indicates a working ImageMagick installation.The error output is permitted to hold the IMv7 deprecation notice: ImageMagick 7's
convertshim reports its version on standard output but writes "WARNING: The convert command is deprecated in IMv7" to standard error, and that must not be mistaken for a broken installation.- Parameters:
magickVersionCommand- a started--versionprocess- Returns:
- true if the process output indicates ImageMagick is available, false otherwise
- Throws:
InterruptedException- if interrupted while waiting for the process to finish
-
runNativeMagickVersionCommand
Runs the ImageMagick 7magick --versioncommand. On a machine with only ImageMagick 6, the binary does not exist and this throwsIOException, in which case detection falls back torunMagickVersionCommand().- Returns:
- the started process
- Throws:
IOException- if themagickbinary could not be executed
-
runMagickVersionCommand
- Throws:
IOException
-