def get_percent_difference(file1, file2): """ Performs pixel comparison of two files, given by their paths |file1| and |file2| using terminal tool 'perceptualdiff' and returns percentage difference of the total file size. @param file1: path to image @param file2: path to secondary image @return: percentage difference of total file size. @raise ValueError: if image dimensions are not the same @raise OSError: if file does not exist or cannot be opened. """ # Using pdiff image comparer to compare the two images. This class # invokes the terminal tool perceptualdiff. pdi = pdiff_image_comparer.PdiffImageComparer() diff_bytes = pdi.compare(file1, file2)[0] return round(100. * diff_bytes / os.path.getsize(file1))
def make_pdiff_comparer(self): """ @returns a PDiffImageComparer object. """ return pdiff_image_comparer.PdiffImageComparer()