blob: 6e5f00cbfb93b874a80a0fca98324254af841d51 [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001/*
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3% %
4% %
5% %
6% SSSSS TTTTT AAA TTTTT IIIII CCCC %
7% SS T A A T I C %
8% SSS T AAAAA T I C %
9% SS T A A T I C %
10% SSSSS T A A T IIIII CCCC %
11% %
12% %
13% MagickCore Static Methods %
14% %
15% Software Design %
16% John Cristy %
17% March 2000 %
18% %
19% %
cristy7e41fe82010-12-04 23:12:08 +000020% Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
cristy3ed852e2009-09-05 21:47:34 +000021% dedicated to making software imaging solutions freely available. %
22% %
23% You may not use this file except in compliance with the License. You may %
24% obtain a copy of the License at %
25% %
26% http://www.imagemagick.org/script/license.php %
27% %
28% Unless required by applicable law or agreed to in writing, software %
29% distributed under the License is distributed on an "AS IS" BASIS, %
30% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31% See the License for the specific language governing permissions and %
32% limitations under the License. %
33% %
34%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35%
36%
37%
38*/
39
40/*
41 Include declarations.
42*/
43#include "magick/studio.h"
44#include "magick/exception-private.h"
45#include "magick/image.h"
46#include "magick/module.h"
47#include "magick/policy.h"
48#include "magick/static.h"
49#include "magick/string_.h"
50
51/*
52%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53% %
54% %
55% %
56% I n v o k e S t a t i c I m a g e F i l t e r %
57% %
58% %
59% %
60%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
61%
62% InvokeStaticImageFilter() invokes a static image filter.
63%
64% The format of the InvokeStaticImageFilter method is:
65%
66% MagickBooleanType InvokeStaticImageFilter(const char *tag,Image **image,
67% const int argc,const char **argv)
68%
69% A description of each parameter follows:
70%
71% o tag: the module tag.
72%
73% o image: the image.
74%
75% o argc: the number of elements in the argument vector.
76%
77% o argv: A text array containing the command line arguments.
78%
79% o argv: A text array containing the command line arguments.
80%
81% o exception: return any errors or warnings in this structure.
82%
83*/
84#if defined(MAGICKCORE_MODULES_SUPPORT)
85MagickExport MagickBooleanType InvokeStaticImageFilter(const char *tag,
86 Image **image,const int argc,const char **argv,ExceptionInfo *exception)
87{
88 PolicyRights
89 rights;
90
91 assert(image != (Image **) NULL);
92 assert((*image)->signature == MagickSignature);
93 if ((*image)->debug != MagickFalse)
94 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
95 rights=ReadPolicyRights;
96 if (IsRightsAuthorized(FilterPolicyDomain,rights,tag) == MagickFalse)
97 {
cristya9197f62010-01-12 02:23:34 +000098 errno=EPERM;
cristy3ed852e2009-09-05 21:47:34 +000099 (void) ThrowMagickException(exception,GetMagickModule(),PolicyError,
100 "NotAuthorized","`%s'",tag);
101 return(MagickFalse);
102 }
103#if defined(MAGICKCORE_BUILD_MODULES)
104 (void) tag;
105 (void) argc;
106 (void) argv;
107 (void) exception;
108#else
109 {
cristybb503372010-05-27 20:51:26 +0000110 extern size_t
cristya0b81c32010-01-22 02:54:33 +0000111 analyzeImage(Image **,const int,char **,ExceptionInfo *);
cristy3ed852e2009-09-05 21:47:34 +0000112
113 ImageFilterHandler
114 *image_filter;
115
116 image_filter=(ImageFilterHandler *) NULL;
117 if (LocaleCompare("analyze",tag) == 0)
cristyc4c8d132010-01-07 01:58:38 +0000118 image_filter=(ImageFilterHandler *) analyzeImage;
cristya6de29a2010-06-30 14:34:26 +0000119 if (image_filter == (ImageFilterHandler *) NULL)
120 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
121 "UnableToLoadModule","`%s'",tag);
122 else
cristy3ed852e2009-09-05 21:47:34 +0000123 {
cristybb503372010-05-27 20:51:26 +0000124 size_t
cristy3ed852e2009-09-05 21:47:34 +0000125 signature;
126
127 if ((*image)->debug != MagickFalse)
128 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
129 "Invoking \"%s\" static image filter",tag);
130 signature=image_filter(image,argc,argv,exception);
131 if ((*image)->debug != MagickFalse)
132 (void) LogMagickEvent(CoderEvent,GetMagickModule(),"\"%s\" completes",
133 tag);
134 if (signature != MagickImageFilterSignature)
135 {
136 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
cristyb65b3302010-05-29 16:58:33 +0000137 "ImageFilterSignatureMismatch","`%s': %8lx != %8lx",tag,
138 (unsigned long) signature,(unsigned long)
cristy3ed852e2009-09-05 21:47:34 +0000139 MagickImageFilterSignature);
140 return(MagickFalse);
141 }
142 }
143 }
144#endif
145 return(MagickTrue);
146}
147#endif
148
149/*
150%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
151% %
152% %
153% %
154% R e g i s t e r S t a t i c M o d u l e s %
155% %
156% %
157% %
158%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
159%
160% (void) RegisterStaticModules() statically registers all the available module
161% handlers.
162%
163% The format of the RegisterStaticModules method is:
164%
165% (void) RegisterStaticModules(void)
166%
167*/
168MagickExport void RegisterStaticModules(void)
169{
170#if !defined(MAGICKCORE_BUILD_MODULES)
cristy397bede2011-01-18 23:59:59 +0000171 (void) RegisterAAIImage();
cristy3ed852e2009-09-05 21:47:34 +0000172 (void) RegisterARTImage();
cristy3ed852e2009-09-05 21:47:34 +0000173 (void) RegisterAVSImage();
174 (void) RegisterBMPImage();
cristy1f9ce9f2010-04-28 11:55:12 +0000175 (void) RegisterCALSImage();
cristy3ed852e2009-09-05 21:47:34 +0000176 (void) RegisterCAPTIONImage();
177 (void) RegisterCINImage();
178 (void) RegisterCIPImage();
179 (void) RegisterCLIPImage();
180#if defined(MAGICKCORE_WINGDI32_DELEGATE)
181 (void) RegisterCLIPBOARDImage();
182#endif
183 (void) RegisterCMYKImage();
184 (void) RegisterCUTImage();
185 (void) RegisterDCMImage();
186 (void) RegisterDDSImage();
cristy2aac09a2010-06-06 16:46:43 +0000187 (void) RegisterDEBUGImage();
cristy3ed852e2009-09-05 21:47:34 +0000188 (void) RegisterDIBImage();
189#if defined(MAGICKCORE_DJVU_DELEGATE)
190 (void) RegisterDJVUImage();
191#endif
192 (void) RegisterDNGImage();
cristyb32b90a2009-09-07 21:45:48 +0000193#if defined(MAGICKCORE_DPS_DELEGATE)
cristy3ed852e2009-09-05 21:47:34 +0000194 (void) RegisterDPSImage();
cristyb32b90a2009-09-07 21:45:48 +0000195#endif
cristy3ed852e2009-09-05 21:47:34 +0000196 (void) RegisterDPXImage();
197#if defined(MAGICKCORE_WINGDI32_DELEGATE)
198 (void) RegisterEMFImage();
199#endif
200#if defined(MAGICKCORE_TIFF_DELEGATE)
201 (void) RegisterEPTImage();
202#endif
203#if defined(MAGICKCORE_OPENEXR_DELEGATE)
204 (void) RegisterEXRImage();
205#endif
206 (void) RegisterFAXImage();
207 (void) RegisterFITSImage();
208#if defined(MAGICKCORE_FPX_DELEGATE)
209 (void) RegisterFPXImage();
210#endif
211 (void) RegisterGIFImage();
212 (void) RegisterGRAYImage();
213 (void) RegisterGRADIENTImage();
cristy579bc8f2011-03-06 17:27:05 +0000214 (void) RegisterHALDIMAGEImage();
215 (void) RegisterHDRIMAGEImage();
216 (void) RegisterHIMAGEImage();
cristy3ed852e2009-09-05 21:47:34 +0000217 (void) RegisterHISTOGRAMImage();
218 (void) RegisterHRZImage();
219 (void) RegisterHTMLImage();
220 (void) RegisterICONImage();
221 (void) RegisterINFOImage();
222 (void) RegisterINLINEImage();
223 (void) RegisterIPLImage();
224#if defined(MAGICKCORE_JBIG_DELEGATE)
225 (void) RegisterJBIGImage();
226#endif
227#if defined(MAGICKCORE_JPEG_DELEGATE)
228 (void) RegisterJPEGImage();
229#endif
230#if defined(MAGICKCORE_JP2_DELEGATE)
231 (void) RegisterJP2Image();
232#endif
233 (void) RegisterLABELImage();
cristyae29c4f2010-12-28 14:45:29 +0000234 (void) RegisterMACImage();
cristy3ed852e2009-09-05 21:47:34 +0000235 (void) RegisterMAGICKImage();
236 (void) RegisterMAPImage();
237 (void) RegisterMATImage();
238 (void) RegisterMATTEImage();
239 (void) RegisterMETAImage();
240 (void) RegisterMIFFImage();
241 (void) RegisterMONOImage();
242 (void) RegisterMPCImage();
243 (void) RegisterMPEGImage();
244 (void) RegisterMPRImage();
245 (void) RegisterMSLImage();
246 (void) RegisterMTVImage();
247 (void) RegisterMVGImage();
248 (void) RegisterNULLImage();
249 (void) RegisterOTBImage();
250 (void) RegisterPALMImage();
251 (void) RegisterPATTERNImage();
252 (void) RegisterPCDImage();
253 (void) RegisterPCLImage();
254 (void) RegisterPCXImage();
255 (void) RegisterPDBImage();
256 (void) RegisterPDFImage();
cristyc2e5d6d2010-01-24 17:45:00 +0000257 (void) RegisterPESImage();
cristy3ed852e2009-09-05 21:47:34 +0000258 (void) RegisterPICTImage();
259 (void) RegisterPIXImage();
260 (void) RegisterPLASMAImage();
261#if defined(MAGICKCORE_PNG_DELEGATE)
262 (void) RegisterPNGImage();
263#endif
264 (void) RegisterPNMImage();
265 (void) RegisterPREVIEWImage();
266 (void) RegisterPSImage();
267 (void) RegisterPS2Image();
268 (void) RegisterPS3Image();
269 (void) RegisterPSDImage();
270 (void) RegisterPWPImage();
271 (void) RegisterRAWImage();
272 (void) RegisterRGBImage();
273 (void) RegisterRLAImage();
274 (void) RegisterRLEImage();
275 (void) RegisterSCRImage();
276 (void) RegisterSCTImage();
277 (void) RegisterSFWImage();
278 (void) RegisterSGIImage();
279 (void) RegisterSTEGANOImage();
280 (void) RegisterSUNImage();
281 (void) RegisterSVGImage();
282 (void) RegisterTGAImage();
283 (void) RegisterTHUMBNAILImage();
284#if defined(MAGICKCORE_TIFF_DELEGATE)
285 (void) RegisterTIFFImage();
286#endif
287 (void) RegisterTILEImage();
288 (void) RegisterTIMImage();
289 (void) RegisterTTFImage();
290 (void) RegisterTXTImage();
291 (void) RegisterUILImage();
292 (void) RegisterURLImage();
293 (void) RegisterUYVYImage();
294 (void) RegisterVICARImage();
295 (void) RegisterVIDImage();
296 (void) RegisterVIFFImage();
297 (void) RegisterWBMPImage();
298#if defined(MAGICKCORE_WMF_DELEGATE) || defined(MAGICKCORE_WMFLITE_DELEGATE)
299 (void) RegisterWMFImage();
300#endif
301 (void) RegisterWPGImage();
302#if defined(MAGICKCORE_X11_DELEGATE)
303 (void) RegisterXImage();
304#endif
305 (void) RegisterXBMImage();
306 (void) RegisterXCImage();
307 (void) RegisterXCFImage();
308 (void) RegisterXPMImage();
309 (void) RegisterXPSImage();
310#if defined(_VISUALC_)
311 (void) RegisterXTRNImage();
312#endif
313#if defined(MAGICKCORE_X11_DELEGATE)
314 (void) RegisterXWDImage();
315#endif
316 (void) RegisterYCBCRImage();
317 (void) RegisterYUVImage();
318#endif
319}
320
321/*
322%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
323% %
324% %
325% %
326% U n r e g i s t e r S t a t i c M o d u l e s %
327% %
328% %
329% %
330%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
331%
332% UnregisterStaticModules() statically unregisters all the available module
333% handlers.
334%
335% The format of the UnregisterStaticModules method is:
336%
337% UnregisterStaticModules(void)
338%
339*/
340MagickExport void UnregisterStaticModules(void)
341{
342#if !defined(MAGICKCORE_BUILD_MODULES)
cristy397bede2011-01-18 23:59:59 +0000343 UnregisterAAIImage();
cristy3ed852e2009-09-05 21:47:34 +0000344 UnregisterARTImage();
cristy3ed852e2009-09-05 21:47:34 +0000345 UnregisterAVSImage();
346 UnregisterBMPImage();
347 UnregisterBRAILLEImage();
cristy1f9ce9f2010-04-28 11:55:12 +0000348 UnregisterCALSImage();
cristy3ed852e2009-09-05 21:47:34 +0000349 UnregisterCAPTIONImage();
350 UnregisterCINImage();
351 UnregisterCIPImage();
352 UnregisterCLIPImage();
353#if defined(MAGICKCORE_WINGDI32_DELEGATE)
354 UnregisterCLIPBOARDImage();
355#endif
356 UnregisterCMYKImage();
357 UnregisterCUTImage();
358 UnregisterDCMImage();
359 UnregisterDDSImage();
cristy2aac09a2010-06-06 16:46:43 +0000360 UnregisterDEBUGImage();
cristy3ed852e2009-09-05 21:47:34 +0000361 UnregisterDIBImage();
362#if defined(MAGICKCORE_DJVU_DELEGATE)
363 UnregisterDJVUImage();
364#endif
365 UnregisterDNGImage();
cristyb32b90a2009-09-07 21:45:48 +0000366#if defined(MAGICKCORE_DPS_DELEGATE)
cristy3ed852e2009-09-05 21:47:34 +0000367 UnregisterDPSImage();
cristyb32b90a2009-09-07 21:45:48 +0000368#endif
cristy3ed852e2009-09-05 21:47:34 +0000369 UnregisterDPXImage();
370#if defined(MAGICKCORE_WINGDI32_DELEGATE)
371 UnregisterEMFImage();
372#endif
373#if defined(MAGICKCORE_TIFF_DELEGATE)
374 UnregisterEPTImage();
375#endif
376#if defined(MAGICKCORE_OPENEXR_DELEGATE)
377 UnregisterEXRImage();
378#endif
379 UnregisterFAXImage();
380 UnregisterFITSImage();
381#if defined(MAGICKCORE_FPX_DELEGATE)
382 UnregisterFPXImage();
383#endif
384 UnregisterGIFImage();
385 UnregisterGRAYImage();
386 UnregisterGRADIENTImage();
cristy579bc8f2011-03-06 17:27:05 +0000387 UnregisterHALDImage();
388 UnregisterHDRImage();
389 UnregisterHImage();
cristy3ed852e2009-09-05 21:47:34 +0000390 UnregisterHISTOGRAMImage();
391 UnregisterHRZImage();
392 UnregisterHTMLImage();
393 UnregisterICONImage();
394 UnregisterINFOImage();
395 UnregisterINLINEImage();
396 UnregisterIPLImage();
397#if defined(MAGICKCORE_JBIG_DELEGATE)
398 UnregisterJBIGImage();
399#endif
400#if defined(MAGICKCORE_JPEG_DELEGATE)
401 UnregisterJPEGImage();
402#endif
403#if defined(MAGICKCORE_JP2_DELEGATE)
404 UnregisterJP2Image();
405#endif
406 UnregisterLABELImage();
cristyae29c4f2010-12-28 14:45:29 +0000407 UnregisterMACImage();
cristy3ed852e2009-09-05 21:47:34 +0000408 UnregisterMAGICKImage();
409 UnregisterMAPImage();
410 UnregisterMATImage();
411 UnregisterMATTEImage();
412 UnregisterMETAImage();
413 UnregisterMIFFImage();
414 UnregisterMONOImage();
415 UnregisterMPCImage();
416 UnregisterMPEGImage();
417 UnregisterMPRImage();
418 UnregisterMSLImage();
419 UnregisterMTVImage();
420 UnregisterMVGImage();
421 UnregisterNULLImage();
422 UnregisterOTBImage();
423 UnregisterPALMImage();
424 UnregisterPATTERNImage();
425 UnregisterPCDImage();
426 UnregisterPCLImage();
427 UnregisterPCXImage();
428 UnregisterPDBImage();
429 UnregisterPDFImage();
cristyc2e5d6d2010-01-24 17:45:00 +0000430 UnregisterPESImage();
cristy3ed852e2009-09-05 21:47:34 +0000431 UnregisterPICTImage();
432 UnregisterPIXImage();
433 UnregisterPLASMAImage();
434#if defined(MAGICKCORE_PNG_DELEGATE)
435 UnregisterPNGImage();
436#endif
437 UnregisterPNMImage();
438 UnregisterPREVIEWImage();
439 UnregisterPSImage();
440 UnregisterPS2Image();
441 UnregisterPS3Image();
442 UnregisterPSDImage();
443 UnregisterPWPImage();
444 UnregisterRAWImage();
445 UnregisterRGBImage();
446 UnregisterRLAImage();
447 UnregisterRLEImage();
448 UnregisterSCRImage();
449 UnregisterSCTImage();
450 UnregisterSFWImage();
451 UnregisterSGIImage();
452 UnregisterSTEGANOImage();
453 UnregisterSUNImage();
454 UnregisterSVGImage();
455 UnregisterTGAImage();
456 UnregisterTHUMBNAILImage();
457#if defined(MAGICKCORE_TIFF_DELEGATE)
458 UnregisterTIFFImage();
459#endif
460 UnregisterTILEImage();
461 UnregisterTIMImage();
462 UnregisterTTFImage();
463 UnregisterTXTImage();
464 UnregisterUILImage();
465 UnregisterURLImage();
466 UnregisterUYVYImage();
467 UnregisterVICARImage();
468 UnregisterVIDImage();
469 UnregisterVIFFImage();
470 UnregisterWBMPImage();
471#if defined(MAGICKCORE_WMF_DELEGATE) || defined(MAGICKCORE_WMFLITE_DELEGATE)
472 UnregisterWMFImage();
473#endif
474 UnregisterWPGImage();
475#if defined(MAGICKCORE_X11_DELEGATE)
476 UnregisterXImage();
477#endif
478 UnregisterXBMImage();
479 UnregisterXCImage();
480 UnregisterXCFImage();
481 UnregisterXPMImage();
482 UnregisterXPSImage();
483#if defined(_VISUALC_)
484 UnregisterXTRNImage();
485#endif
486#if defined(MAGICKCORE_X11_DELEGATE)
487 UnregisterXWDImage();
488#endif
489 UnregisterYCBCRImage();
490 UnregisterYUVImage();
491#endif
492}