Last active
September 21, 2017 02:22
-
-
Save goofmint/7d7b275a05f8f09177cb6b75855111b9 to your computer and use it in GitHub Desktop.
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
import java.io.*; | |
import javax.imageio.ImageIO; | |
import java.awt.image.BufferedImage; | |
import com.htmlhifive.pitalium.core.*; | |
import com.htmlhifive.pitalium.image.util.*; | |
import com.htmlhifive.pitalium.image.model.*; | |
class Diff { | |
public static void main(String args[]){ | |
try { | |
// 正とする画像 | |
BufferedImage Image1 = ImageIO.read(new File(args[0])); | |
// 比較対象の画像 | |
BufferedImage Image2 = ImageIO.read(new File(args[1])); | |
// 比較実行 | |
ImageComparedResult result = ImageUtils.compare( | |
Image1, null, Image2, null, | |
new CompareOption[] { | |
new CompareOption( | |
CompareOptionType.IGNORE_CLEAR_PIXELS | |
) | |
} | |
); | |
// 結果の確認 | |
if (result.isFailed()) { | |
// 違いがある場合 | |
// 差分を書き出し | |
DiffPoints diffPoints = (DiffPoints) result; | |
final BufferedImage diffImage = ImageUtils.getDiffImage( | |
Image1, | |
Image2, | |
diffPoints | |
); | |
// ファイルに書き出し | |
ImageIO.write(diffImage, "png", new File(args[2])); | |
} | |
} catch(IOException e) { | |
System.err.println(e.getMessage()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment