Class DefaultImageMagickDetector

java.lang.Object
com.broadleafcommerce.asset.service.support.DefaultImageMagickDetector
All Implemented Interfaces:
ImageMagickDetector

public class DefaultImageMagickDetector extends Object implements 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 Details

    • DefaultImageMagickDetector

      public DefaultImageMagickDetector()
  • Method Details

    • imageMagickAvailable

      public boolean imageMagickAvailable()
      Description copied from interface: ImageMagickDetector
      Determines if the ImageMagick commandline utillity is available on the current machine.
      Specified by:
      imageMagickAvailable in interface ImageMagickDetector
      Returns:
      true if ImageMagick is available, false otherwise
    • indicatesImageMagickAvailable

      protected boolean indicatesImageMagickAvailable(Process magickVersionCommand) throws InterruptedException
      Determines whether the given --version process indicates a working ImageMagick installation.

      The error output is permitted to hold the IMv7 deprecation notice: ImageMagick 7's convert shim 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 --version process
      Returns:
      true if the process output indicates ImageMagick is available, false otherwise
      Throws:
      InterruptedException - if interrupted while waiting for the process to finish
    • runNativeMagickVersionCommand

      protected Process runNativeMagickVersionCommand() throws IOException
      Runs the ImageMagick 7 magick --version command. On a machine with only ImageMagick 6, the binary does not exist and this throws IOException, in which case detection falls back to runMagickVersionCommand().
      Returns:
      the started process
      Throws:
      IOException - if the magick binary could not be executed
    • runMagickVersionCommand

      protected Process runMagickVersionCommand() throws IOException
      Throws:
      IOException