Skip to content

Instantly share code, notes, and snippets.

@koyachi
Last active March 8, 2017 07:04
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 koyachi/c1077300ab8ce5c14ea03987709fc299 to your computer and use it in GitHub Desktop.
Save koyachi/c1077300ab8ce5c14ea03987709fc299 to your computer and use it in GitHub Desktop.
#!/bin/bash
# via https://github.com/koyachi/diff_pdf_image/blob/master/diff_pdf_image.rb
# before
image_b=$1
# after
image_a=$2
function to_gray {
convert $1 -type GrayScale $1.gray.png
}
function to_blue {
convert $1 +level-colors Blue,White $1.blue.png
}
function to_red {
convert $1 +level-colors Red,White $1.red.png
}
function layer {
convert $1 $2 -compose Multiply -composite $image_a.diff.png
}
to_gray $image_b
to_gray $image_a
to_blue $image_b.gray.png
to_red $image_a.gray.png
layer $image_b.gray.png.blue.png $image_a.gray.png.red.png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment