Skip to content

Instantly share code, notes, and snippets.

@stoyanovgeorge
Created October 23, 2018 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stoyanovgeorge/3f2de32f47f3c4c8f39ba1e379138b0a to your computer and use it in GitHub Desktop.
Save stoyanovgeorge/3f2de32f47f3c4c8f39ba1e379138b0a to your computer and use it in GitHub Desktop.
Compares two image files and returns the PSNR and MSE values.
#!/bin/bash
if [ -e "$1" ] && [ -e "$2" ];
then
if file "$1" | grep -qE 'image|bitmap' && file "$2" | grep -qE 'image|bitmap' ;
then
ffmpeg -loglevel error -i "$1" -i "$2" -lavfi psnr=psnr.log -f null -
cat psnr.log
rm psnr.log
else
echo "The first and/or the second file isn't a valid image file!"
exit 0
fi
else
echo "The first and/or the second file doesn't exist! Please make sure to run the command: './psnr_check.sh path/to/reference/file path/to/processed/file'"
exit 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment