Skip to content

Instantly share code, notes, and snippets.

@rallat
Created June 24, 2019 08:08
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rallat/131491722a4b677e8a24353476850812 to your computer and use it in GitHub Desktop.
Save rallat/131491722a4b677e8a24353476850812 to your computer and use it in GitHub Desktop.
This script compares the similarity between
#!/bin/bash
# This command expects two params.
# First param is the directory of the png.
# Second param is the directory of the webp.
# It will traverse the first directory and compare that file with the same webp in the second directory
# This script requires to download similar script from http://www.fmwconcepts.com/imagemagick/similar/index.php
# and leave it the same directory as this script. This script will be the one leveraging imagemagick
pngDir=$1
webpDir=$2
find $1 -name "*.png" | cut -sd / -f 11- | sed 's/\.png$//1'|while read fname; do
pngFilePath="${pngDir}/${fname}.png"
webPFilePath="${webpDir}/${fname}.webp"
output=$(eval similar -m rgb "$pngFilePath" "$webPFilePath" )
echo "Comparing $pngFilePath & $webPFilePath: $output"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment