#image #comparison #command-line-tool

bin+lib img_diff

Command line tool to diff images in 2 structurally similar folders and output diff images

9 stable releases (4 major)

5.0.0 Dec 27, 2019
4.0.0 Jul 12, 2019
3.0.2 Dec 17, 2018
2.0.0 Jan 22, 2018
1.1.0 Jan 16, 2018

#384 in Images

21 downloads per month

MIT license

31KB
649 lines

img_diff

Linux/OSX Build Status Windows Build Status Current Version dependency status License: MIT

Rust based Command line tool to diff images in 2 structurally similar folders and output diff images.

The value outputted represent a percentage of how much the amount of pixel data differs from the hightest possible value for that given image in each pixel.

Future Features

  • Support multiple format's of images (JPEG).
  • Allow for a threshold to output diff file.

From the CLI WG

  • Revise stdout & stderr efficiency (avoid flush by using a stream).
  • Add logging (log crate)
  • Add Progress bar (indicatif crate)
  • Add types of output (convey crate)
  • Generate a man page (clap crate)

Usage

img_diff -s path\to\images -d path\to\images\to\compare -f path\to\output\diff\images

Will go trough all the files in the -s dir and subdirectories and compare them to the ones in the -d outputting diff files if a difference is found to -f dir.

-v

enables verbose mode and output to stderr in case of a difference found.

Usage in CI

img_diff -s path\to\images -d path\to\images\to\compare -f path\to\output\diff\images -v 2> results/output.txt

This will enable verbose output and enable the results of failed comparisons to be put into output.txt We can use this to enable CI with if [[ -s results/output.txt ]]; then exit 1; else exit 0; fi

Compile from source

 git clone https://github.com/Mike-Neto/img_diff.git
 cd img_diff
 cargo build --release

Build all files

cargo build && cargo test && cargo test --benches
cargo +beta build && cargo +beta test && cargo +beta test --benches
cargo +nightly build && cargo +nightly test && cargo +nightly test --benches

Test

cargo test

Docs

cargo doc --open

Crate

Crates.io

Download

You need Rust

cargo install img_diff

You can also download a binary release for your platform on github releases

Publish process

cargo bump (major|minor|patch)
git commit -m "v4.0.0"
git tag -a v4.0.0 -m "v4.0.0"
git push --tags
cargo publish

Benchmarking and Profiling

Dependencies

sudo apt install valgrind kcachegrind

Local Benchmarks

Will run all all benchmarks against local data.

cargo clean
git checkout master
cargo bench
git checkout $CURRENT_WORKING_BRANCH
cargo bench

Profiling changes

cargo bench img_diff/subtract
# Check for the binary name which will then be used as input bellow
valgrind --tool=callgrind --dump-instr=yes --collect-jumps=yes --simulate-cache=yes target/release/deps/bench-f72b65412859cf2f --bench img_diff/subtract
# Check for the above output file name
kcachegrind callgrind.out.20282

License

Copyright 2018 Miguel Mendes

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Dependencies

~9–18MB
~226K SLoC