Created
March 23, 2016 09:01
-
-
Save YoshihitoAso/2bec3c8566f6cb9e0864 to your computer and use it in GitHub Desktop.
ImageMagickで画像ファイルのDiffをとる
This file contains 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
#!/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