cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 | % % |
| 4 | % % |
| 5 | % % |
| 6 | % CCCC OOO M M PPPP AAA RRRR EEEEE % |
| 7 | % C O O MM MM P P A A R R E % |
| 8 | % C O O M M M PPPP AAAAA RRRR EEE % |
| 9 | % C O O M M P A A R R E % |
| 10 | % CCCC OOO M M P A A R R EEEEE % |
| 11 | % % |
| 12 | % % |
| 13 | % Image Comparison Utility % |
| 14 | % % |
| 15 | % % |
| 16 | % Software Design % |
cristy | de984cd | 2013-12-01 14:49:27 +0000 | [diff] [blame] | 17 | % Cristy % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 18 | % December 2003 % |
| 19 | % % |
| 20 | % % |
cristy | fe676ee | 2013-11-18 13:03:38 +0000 | [diff] [blame] | 21 | % Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 22 | % dedicated to making software imaging solutions freely available. % |
| 23 | % % |
| 24 | % You may not use this file except in compliance with the License. You may % |
| 25 | % obtain a copy of the License at % |
| 26 | % % |
| 27 | % http://www.imagemagick.org/script/license.php % |
| 28 | % % |
| 29 | % Unless required by applicable law or agreed to in writing, software % |
| 30 | % distributed under the License is distributed on an "AS IS" BASIS, % |
| 31 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % |
| 32 | % See the License for the specific language governing permissions and % |
| 33 | % limitations under the License. % |
| 34 | % % |
| 35 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 36 | % |
| 37 | % The compare utility mathematically and visually annotates the difference |
| 38 | % between an image and its reconstruction. |
| 39 | % |
| 40 | */ |
| 41 | |
| 42 | /* |
| 43 | Include declarations. |
| 44 | */ |
cristy | ee67810 | 2011-07-01 23:32:11 +0000 | [diff] [blame] | 45 | #include "MagickWand/studio.h" |
| 46 | #include "MagickWand/MagickWand.h" |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 47 | |
| 48 | /* |
| 49 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 50 | % % |
| 51 | % % |
| 52 | % % |
| 53 | % M a i n % |
| 54 | % % |
| 55 | % % |
| 56 | % % |
| 57 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 58 | % |
| 59 | % |
| 60 | */ |
cristy | 9c88feb | 2011-09-21 13:06:09 +0000 | [diff] [blame] | 61 | static int CompareMain(int argc,char **argv) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 62 | { |
| 63 | char |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 64 | *metadata; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 65 | |
cristy | ebd71f4 | 2013-09-13 22:35:48 +0000 | [diff] [blame] | 66 | const char |
| 67 | *option; |
| 68 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 69 | ExceptionInfo |
| 70 | *exception; |
| 71 | |
| 72 | ImageInfo |
| 73 | *image_info; |
| 74 | |
| 75 | MagickBooleanType |
cristy | ebd71f4 | 2013-09-13 22:35:48 +0000 | [diff] [blame] | 76 | dissimilar, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 77 | status; |
| 78 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 79 | MagickCoreGenesis(*argv,MagickTrue); |
| 80 | exception=AcquireExceptionInfo(); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 81 | image_info=AcquireImageInfo(); |
| 82 | metadata=(char *) NULL; |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 83 | status=MagickCommandGenesis(image_info,CompareImagesCommand,argc,argv, |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 84 | &metadata,exception); |
| 85 | if (metadata != (char *) NULL) |
| 86 | metadata=DestroyString(metadata); |
cristy | ebd71f4 | 2013-09-13 22:35:48 +0000 | [diff] [blame] | 87 | option=GetImageOption(image_info,"compare:dissimilar"); |
| 88 | dissimilar=IsStringTrue(option); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 89 | image_info=DestroyImageInfo(image_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 90 | exception=DestroyExceptionInfo(exception); |
| 91 | MagickCoreTerminus(); |
cristy | ebd71f4 | 2013-09-13 22:35:48 +0000 | [diff] [blame] | 92 | if (dissimilar != MagickFalse) |
| 93 | return(1); |
| 94 | return(status == MagickFalse ? 0 : 2); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 95 | } |
cristy | 66f9c3c | 2011-08-13 17:12:28 +0000 | [diff] [blame] | 96 | |
cristy | 07a3cca | 2012-12-10 13:09:10 +0000 | [diff] [blame] | 97 | #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__) |
cristy | 66f9c3c | 2011-08-13 17:12:28 +0000 | [diff] [blame] | 98 | int main(int argc,char **argv) |
| 99 | { |
| 100 | return(CompareMain(argc,argv)); |
| 101 | } |
| 102 | #else |
| 103 | int wmain(int argc,wchar_t *argv[]) |
| 104 | { |
| 105 | char |
| 106 | **utf8; |
| 107 | |
| 108 | int |
| 109 | status; |
| 110 | |
| 111 | register int |
| 112 | i; |
| 113 | |
| 114 | utf8=NTArgvToUTF8(argc,argv); |
| 115 | status=CompareMain(argc,utf8); |
| 116 | for (i=0; i < argc; i++) |
| 117 | utf8[i]=DestroyString(utf8[i]); |
| 118 | utf8=(char **) RelinquishMagickMemory(utf8); |
cristy | ebd71f4 | 2013-09-13 22:35:48 +0000 | [diff] [blame] | 119 | return(status == MagickFalse ? 0 : 1); |
cristy | 66f9c3c | 2011-08-13 17:12:28 +0000 | [diff] [blame] | 120 | } |
| 121 | #endif |