Class DefaultImageMagickService

  • All Implemented Interfaces:
    ImageMagickService

    public class DefaultImageMagickService
    extends BasicImageMagickStrategy
    implements ImageMagickService
    Default implementation of a ImageMagickService backed by ImageMagick .

    Both ImageMagick executable (convert and identify in use will be executed by the auto injected ProcessExecutor.

    The behavior of this service can be influenced by the following properties: *
    Property Meaning Default
    imagemagick.bindir The binary directory of your local image magick installation.
    imagemagick.executable.convert The convert executable to call. convert
    imagemagick.executable.identify The identify executable to call. identify
    imagemagick.configuration.directory Path to the Configuration directory to use. Lookup sequence is as follows:
    1. If the configuration directory was set through spring injection, it will be used (the property value is disobeyed)
    2. If the property is set, this path will be used.
    3. If the JVM MAGICK_CONFIGURE_PATH environment variable is set, it will be used.
    4. The embedded configuration directory (see BasicImageMagickStrategy.EMBEDDED_CONFIG_DIR) will be used.
    Changes to this property are not reflected on runtime.

    Note: all environment variables relevant to ImageMagick will be forwarded to the executed process when set in the JVM environment.

    • Field Detail

      • EMBEDDED_BIN_DIR

        @Deprecated(since="6.1",
                    forRemoval=true)
        public static final java.lang.String EMBEDDED_BIN_DIR
        Deprecated, for removal: This API element is subject to removal in a future version.
        : since 6.1 ImageMagick in no longer embedded and has to be installed manually.
        Default root of the binary directory (embedded and shipped with this extension). Note that below this directory there is a os.name/os.arch structure for various platforms.
        See Also:
        Constant Field Values
      • IMAGEMAGICK_DIR

        public static final java.lang.String IMAGEMAGICK_DIR
        Property key for the binary directory to use (overrides build in mechanism).
        See Also:
        Constant Field Values
      • IMAGEMAGICK_EXECUTABLE_KEY_PREFIX

        public static final java.lang.String IMAGEMAGICK_EXECUTABLE_KEY_PREFIX
        Configuration key prefix for the executable name to use. Currently it is in use with two ImageMagick executable which are mapped/configuredf to the equal string:
        • imagemagick.executable.convert -> convert
        • imagemagick.executable.identify -> identify
        See Also:
        CONVERT_EXEC, IDENTIFY_EXEC, Constant Field Values
      • DYLD_LIBRARY_PATH

        public static final java.lang.String DYLD_LIBRARY_PATH
        See Also:
        Constant Field Values
      • DYLD_LIBRARY_PATH_ENV

        public static final java.lang.String DYLD_LIBRARY_PATH_ENV
        See Also:
        Constant Field Values
      • CONVERT_EXEC

        public static final java.lang.String CONVERT_EXEC
        Executable name to be used with the IMAGEMAGICK_EXECUTABLE_KEY_PREFIX conf key prefix. This property key is used to have an indirection if a different executable should be used.
        See Also:
        Constant Field Values
      • IDENTIFY_EXEC

        public static final java.lang.String IDENTIFY_EXEC
        Executable name to be used with the IMAGEMAGICK_EXECUTABLE_KEY_PREFIX conf key prefix. This property key is used to have an indirection if a different executable should be used.
        See Also:
        Constant Field Values
    • Constructor Detail

      • DefaultImageMagickService

        public DefaultImageMagickService()
    • Method Detail

      • buildEnvironment

        protected java.lang.String[] buildEnvironment​(java.io.File executable)
                                               throws java.io.IOException
        Assembling image magick environment.
        Parameters:
        executable - the executable to use
        Returns:
        environment setting as array of 'key=value' strings
        Throws:
        java.io.IOException
        See Also:
        Customize ImageMagick With Resources
      • convert

        public void convert​(java.util.List<java.lang.String> commandOpts)
                     throws java.io.IOException
        Description copied from interface: ImageMagickService
        Executes a conversion with the specified list of options. The options available are numerous and listed on the ImageMagick command line options page.
        Specified by:
        convert in interface ImageMagickService
        Parameters:
        commandOpts - the bold command line options (including input and output files if applicable).
        Throws:
        java.io.IOException - on any error
      • identify

        public java.lang.String identify​(java.util.List<java.lang.String> commandOptions)
                                  throws java.io.IOException
        Description copied from interface: ImageMagickService
        Executes image identification with the specified options. Please see ImageMagick Identify Command-line Tool for usage and option descriptions.
        Specified by:
        identify in interface ImageMagickService
        Parameters:
        commandOptions - bold command line options to the identify command (including the input file).
        Returns:
        the commands (std) output.
        Throws:
        java.io.IOException - on any error.
      • setProcessExecutor

        public void setProcessExecutor​(ProcessExecutor processExecutor)
      • setOsConfigurationService

        public void setOsConfigurationService​(OsConfigurationService osDirectoryService)