Class ImageMagickHelper
A utility class that is used as an interface to run 3rd-party tool ImageMagick.
public class ImageMagickHelper
- Inheritance
-
ImageMagickHelper
- Inherited Members
Remarks
A utility class that is used as an interface to run 3rd-party tool ImageMagick. ImageMagick among other things allows to compare images and this class provides means to utilize this feature.
The ImageMagick needs to be installed independently on the system. This class provides a convenient way to run it by passing a terminal command. The command can either be specified explicitly or by a mean of environment variable MAGICK_COMPARE_ENVIRONMENT_VARIABLE.Constructors
ImageMagickHelper()
Creates new instance that will rely on ImageMagick execution command defined by MAGICK_COMPARE_ENVIRONMENT_VARIABLE environment variable.
public ImageMagickHelper()
ImageMagickHelper(string)
Creates new instance that will rely on ImageMagick execution command defined as passed argument.
public ImageMagickHelper(string newCompareExec)
Parameters
newCompareExec
stringthe ImageMagick execution command; if null - environment variables will be used instead
Fields
MAGICK_COMPARE_ENVIRONMENT_VARIABLE
The name of the environment variable with the command to execute ImageMagic comparison operations.
public const string MAGICK_COMPARE_ENVIRONMENT_VARIABLE = "ITEXT_MAGICK_COMPARE_EXEC"
Field Value
Methods
GetCliExecutionCommand()
Returns a command that is used to run the utility.
public virtual string GetCliExecutionCommand()
Returns
- string
a string command
Remarks
Returns a command that is used to run the utility. This command doesn't contain command parameters. Parameters are added on specific methods invocation.
RunImageMagickImageCompare(string, string, string)
Runs imageMagick to visually compare images and generate difference output.
public virtual bool RunImageMagickImageCompare(string outImageFilePath, string cmpImageFilePath, string diffImageName)
Parameters
outImageFilePath
stringPath to the output image file
cmpImageFilePath
stringPath to the cmp image file
diffImageName
stringPath to the difference output image file
Returns
- bool
boolean result of comparing: true - images are visually equal
Remarks
Runs imageMagick to visually compare images and generate difference output.
Note, that this method may create temporary files.RunImageMagickImageCompare(string, string, string, string)
Runs imageMagick to visually compare images with the specified fuzziness value and generate difference output.
public virtual bool RunImageMagickImageCompare(string outImageFilePath, string cmpImageFilePath, string diffImageName, string fuzzValue)
Parameters
outImageFilePath
stringPath to the output image file
cmpImageFilePath
stringPath to the cmp image file
diffImageName
stringPath to the difference output image file
fuzzValue
stringString fuzziness value to compare images. Should be formatted as string with integer or decimal number. Can be null, if it is not required to use fuzziness
Returns
- bool
boolean result of comparing: true - images are visually equal
Remarks
Runs imageMagick to visually compare images with the specified fuzziness value and generate difference output.
Note, that this method may create temporary files.RunImageMagickImageCompareAndGetResult(string, string, string, string)
Runs imageMagick to visually compare images with the specified fuzziness value and generate difference output.
public virtual ImageMagickCompareResult RunImageMagickImageCompareAndGetResult(string outImageFilePath, string cmpImageFilePath, string diffImageName, string fuzzValue)
Parameters
outImageFilePath
stringPath to the output image file
cmpImageFilePath
stringPath to the cmp image file
diffImageName
stringPath to the difference output image file
fuzzValue
stringString fuzziness value to compare images. Should be formatted as string with integer or decimal number. Can be null, if it is not required to use fuzziness
Returns
- ImageMagickCompareResult
an object of ImageMagickCompareResult . containing comparing result information.
Remarks
Runs imageMagick to visually compare images with the specified fuzziness value and generate difference output. This method returns an object of ImageMagickCompareResult , containing comparing result information, such as boolean result value and the number of different pixels.
Note, that this method may create temporary files.RunImageMagickImageCompareWithThreshold(string, string, string, string, long)
Runs imageMagick to visually compare images with the specified fuzziness value and given threshold and generate difference output.
public virtual bool RunImageMagickImageCompareWithThreshold(string outImageFilePath, string cmpImageFilePath, string diffImageName, string fuzzValue, long threshold)
Parameters
outImageFilePath
stringPath to the output image file
cmpImageFilePath
stringPath to the cmp image file
diffImageName
stringPath to the difference output image file
fuzzValue
stringString fuzziness value to compare images. Should be formatted as string with integer or decimal number. Can be null, if it is not required to use fuzziness
threshold
longLong value of accepted threshold.
Returns
- bool
boolean result of comparing: true - images are visually equal
Remarks
Runs imageMagick to visually compare images with the specified fuzziness value and given threshold and generate difference output.
Note, that this method may create temporary files.