A Dart Package to get the % difference between two images of the same width and height.
diff_image is a Dart version of this with changes on visualization and , you guessed it, the language.
A simple usage example:
import 'package:diff_image/diff_image.dart';
final FIRST_IMAGE = 'https://raw.githubusercontent.com/nicolashahn/diffimg/master/images/mario-circle-cs.png';
final SECOND_IMAGE = 'https://raw.githubusercontent.com/nicolashahn/diffimg/master/images/mario-circle-node.png';
void foo() async{
try{
var diff = await DiffImage.compareFromUrl(FIRST_IMAGE, SECOND_IMAGE);
print('The difference between images is: $diff %');
} catch(e){
print(e);
}
}
main() {
foo();
}
A more detailed example can be found here
- Currently there is support only for images from the web (urls)
- The
compareFromUrl
definition is:
static Future<num> compareFromUrl(
firstImgSrc, secondImgSrc,
{ignoreAlpha=true, asPercentage=true, saveDiff=false}
) async{...}
where:
ignoreAlpha
allows to decide whether to take alpha from RGBA into account for the calculationasPercentage
set the format of the output (as percentage or between 0-1)saveDiff
save a png showing the differences between [firstImgSrc] and [secondImgSrc] (currently not available on Dart Web)
With Alpha : 35.67169421487167 %
Without Alpha : 34.83905183744361 %
Please file feature requests, suggestions and bugs at the issue tracker.