Skip to content

Instantly share code, notes, and snippets.

@koyachi
Last active March 8, 2017 07:04
Show Gist options
  • Save koyachi/c1077300ab8ce5c14ea03987709fc299 to your computer and use it in GitHub Desktop.
Save koyachi/c1077300ab8ce5c14ea03987709fc299 to your computer and use it in GitHub Desktop.

Revisions

  1. koyachi revised this gist Mar 8, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions image_diff.sh
    Original file line number Diff line number Diff line change
    @@ -2,9 +2,9 @@
    # via https://github.com/koyachi/diff_pdf_image/blob/master/diff_pdf_image.rb

    # before
    image_b=$2
    image_b=$1
    # after
    image_a=$1
    image_a=$2

    function to_gray {
    convert $1 -type GrayScale $1.gray.png
  2. koyachi created this gist Mar 8, 2017.
    31 changes: 31 additions & 0 deletions image_diff.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    #!/bin/bash
    # via https://github.com/koyachi/diff_pdf_image/blob/master/diff_pdf_image.rb

    # before
    image_b=$2
    # after
    image_a=$1

    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