Skip to content

Instantly share code, notes, and snippets.

@YoshihitoAso
Created March 23, 2016 09:01
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 YoshihitoAso/2bec3c8566f6cb9e0864 to your computer and use it in GitHub Desktop.
Save YoshihitoAso/2bec3c8566f6cb9e0864 to your computer and use it in GitHub Desktop.
ImageMagickで画像ファイルのDiffをとる
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
#----------------------------------------------------------------
# ImageMagick Diff
#
# Copyright 2016 Yoshihito Aso
#----------------------------------------------------------------
class ImageMagick_Diff:
def __init__(self, in_file1, in_file2, out_file):
self.in_file1 = in_file1
self.in_file2 = in_file2
self.out_file = out_file
def diff(self):
cmd = "composite -compose difference " + str(in_file1) + " " + str(in_file2) + " " + str(out_file)
os.system(cmd);
if __name__ == "__main__":
# 引数のチェック
argvs = sys.argv
argc = len(argvs)
if (argc != 4):
print 'Usage: # python %s in_file1 in_file2 diff_file' % argvs[0]
quit()
in_file1 = argvs[1]
in_file2 = argvs[2]
out_file = argvs[3]
IM_Diff = ImageMagick_Diff(in_file1,in_file2,out_file)
IM_Diff.diff()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment