iText 8.0.2 API
iText.IO.Util.ImageMagickHelper Class Reference

A utility class that is used as an interface to run 3rd-party tool ImageMagick. More...

Public Member Functions

  ImageMagickHelper ()
  Creates new instance that will rely on ImageMagick execution command defined by MAGICK_COMPARE_ENVIRONMENT_VARIABLE environment variable. More...
 
  ImageMagickHelper (String newCompareExec)
  Creates new instance that will rely on ImageMagick execution command defined as passed argument. More...
 
virtual String  GetCliExecutionCommand ()
  Returns a command that is used to run the utility. More...
 
virtual bool  RunImageMagickImageCompare (String outImageFilePath, String cmpImageFilePath, String diffImageName)
  Runs imageMagick to visually compare images and generate difference output. More...
 
virtual bool  RunImageMagickImageCompare (String outImageFilePath, String cmpImageFilePath, String diffImageName, String fuzzValue)
  Runs imageMagick to visually compare images with the specified fuzziness value and generate difference output. More...
 
virtual bool  RunImageMagickImageCompareWithThreshold (String outImageFilePath, String cmpImageFilePath, String diffImageName, String fuzzValue, long threshold)
  Runs imageMagick to visually compare images with the specified fuzziness value and given threshold and generate difference output. More...
 
virtual ImageMagickCompareResult  RunImageMagickImageCompareAndGetResult (String outImageFilePath, String cmpImageFilePath, String diffImageName, String fuzzValue)
  Runs imageMagick to visually compare images with the specified fuzziness value and generate difference output. More...
 

Static Public Attributes

const String  MAGICK_COMPARE_ENVIRONMENT_VARIABLE = "ITEXT_MAGICK_COMPARE_EXEC"
  The name of the environment variable with the command to execute ImageMagic comparison operations. More...
 

Detailed Description

A utility class that is used as an interface to run 3rd-party tool ImageMagick.

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.

Constructor & Destructor Documentation

◆ ImageMagickHelper() [1/2]

iText.IO.Util.ImageMagickHelper.ImageMagickHelper ( )
inline

Creates new instance that will rely on ImageMagick execution command defined by MAGICK_COMPARE_ENVIRONMENT_VARIABLE environment variable.

◆ ImageMagickHelper() [2/2]

iText.IO.Util.ImageMagickHelper.ImageMagickHelper ( String  newCompareExec )
inline

Creates new instance that will rely on ImageMagick execution command defined as passed argument.

Parameters
newCompareExec the ImageMagick execution command; if null - environment variables will be used instead

Member Function Documentation

◆ GetCliExecutionCommand()

virtual String iText.IO.Util.ImageMagickHelper.GetCliExecutionCommand ( )
inlinevirtual

Returns a command that is used to run the utility.

Returns a command that is used to run the utility. This command doesn't contain command parameters. Parameters are added on specific methods invocation.

Returns
a string command

◆ RunImageMagickImageCompare() [1/2]

virtual bool iText.IO.Util.ImageMagickHelper.RunImageMagickImageCompare ( String  outImageFilePath,
String  cmpImageFilePath,
String  diffImageName 
)
inlinevirtual

Runs imageMagick to visually compare images and generate difference output.

Runs imageMagick to visually compare images and generate difference output.

Note, that this method may create temporary files.

Parameters
outImageFilePath Path to the output image file
cmpImageFilePath Path to the cmp image file
diffImageName Path to the difference output image file
Returns
boolean result of comparing: true - images are visually equal

◆ RunImageMagickImageCompare() [2/2]

virtual bool iText.IO.Util.ImageMagickHelper.RunImageMagickImageCompare ( String  outImageFilePath,
String  cmpImageFilePath,
String  diffImageName,
String  fuzzValue 
)
inlinevirtual

Runs imageMagick to visually compare images with the specified fuzziness value and generate difference output.

Runs imageMagick to visually compare images with the specified fuzziness value and generate difference output.

Note, that this method may create temporary files.

Parameters
outImageFilePath Path to the output image file
cmpImageFilePath Path to the cmp image file
diffImageName Path to the difference output image file
fuzzValue String 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
boolean result of comparing: true - images are visually equal

◆ RunImageMagickImageCompareAndGetResult()

virtual ImageMagickCompareResult iText.IO.Util.ImageMagickHelper.RunImageMagickImageCompareAndGetResult ( String  outImageFilePath,
String  cmpImageFilePath,
String  diffImageName,
String  fuzzValue 
)
inlinevirtual

Runs imageMagick to visually compare images with the specified fuzziness value and generate difference output.

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.

Parameters
outImageFilePath Path to the output image file
cmpImageFilePath Path to the cmp image file
diffImageName Path to the difference output image file
fuzzValue String 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
an object of ImageMagickCompareResult . containing comparing result information.

◆ RunImageMagickImageCompareWithThreshold()

virtual bool iText.IO.Util.ImageMagickHelper.RunImageMagickImageCompareWithThreshold ( String  outImageFilePath,
String  cmpImageFilePath,
String  diffImageName,
String  fuzzValue,
long  threshold 
)
inlinevirtual

Runs imageMagick to visually compare images with the specified fuzziness value and given threshold and generate difference output.

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.

Parameters
outImageFilePath Path to the output image file
cmpImageFilePath Path to the cmp image file
diffImageName Path to the difference output image file
fuzzValue String 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 Long value of accepted threshold.
Returns
boolean result of comparing: true - images are visually equal

Member Data Documentation

◆ MAGICK_COMPARE_ENVIRONMENT_VARIABLE

const String iText.IO.Util.ImageMagickHelper.MAGICK_COMPARE_ENVIRONMENT_VARIABLE = "ITEXT_MAGICK_COMPARE_EXEC"
static

The name of the environment variable with the command to execute ImageMagic comparison operations.