0

I am using the following code to compare 2 image files but even after downloading required dependecies/jar files CompareCmd class is not getting identified and gives compilation error.

import org.im4java.core.*
import org.im4java.process.*
import org.im4java.utils.*

boolean compareImages(String file1, String file2) {
        // This instance wraps the compare command
        CompareCmd compare = new CompareCmd() //throws compilation error here
        // For metric-output
        compare.setErrorConsumer(StandardStream.STDERR)
        IMOperation cmpOp = new IMOperation()
        // Set the compare metric
        cmpOp.metric("mae")

        // Add the expected image
        cmpOp.addImage(file1)

        // Add the current image
        cmpOp.addImage(file2)

        // This stores the difference
//                        cmpOp.addImage(diff)

        try {
            // Do the compare
            compare.run(cmpOp);
            return true
        }
        catch (Exception ex) {
            return false
        }
    }

Error: unable to resolve class CompareCmd @ line 150, column 20. CompareCmd compare = new CompareCmd() ^

Can someone tell me if this class still exists in latest version of im4Java? or am I missing something.

Thanks in advance.

RV_Dev
  • 435
  • 1
  • 7
  • 21
  • Class is indeed there. Does your code resolves other classes? that looks like a mere problem of class path during compilation. – xenoid Apr 11 '17 at 13:44
  • It did resolve other classes. Its just this one. – RV_Dev Apr 11 '17 at 17:24
  • Strange, there is one in the source package I downloaded. It's easy enough to peek in the JAR with anything that handles .ZIP files... Is the .class there? – xenoid Apr 11 '17 at 17:39
  • Can you send me the link of the jar file? Also I am using gradle so I used its dependency to download the jars – RV_Dev Apr 11 '17 at 19:34
  • 1
    Got the files from [SourceForge](https://sourceforge.net/projects/im4java/files/im4java-1.4.0/) – xenoid Apr 12 '17 at 00:48
  • Can you tell me what will the compare.run(cmpop) does? Will it return true if the image matches or if image does not match? – RV_Dev Apr 12 '17 at 19:16

0 Answers0