Last active
January 25, 2019 13:05
-
-
Save dettmering/900a3cbcf5ab8d5a65218b1b3be7af9f to your computer and use it in GitHub Desktop.
Compare a single page of two PDF files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
FILE_A=$1 | |
FILE_B=$2 | |
PAGE_COUNT_A=$(pdfinfo $FILE_A | grep Pages | awk '{print $2}') | |
PAGE_COUNT_B=$(pdfinfo $FILE_B | grep Pages | awk '{print $2}') | |
if [ $PAGE_COUNT_A -eq $PAGE_COUNT_B ]; | |
then | |
for i in $(seq 0 $PAGE_COUNT_A); do | |
echo Comparing page $i | |
convert -density 300 $FILE_A[$i] -transparent white -colorspace RGB -alpha extract -threshold 0 -fill red +opaque black -transparent black A.png | |
convert -density 300 $FILE_B[$i] -transparent white -colorspace RGB -alpha extract -threshold 0 -fill blue +opaque black -transparent black B.png | |
composite -blend 50 A.png B.png diff_$i.png | |
rm A.png B.png | |
done | |
else | |
echo Page count of the documents does not match. | |
exit 1 | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
FILE_A=$1 | |
FILE_B=$2 | |
convert -density 300 $FILE_A -transparent white -colorspace RGB -alpha extract -threshold 0 -fill red +opaque black -transparent black A.png | |
convert -density 300 $FILE_B -transparent white -colorspace RGB -alpha extract -threshold 0 -fill blue +opaque black -transparent black B.png | |
composite -blend 50 A.png B.png diff.png | |
rm A.png B.png |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment