1 /*
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %                                                                             %
4 %                                                                             %
5 %                                                                             %
6 %                            DDDD   N   N   GGGG                              %
7 %                            D   D  NN  N  GS                                 %
8 %                            D   D  N N N  G  GG                              %
9 %                            D   D  N  NN  G   G                              %
10 %                            DDDD   N   N   GGGG                              %
11 %                                                                             %
12 %                                                                             %
13 %                  Read the Digital Negative Image Format                     %
14 %                                                                             %
15 %                              Software Design                                %
16 %                                   Cristy                                    %
17 %                                 July 1999                                   %
18 %                                                                             %
19 %                                                                             %
20 %  Copyright 1999-2021 ImageMagick Studio LLC, a non-profit organization      %
21 %  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 %    https://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   Include declarations.
40 */
41 #include "magick/studio.h"
42 #include "magick/blob.h"
43 #include "magick/blob-private.h"
44 #include "magick/constitute.h"
45 #include "magick/delegate.h"
46 #include "magick/exception.h"
47 #include "magick/exception-private.h"
48 #include "magick/geometry.h"
49 #include "magick/image.h"
50 #include "magick/image-private.h"
51 #include "magick/layer.h"
52 #include "magick/list.h"
53 #include "magick/log.h"
54 #include "magick/magick.h"
55 #include "magick/memory_.h"
56 #include "magick/monitor.h"
57 #include "magick/monitor-private.h"
58 #include "magick/opencl.h"
59 #include "magick/option.h"
60 #include "magick/pixel-accessor.h"
61 #include "magick/profile.h"
62 #include "magick/property.h"
63 #include "magick/quantum-private.h"
64 #include "magick/resource_.h"
65 #include "magick/static.h"
66 #include "magick/string_.h"
67 #include "magick/module.h"
68 #include "magick/transform.h"
69 #include "magick/utility.h"
70 #include "magick/xml-tree.h"
71 #if defined(MAGICKCORE_RAW_R_DELEGATE)
72 #include <libraw.h>
73 #endif
74 
75 /*
76 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
77 %                                                                             %
78 %                                                                             %
79 %                                                                             %
80 %   R e a d D N G I m a g e                                                   %
81 %                                                                             %
82 %                                                                             %
83 %                                                                             %
84 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
85 %
86 %  ReadDNGImage() reads an binary file in the Digital Negative format and
87 %  returns it.  It allocates the memory necessary for the new Image structure
88 %  and returns a pointer to the new image.
89 %
90 %  The format of the ReadDNGImage method is:
91 %
92 %      Image *ReadDNGImage(const ImageInfo *image_info,
93 %        ExceptionInfo *exception)
94 %
95 %  A description of each parameter follows:
96 %
97 %    o image_info: the image info.
98 %
99 %    o exception: return any errors or warnings in this structure.
100 %
101 */
102 
103 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && defined(MAGICKCORE_OPENCL_SUPPORT)
InitializeDcrawOpenCL(ExceptionInfo * exception)104 static void InitializeDcrawOpenCL(ExceptionInfo *exception)
105 {
106   MagickCLEnv
107     clEnv;
108 
109   (void) SetEnvironmentVariable("DCR_CL_PLATFORM",NULL);
110   (void) SetEnvironmentVariable("DCR_CL_DEVICE",NULL);
111   (void) SetEnvironmentVariable("DCR_CL_DISABLED",NULL);
112   clEnv=GetDefaultOpenCLEnv();
113   if (InitOpenCLEnv(clEnv,exception) != MagickFalse)
114     {
115       char
116         *name;
117 
118       MagickBooleanType
119         opencl_disabled;
120 
121       GetMagickOpenCLEnvParam(clEnv,MAGICK_OPENCL_ENV_PARAM_OPENCL_DISABLED,
122         sizeof(MagickBooleanType),&opencl_disabled,exception);
123       if (opencl_disabled != MagickFalse)
124         {
125           (void)SetEnvironmentVariable("DCR_CL_DISABLED","1");
126           return;
127         }
128       GetMagickOpenCLEnvParam(clEnv,MAGICK_OPENCL_ENV_PARAM_PLATFORM_VENDOR,
129         sizeof(char *),&name,exception);
130       if (name != (char *) NULL)
131       {
132         (void) SetEnvironmentVariable("DCR_CL_PLATFORM",name);
133         name=RelinquishMagickMemory(name);
134       }
135       GetMagickOpenCLEnvParam(clEnv,MAGICK_OPENCL_ENV_PARAM_DEVICE_NAME,
136         sizeof(char *),&name,exception);
137       if (name != (char *) NULL)
138       {
139         (void) SetEnvironmentVariable("DCR_CL_DEVICE",name);
140         name=RelinquishMagickMemory(name);
141       }
142     }
143 }
144 #else
145 #if !defined(MAGICKCORE_RAW_R_DELEGATE)
InitializeDcrawOpenCL(ExceptionInfo * magick_unused (exception))146 static void InitializeDcrawOpenCL(ExceptionInfo *magick_unused(exception))
147 {
148   magick_unreferenced(exception);
149 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
150   (void) SetEnvironmentVariable("DCR_CL_DISABLED","1");
151 #endif
152 }
153 #endif
154 #endif
155 
156 #if defined(MAGICKCORE_RAW_R_DELEGATE)
SetDNGProperties(Image * image,const libraw_data_t * raw_info)157 static void SetDNGProperties(Image *image,const libraw_data_t *raw_info)
158 {
159   char
160     property[MagickPathExtent],
161     timestamp[MagickPathExtent];
162 
163   (void) SetImageProperty(image,"dng:make",raw_info->idata.make);
164   (void) SetImageProperty(image,"dng:camera.model.name",raw_info->idata.model);
165   (void) FormatMagickTime(raw_info->other.timestamp,MagickPathExtent,timestamp);
166   (void) SetImageProperty(image,"dng:create.date",timestamp);
167   (void) SetImageProperty(image,"dng:f.number",property);
168   (void) FormatLocaleString(property,MagickPathExtent,"%0.1f",
169     raw_info->other.iso_speed);
170 #if LIBRAW_COMPILE_CHECK_VERSION_NOTLESS(0,18)
171   (void) SetImageProperty(image,"dng:software",raw_info->idata.software);
172   if (*raw_info->shootinginfo.BodySerial != '\0')
173     (void) SetImageProperty(image,"dng:serial.number",
174       raw_info->shootinginfo.BodySerial);
175   (void) FormatLocaleString(property,MagickPathExtent,"1/%0.1f",
176     PerceptibleReciprocal(raw_info->other.shutter));
177   (void) SetImageProperty(image,"dng:exposure.time",property);
178   (void) FormatLocaleString(property,MagickPathExtent,"%0.1f",
179     raw_info->other.aperture);
180   (void) SetImageProperty(image,"dng:iso.setting",property);
181   (void) FormatLocaleString(property,MagickPathExtent,"%0.1f",
182     raw_info->lens.EXIF_MaxAp);
183   (void) SetImageProperty(image,"dng:max.aperture.value",property);
184   (void) FormatLocaleString(property,MagickPathExtent,"%0.1f",
185     raw_info->other.focal_len);
186   (void) SetImageProperty(image,"dng:focal.length",property);
187   (void) FormatLocaleString(property,MagickPathExtent,"%f %f %f %f",
188     raw_info->color.cam_mul[0],raw_info->color.cam_mul[2],
189     raw_info->color.cam_mul[1],raw_info->color.cam_mul[3]);
190   (void) SetImageProperty(image,"dng:wb.rb.levels",property);
191   (void) FormatLocaleString(property,MagickPathExtent,
192     "%0.1f-%0.1fmm f/%0.1f-%0.1f",raw_info->lens.makernotes.MinFocal,
193     raw_info->lens.makernotes.MaxFocal,raw_info->lens.makernotes.MaxAp4MinFocal,
194     raw_info->lens.makernotes.MaxAp4MaxFocal);
195   (void) SetImageProperty(image,"dng:lens",property);
196   (void) FormatLocaleString(property,MagickPathExtent,"%0.2f",
197     raw_info->lens.makernotes.LensFStops);
198   (void) SetImageProperty(image,"dng:lens.f.stops",property);
199   (void) FormatLocaleString(property,MagickPathExtent,"%0.1f mm",
200     raw_info->lens.makernotes.MinFocal);
201   (void) SetImageProperty(image,"dng:min.focal.length",property);
202   (void) FormatLocaleString(property,MagickPathExtent,"%0.1f mm",
203     raw_info->lens.makernotes.MaxFocal);
204   (void) SetImageProperty(image,"dng:max.focal.length",property);
205   (void) SetImageProperty(image,"dng:max.aperture.at.min.focal",property);
206   (void) FormatLocaleString(property,MagickPathExtent,"%0.1f",
207     raw_info->lens.makernotes.MaxAp4MaxFocal);
208   (void) SetImageProperty(image,"dng:max.aperture.at.max.focal",property);
209   (void) FormatLocaleString(property,MagickPathExtent,"%d mm",
210     raw_info->lens.FocalLengthIn35mmFormat);
211   (void) SetImageProperty(image,"dng:focal.length.in.35mm.format",property);
212 #endif
213 }
214 
LibRawDataError(void * data,const char * magick_unused (file),const int offset)215 static void LibRawDataError(void *data,const char *magick_unused(file),
216   const int offset)
217 {
218   magick_unreferenced(file);
219   /* Value below zero is an EOF and an exception will be raised instead */
220   if (offset >= 0)
221     {
222       ExceptionInfo
223         *exception;
224 
225       exception=(ExceptionInfo *) data;
226       (void) ThrowMagickException(exception,GetMagickModule(),
227         CorruptImageWarning,"Data corrupted at","`%d'",offset);
228   }
229 }
230 #endif
231 
ReadDNGImage(const ImageInfo * image_info,ExceptionInfo * exception)232 static Image *ReadDNGImage(const ImageInfo *image_info,ExceptionInfo *exception)
233 {
234   Image
235     *image;
236 
237   MagickBooleanType
238     status;
239 
240   /*
241     Open image file.
242   */
243   assert(image_info != (const ImageInfo *) NULL);
244   assert(image_info->signature == MagickCoreSignature);
245   if (image_info->debug != MagickFalse)
246     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
247       image_info->filename);
248   assert(exception != (ExceptionInfo *) NULL);
249   assert(exception->signature == MagickCoreSignature);
250   image=AcquireImage(image_info);
251   status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
252   if (status == MagickFalse)
253     {
254       image=DestroyImageList(image);
255       return((Image *) NULL);
256     }
257   (void) CloseBlob(image);
258 #if defined(MAGICKCORE_RAW_R_DELEGATE)
259   {
260     int
261       errcode;
262 
263     libraw_data_t
264       *raw_info;
265 
266     libraw_processed_image_t
267       *raw_image;
268 
269     ssize_t
270       y;
271 
272     StringInfo
273       *profile;
274 
275     unsigned short
276       *p;
277 
278     errcode=0;
279     raw_info=libraw_init(LIBRAW_OPIONS_NO_MEMERR_CALLBACK |
280       LIBRAW_OPIONS_NO_DATAERR_CALLBACK);
281     if (raw_info == (libraw_data_t *) NULL)
282       {
283         (void) ThrowMagickException(exception,GetMagickModule(),CoderError,
284           libraw_strerror(errcode),"`%s'",image->filename);
285         libraw_close(raw_info);
286         return(DestroyImageList(image));
287       }
288     libraw_set_dataerror_handler(raw_info,LibRawDataError,exception);
289     raw_info->params.use_camera_wb=IsStringTrue(GetImageOption(image_info,
290       "dng:use-camera-wb"));
291 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && defined(_MSC_VER) && (_MSC_VER > 1310)
292     {
293       wchar_t
294         fileName[MagickPathExtent];
295 
296       MultiByteToWideChar(CP_UTF8,0,image->filename,-1,fileName,
297         MagickPathExtent);
298       errcode=libraw_open_wfile(raw_info,fileName);
299     }
300 #else
301     errcode=libraw_open_file(raw_info,image->filename);
302 #endif
303     if (errcode != LIBRAW_SUCCESS)
304       {
305         (void) ThrowMagickException(exception,GetMagickModule(),CoderError,
306           libraw_strerror(errcode),"`%s'",image->filename);
307         libraw_close(raw_info);
308         return(DestroyImageList(image));
309       }
310     image->columns=raw_info->sizes.width;
311     image->rows=raw_info->sizes.height;
312     image->page.width=raw_info->sizes.raw_width;
313     image->page.height=raw_info->sizes.raw_height;
314     image->page.x=raw_info->sizes.left_margin;
315     image->page.y=raw_info->sizes.top_margin;
316     if (image_info->ping != MagickFalse)
317       {
318         libraw_close(raw_info);
319         return(image);
320       }
321     status=SetImageExtent(image,image->columns,image->rows);
322     if (status == MagickFalse)
323       {
324         libraw_close(raw_info);
325         return(image);
326       }
327     errcode=libraw_unpack(raw_info);
328     if (errcode != LIBRAW_SUCCESS)
329       {
330         (void) ThrowMagickException(exception,GetMagickModule(),CoderError,
331           libraw_strerror(errcode),"`%s'",image->filename);
332         libraw_close(raw_info);
333         return(DestroyImageList(image));
334       }
335     raw_info->params.output_bps=16;
336     errcode=libraw_dcraw_process(raw_info);
337     if (errcode != LIBRAW_SUCCESS)
338       {
339         (void) ThrowMagickException(exception,GetMagickModule(),CoderError,
340           libraw_strerror(errcode),"`%s'",image->filename);
341         libraw_close(raw_info);
342         return(DestroyImageList(image));
343       }
344     raw_image=libraw_dcraw_make_mem_image(raw_info,&errcode);
345     if ((errcode != LIBRAW_SUCCESS) ||
346         (raw_image == (libraw_processed_image_t *) NULL) ||
347         (raw_image->type != LIBRAW_IMAGE_BITMAP) || (raw_image->bits != 16) ||
348         (raw_image->colors < 3) || (raw_image->colors > 4))
349       {
350         if (raw_image != (libraw_processed_image_t *) NULL)
351           libraw_dcraw_clear_mem(raw_image);
352         (void) ThrowMagickException(exception,GetMagickModule(),CoderError,
353           libraw_strerror(errcode),"`%s'",image->filename);
354         libraw_close(raw_info);
355         return(DestroyImageList(image));
356       }
357     image->columns=raw_image->width;
358     image->rows=raw_image->height;
359     image->depth=raw_image->bits;
360     image->page.width=raw_info->sizes.width;
361     image->page.height=raw_info->sizes.height;
362     image->page.x=raw_info->sizes.left_margin;
363     image->page.y=raw_info->sizes.top_margin;
364     status=SetImageExtent(image,image->columns,image->rows);
365     if (status == MagickFalse)
366       {
367         libraw_dcraw_clear_mem(raw_image);
368         libraw_close(raw_info);
369         return(DestroyImageList(image));
370       }
371     p=(unsigned short *) raw_image->data;
372     for (y=0; y < (ssize_t) image->rows; y++)
373     {
374       PixelPacket
375         *q;
376 
377       ssize_t
378         x;
379 
380       q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
381       if (q == (PixelPacket *) NULL)
382         break;
383       for (x=0; x < (ssize_t) image->columns; x++)
384       {
385         SetPixelRed(q,ScaleShortToQuantum(*p++));
386         SetPixelGreen(q,ScaleShortToQuantum(*p++));
387         SetPixelBlue(q,ScaleShortToQuantum(*p++));
388         if (raw_image->colors > 3)
389           SetPixelAlpha(q,ScaleShortToQuantum(*p++));
390         q++;
391       }
392       if (SyncAuthenticPixels(image,exception) == MagickFalse)
393         break;
394       if (image->previous == (Image *) NULL)
395         {
396           status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
397             image->rows);
398           if (status == MagickFalse)
399             break;
400         }
401     }
402     libraw_dcraw_clear_mem(raw_image);
403     /*
404       Set DNG image metadata.
405     */
406     if (raw_info->color.profile != NULL)
407       {
408         profile=BlobToStringInfo(raw_info->color.profile,
409           raw_info->color.profile_length);
410         if (profile != (StringInfo *) NULL)
411           {
412             SetImageProfile(image,"ICC",profile);
413             profile=DestroyStringInfo(profile);
414           }
415       }
416 #if LIBRAW_COMPILE_CHECK_VERSION_NOTLESS(0,18)
417     if (raw_info->idata.xmpdata != NULL)
418       {
419         profile=BlobToStringInfo(raw_info->idata.xmpdata,
420           raw_info->idata.xmplen);
421         if (profile != (StringInfo *) NULL)
422           {
423             SetImageProfile(image,"XMP",profile);
424             profile=DestroyStringInfo(profile);
425           }
426       }
427 #endif
428     SetDNGProperties(image,raw_info);
429     libraw_close(raw_info);
430     return(image);
431   }
432 #else
433   {
434     ExceptionInfo
435       *sans_exception;
436 
437     ImageInfo
438       *read_info;
439 
440     /*
441       Convert DNG to PPM with delegate.
442     */
443     (void) DestroyImageList(image);
444     InitializeDcrawOpenCL(exception);
445     image=AcquireImage(image_info);
446     read_info=CloneImageInfo(image_info);
447     SetImageInfoBlob(read_info,(void *) NULL,0);
448     (void) InvokeDelegate(read_info,image,"dng:decode",(char *) NULL,exception);
449     image=DestroyImage(image);
450     (void) FormatLocaleString(read_info->filename,MaxTextExtent,"%s.png",
451       read_info->unique);
452     sans_exception=AcquireExceptionInfo();
453     image=ReadImage(read_info,sans_exception);
454     sans_exception=DestroyExceptionInfo(sans_exception);
455     if (image == (Image *) NULL)
456       {
457         (void) FormatLocaleString(read_info->filename,MaxTextExtent,"%s.ppm",
458           read_info->unique);
459         image=ReadImage(read_info,exception);
460       }
461     (void) RelinquishUniqueFileResource(read_info->filename);
462     if (image != (Image *) NULL)
463       {
464         char
465           filename[MaxTextExtent],
466           *xml;
467 
468         ExceptionInfo
469           *sans;
470 
471         (void) CopyMagickString(image->magick,read_info->magick,MaxTextExtent);
472         (void) FormatLocaleString(filename,MaxTextExtent,"%s.ufraw",
473           read_info->unique);
474         sans=AcquireExceptionInfo();
475         xml=FileToString(filename,MaxTextExtent,sans);
476         (void) RelinquishUniqueFileResource(filename);
477         if (xml != (char *) NULL)
478           {
479             XMLTreeInfo
480               *ufraw;
481 
482             /*
483               Inject.
484             */
485             ufraw=NewXMLTree(xml,sans);
486             if (ufraw != (XMLTreeInfo *) NULL)
487               {
488                 char
489                   *content,
490                   property[MaxTextExtent];
491 
492                 const char
493                   *tag;
494 
495                 XMLTreeInfo
496                   *next;
497 
498                 if (image->properties == (void *) NULL)
499                   ((Image *) image)->properties=NewSplayTree(
500                     CompareSplayTreeString,RelinquishMagickMemory,
501                     RelinquishMagickMemory);
502                 next=GetXMLTreeChild(ufraw,(const char *) NULL);
503                 while (next != (XMLTreeInfo *) NULL)
504                 {
505                   tag=GetXMLTreeTag(next);
506                   if (tag == (char *) NULL)
507                     tag="unknown";
508                   (void) FormatLocaleString(property,MaxTextExtent,"dng:%s",
509                     tag);
510                   content=ConstantString(GetXMLTreeContent(next));
511                   StripString(content);
512                   if ((LocaleCompare(tag,"log") != 0) &&
513                       (LocaleCompare(tag,"InputFilename") != 0) &&
514                       (LocaleCompare(tag,"OutputFilename") != 0) &&
515                       (LocaleCompare(tag,"OutputType") != 0) &&
516                       (strlen(content) != 0))
517                     (void) AddValueToSplayTree((SplayTreeInfo *)
518                       ((Image *) image)->properties,ConstantString(property),
519                       content);
520                   next=GetXMLTreeSibling(next);
521                 }
522                 ufraw=DestroyXMLTree(ufraw);
523               }
524             xml=DestroyString(xml);
525           }
526         sans=DestroyExceptionInfo(sans);
527       }
528     read_info=DestroyImageInfo(read_info);
529     return(image);
530   }
531 #endif
532 }
533 
534 /*
535 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
536 %                                                                             %
537 %                                                                             %
538 %                                                                             %
539 %   R e g i s t e r D N G I m a g e                                           %
540 %                                                                             %
541 %                                                                             %
542 %                                                                             %
543 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
544 %
545 %  RegisterDNGImage() adds attributes for the DNG image format to
546 %  the list of supported formats.  The attributes include the image format
547 %  tag, a method to read and/or write the format, whether the format
548 %  supports the saving of more than one frame to the same file or blob,
549 %  whether the format supports native in-memory I/O, and a brief
550 %  description of the format.
551 %
552 %  The format of the RegisterDNGImage method is:
553 %
554 %      size_t RegisterDNGImage(void)
555 %
556 */
RegisterDNGImage(void)557 ModuleExport size_t RegisterDNGImage(void)
558 {
559   MagickInfo
560     *entry;
561 
562   entry=SetMagickInfo("3FR");
563   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
564   entry->seekable_stream=MagickTrue;
565   entry->blob_support=MagickFalse;
566   entry->seekable_stream=MagickTrue;
567   entry->format_type=ExplicitFormatType;
568   entry->description=ConstantString("Hasselblad CFV/H3D39II");
569   entry->magick_module=ConstantString("DNG");
570   (void) RegisterMagickInfo(entry);
571   entry=SetMagickInfo("ARW");
572   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
573   entry->seekable_stream=MagickTrue;
574   entry->blob_support=MagickFalse;
575   entry->seekable_stream=MagickTrue;
576   entry->format_type=ExplicitFormatType;
577   entry->description=ConstantString("Sony Alpha Raw Image Format");
578   entry->magick_module=ConstantString("DNG");
579   (void) RegisterMagickInfo(entry);
580   entry=SetMagickInfo("DNG");
581   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
582   entry->seekable_stream=MagickTrue;
583   entry->blob_support=MagickFalse;
584   entry->seekable_stream=MagickTrue;
585   entry->format_type=ExplicitFormatType;
586   entry->description=ConstantString("Digital Negative");
587   entry->magick_module=ConstantString("DNG");
588   (void) RegisterMagickInfo(entry);
589   entry=SetMagickInfo("CR2");
590   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
591   entry->seekable_stream=MagickTrue;
592   entry->blob_support=MagickFalse;
593   entry->seekable_stream=MagickTrue;
594   entry->format_type=ExplicitFormatType;
595   entry->description=ConstantString("Canon Digital Camera Raw Image Format");
596   entry->magick_module=ConstantString("DNG");
597   (void) RegisterMagickInfo(entry);
598   entry=SetMagickInfo("CR3");
599   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
600   entry->seekable_stream=MagickTrue;
601   entry->blob_support=MagickFalse;
602   entry->seekable_stream=MagickTrue;
603   entry->format_type=ExplicitFormatType;
604   entry->description=ConstantString("Canon Digital Camera Raw Image Format");
605   entry->magick_module=ConstantString("DNG");
606   (void) RegisterMagickInfo(entry);
607   entry=SetMagickInfo("CRW");
608   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
609   entry->seekable_stream=MagickTrue;
610   entry->blob_support=MagickFalse;
611   entry->seekable_stream=MagickTrue;
612   entry->format_type=ExplicitFormatType;
613   entry->description=ConstantString("Canon Digital Camera Raw Image Format");
614   entry->magick_module=ConstantString("DNG");
615   (void) RegisterMagickInfo(entry);
616   entry=SetMagickInfo("DCR");
617   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
618   entry->seekable_stream=MagickTrue;
619   entry->blob_support=MagickFalse;
620   entry->seekable_stream=MagickTrue;
621   entry->format_type=ExplicitFormatType;
622   entry->description=ConstantString("Kodak Digital Camera Raw Image File");
623   entry->magick_module=ConstantString("DNG");
624   (void) RegisterMagickInfo(entry);
625   entry=SetMagickInfo("ERF");
626   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
627   entry->seekable_stream=MagickTrue;
628   entry->blob_support=MagickFalse;
629   entry->seekable_stream=MagickTrue;
630   entry->format_type=ExplicitFormatType;
631   entry->description=ConstantString("Epson Raw Format");
632   entry->magick_module=ConstantString("DNG");
633   (void) RegisterMagickInfo(entry);
634   entry=SetMagickInfo("IIQ");
635   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
636   entry->seekable_stream=MagickTrue;
637   entry->blob_support=MagickFalse;
638   entry->seekable_stream=MagickTrue;
639   entry->format_type=ExplicitFormatType;
640   entry->description=ConstantString("Phase One Raw Image Format");
641   entry->magick_module=ConstantString("DNG");
642   (void) RegisterMagickInfo(entry);
643   entry=SetMagickInfo("KDC");
644   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
645   entry->seekable_stream=MagickTrue;
646   entry->blob_support=MagickFalse;
647   entry->seekable_stream=MagickTrue;
648   entry->format_type=ExplicitFormatType;
649   entry->description=ConstantString("Kodak Digital Camera Raw Image Format");
650   entry->magick_module=ConstantString("DNG");
651   (void) RegisterMagickInfo(entry);
652   entry=SetMagickInfo("K25");
653   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
654   entry->seekable_stream=MagickTrue;
655   entry->blob_support=MagickFalse;
656   entry->seekable_stream=MagickTrue;
657   entry->format_type=ExplicitFormatType;
658   entry->description=ConstantString("Kodak Digital Camera Raw Image Format");
659   entry->magick_module=ConstantString("DNG");
660   (void) RegisterMagickInfo(entry);
661   entry=SetMagickInfo("MEF");
662   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
663   entry->seekable_stream=MagickTrue;
664   entry->blob_support=MagickFalse;
665   entry->seekable_stream=MagickTrue;
666   entry->format_type=ExplicitFormatType;
667   entry->description=ConstantString("Mamiya Raw Image File");
668   entry->magick_module=ConstantString("DNG");
669   (void) RegisterMagickInfo(entry);
670   entry=SetMagickInfo("MRW");
671   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
672   entry->seekable_stream=MagickTrue;
673   entry->blob_support=MagickFalse;
674   entry->seekable_stream=MagickTrue;
675   entry->format_type=ExplicitFormatType;
676   entry->description=ConstantString("Sony (Minolta) Raw Image File");
677   entry->magick_module=ConstantString("DNG");
678   (void) RegisterMagickInfo(entry);
679   entry=SetMagickInfo("NEF");
680   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
681   entry->seekable_stream=MagickTrue;
682   entry->blob_support=MagickFalse;
683   entry->seekable_stream=MagickTrue;
684   entry->format_type=ExplicitFormatType;
685   entry->description=ConstantString("Nikon Digital SLR Camera Raw Image File");
686   entry->magick_module=ConstantString("DNG");
687   (void) RegisterMagickInfo(entry);
688   entry=SetMagickInfo("NRW");
689   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
690   entry->seekable_stream=MagickTrue;
691   entry->blob_support=MagickFalse;
692   entry->seekable_stream=MagickTrue;
693   entry->format_type=ExplicitFormatType;
694   entry->description=ConstantString("Nikon Digital SLR Camera Raw Image File");
695   entry->magick_module=ConstantString("DNG");
696   (void) RegisterMagickInfo(entry);
697   entry=SetMagickInfo("ORF");
698   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
699   entry->seekable_stream=MagickTrue;
700   entry->blob_support=MagickFalse;
701   entry->seekable_stream=MagickTrue;
702   entry->format_type=ExplicitFormatType;
703   entry->description=ConstantString("Olympus Digital Camera Raw Image File");
704   entry->magick_module=ConstantString("DNG");
705   (void) RegisterMagickInfo(entry);
706   entry=SetMagickInfo("PEF");
707   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
708   entry->seekable_stream=MagickTrue;
709   entry->blob_support=MagickFalse;
710   entry->seekable_stream=MagickTrue;
711   entry->format_type=ExplicitFormatType;
712   entry->description=ConstantString("Pentax Electronic File");
713   entry->magick_module=ConstantString("DNG");
714   (void) RegisterMagickInfo(entry);
715   entry=SetMagickInfo("RAF");
716   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
717   entry->seekable_stream=MagickTrue;
718   entry->blob_support=MagickFalse;
719   entry->seekable_stream=MagickTrue;
720   entry->format_type=ExplicitFormatType;
721   entry->description=ConstantString("Fuji CCD-RAW Graphic File");
722   entry->magick_module=ConstantString("DNG");
723   (void) RegisterMagickInfo(entry);
724   entry=SetMagickInfo("RAW");
725   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
726   entry->seekable_stream=MagickTrue;
727   entry->blob_support=MagickFalse;
728   entry->seekable_stream=MagickTrue;
729   entry->format_type=ExplicitFormatType;
730   entry->description=ConstantString("Raw");
731   entry->magick_module=ConstantString("DNG");
732   (void) RegisterMagickInfo(entry);
733   entry=SetMagickInfo("RMF");
734   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
735   entry->seekable_stream=MagickTrue;
736   entry->blob_support=MagickFalse;
737   entry->seekable_stream=MagickTrue;
738   entry->format_type=ExplicitFormatType;
739   entry->description=ConstantString("Raw Media Format");
740   entry->magick_module=ConstantString("DNG");
741   (void) RegisterMagickInfo(entry);
742   entry=SetMagickInfo("RW2");
743   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
744   entry->seekable_stream=MagickTrue;
745   entry->blob_support=MagickFalse;
746   entry->seekable_stream=MagickTrue;
747   entry->format_type=ExplicitFormatType;
748   entry->description=ConstantString("Panasonic Lumix Raw Image");
749   entry->magick_module=ConstantString("DNG");
750   (void) RegisterMagickInfo(entry);
751   entry=SetMagickInfo("SRF");
752   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
753   entry->seekable_stream=MagickTrue;
754   entry->blob_support=MagickFalse;
755   entry->seekable_stream=MagickTrue;
756   entry->format_type=ExplicitFormatType;
757   entry->description=ConstantString("Sony Raw Format");
758   entry->magick_module=ConstantString("DNG");
759   (void) RegisterMagickInfo(entry);
760   entry=SetMagickInfo("SR2");
761   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
762   entry->seekable_stream=MagickTrue;
763   entry->blob_support=MagickFalse;
764   entry->seekable_stream=MagickTrue;
765   entry->format_type=ExplicitFormatType;
766   entry->description=ConstantString("Sony Raw Format 2");
767   entry->magick_module=ConstantString("DNG");
768   (void) RegisterMagickInfo(entry);
769   entry=SetMagickInfo("X3F");
770   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
771   entry->seekable_stream=MagickTrue;
772   entry->blob_support=MagickFalse;
773   entry->format_type=ExplicitFormatType;
774   entry->description=ConstantString("Sigma Camera RAW Picture File");
775   entry->magick_module=ConstantString("DNG");
776   (void) RegisterMagickInfo(entry);
777   return(MagickImageCoderSignature);
778 }
779 
780 /*
781 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
782 %                                                                             %
783 %                                                                             %
784 %                                                                             %
785 %   U n r e g i s t e r D N G I m a g e                                       %
786 %                                                                             %
787 %                                                                             %
788 %                                                                             %
789 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
790 %
791 %  UnregisterDNGImage() removes format registrations made by the
792 %  BIM module from the list of supported formats.
793 %
794 %  The format of the UnregisterBIMImage method is:
795 %
796 %      UnregisterDNGImage(void)
797 %
798 */
UnregisterDNGImage(void)799 ModuleExport void UnregisterDNGImage(void)
800 {
801   (void) UnregisterMagickInfo("X3F");
802   (void) UnregisterMagickInfo("SR2");
803   (void) UnregisterMagickInfo("SRF");
804   (void) UnregisterMagickInfo("RW2");
805   (void) UnregisterMagickInfo("RMF");
806   (void) UnregisterMagickInfo("RAW");
807   (void) UnregisterMagickInfo("RAF");
808   (void) UnregisterMagickInfo("PEF");
809   (void) UnregisterMagickInfo("ORF");
810   (void) UnregisterMagickInfo("NRW");
811   (void) UnregisterMagickInfo("NEF");
812   (void) UnregisterMagickInfo("MRW");
813   (void) UnregisterMagickInfo("MEF");
814   (void) UnregisterMagickInfo("K25");
815   (void) UnregisterMagickInfo("KDC");
816   (void) UnregisterMagickInfo("IIQ");
817   (void) UnregisterMagickInfo("ERF");
818   (void) UnregisterMagickInfo("DCR");
819   (void) UnregisterMagickInfo("CRW");
820   (void) UnregisterMagickInfo("CR3");
821   (void) UnregisterMagickInfo("CR2");
822   (void) UnregisterMagickInfo("DNG");
823   (void) UnregisterMagickInfo("ARW");
824   (void) UnregisterMagickInfo("3FR");
825 }
826