]> granicus.if.org Git - imagemagick/blobdiff - coders/dng.c
...
[imagemagick] / coders / dng.c
index ac6d5c0b79e52e9f641ee7c484120215d3ddc628..c306a661188879939318dc1e868fc0b4bf6d6de6 100644 (file)
@@ -17,7 +17,7 @@
 %                                 July 1999                                   %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2017 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2018 ImageMagick Studio LLC, a non-profit organization      %
 %  dedicated to making software imaging solutions freely available.           %
 %                                                                             %
 %  You may not use this file except in compliance with the License.  You may  %
@@ -168,12 +168,15 @@ static void SetDNGProperties(Image *image,const libraw_data_t *raw_info,
 
   (void) SetImageProperty(image,"dng:make",raw_info->idata.make,exception);
   (void) SetImageProperty(image,"dng:camera.model.name",raw_info->idata.model,
-     exception);
-  (void) SetImageProperty(image,"dng:software",raw_info->idata.software,
     exception);
   (void) FormatMagickTime(raw_info->other.timestamp,MagickPathExtent,timestamp);
   (void) SetImageProperty(image,"dng:create.date",timestamp,exception);
+  (void) FormatLocaleString(property,MagickPathExtent,"%0.1f",
+    raw_info->other.iso_speed);
+  (void) SetImageProperty(image,"dng:iso.setting",property,exception);
 #if LIBRAW_COMPILE_CHECK_VERSION_NOTLESS(0,18)
+  (void) SetImageProperty(image,"dng:software",raw_info->idata.software,
+    exception);
   if (*raw_info->shootinginfo.BodySerial != '\0')
     (void) SetImageProperty(image,"dng:serial.number",
       raw_info->shootinginfo.BodySerial,exception);
@@ -181,16 +184,12 @@ static void SetDNGProperties(Image *image,const libraw_data_t *raw_info,
     raw_info->other.FlashEC);
   (void) SetImageProperty(image,"dng:flash.exposure.compensation",property,
     exception);
-#endif
   (void) FormatLocaleString(property,MagickPathExtent,"1/%0.1f",
     1.0/raw_info->other.shutter);
   (void) SetImageProperty(image,"dng:exposure.time",property,exception);
   (void) FormatLocaleString(property,MagickPathExtent,"%0.1f",
     raw_info->other.aperture);
   (void) SetImageProperty(image,"dng:f.number",property,exception);
-  (void) FormatLocaleString(property,MagickPathExtent,"%0.1f",
-    raw_info->other.iso_speed);
-  (void) SetImageProperty(image,"dng:iso.setting",property,exception);
   (void) FormatLocaleString(property,MagickPathExtent,"%0.1f",
     raw_info->lens.EXIF_MaxAp);
   (void) SetImageProperty(image,"dng:max.aperture.value",property,exception);
@@ -203,18 +202,19 @@ static void SetDNGProperties(Image *image,const libraw_data_t *raw_info,
   (void) SetImageProperty(image,"dng:wb.rb.levels",property,exception);
   (void) SetImageProperty(image,"dng:lens.type",
     raw_info->lens.makernotes.LensFeatures_suf,exception);
-  (void) FormatLocaleString(property,MagickPathExtent,"%f-%fmm f/%0.1f-%0.1f",
-    raw_info->lens.makernotes.MinFocal,raw_info->lens.makernotes.MaxFocal,
+  (void) FormatLocaleString(property,MagickPathExtent,
+    "%0.1f-%0.1fmm f/%0.1f-%0.1f",raw_info->lens.makernotes.MinFocal,
+    raw_info->lens.makernotes.MaxFocal,
     raw_info->lens.makernotes.MaxAp4MinFocal,
     raw_info->lens.makernotes.MaxAp4MaxFocal);
   (void) SetImageProperty(image,"dng:lens",property,exception);
   (void) FormatLocaleString(property,MagickPathExtent,"%0.2f",
     raw_info->lens.makernotes.LensFStops);
   (void) SetImageProperty(image,"dng:lens.f.stops",property,exception);
-  (void) FormatLocaleString(property,MagickPathExtent,"%f mm",
+  (void) FormatLocaleString(property,MagickPathExtent,"%0.1f mm",
     raw_info->lens.makernotes.MinFocal);
   (void) SetImageProperty(image,"dng:min.focal.length",property,exception);
-  (void) FormatLocaleString(property,MagickPathExtent,"%f mm",
+  (void) FormatLocaleString(property,MagickPathExtent,"%0.1f mm",
     raw_info->lens.makernotes.MaxFocal);
   (void) SetImageProperty(image,"dng:max.focal.length",property,exception);
   (void) FormatLocaleString(property,MagickPathExtent,"%0.1f",
@@ -229,6 +229,7 @@ static void SetDNGProperties(Image *image,const libraw_data_t *raw_info,
     raw_info->lens.FocalLengthIn35mmFormat);
   (void) SetImageProperty(image,"dng:focal.length.in.35mm.format",property,
     exception);
+#endif
 }
 #endif
 
@@ -304,6 +305,17 @@ static Image *ReadDNGImage(const ImageInfo *image_info,ExceptionInfo *exception)
           libraw_strerror(errcode),"`%s'",image->filename);
         return(DestroyImageList(image));
       }
+    image->columns=raw_info->sizes.width;
+    image->rows=raw_info->sizes.height;
+    image->page.width=raw_info->sizes.raw_width;
+    image->page.height=raw_info->sizes.raw_height;
+    image->page.x=raw_info->sizes.left_margin;
+    image->page.y=raw_info->sizes.top_margin;
+    if (image_info->ping != MagickFalse)
+      {
+        libraw_close(raw_info);
+        return(image);
+      }
     errcode=libraw_unpack(raw_info);
     if (errcode != LIBRAW_SUCCESS)
       {
@@ -344,12 +356,6 @@ static Image *ReadDNGImage(const ImageInfo *image_info,ExceptionInfo *exception)
         libraw_close(raw_info);
         return(DestroyImageList(image));
       }
-    if (image_info->ping != MagickFalse)
-      {
-        libraw_dcraw_clear_mem(raw_image);
-        libraw_close(raw_info);
-        return(image);
-      }
     p=(unsigned short *) raw_image->data;
     for (y=0; y < (ssize_t) image->rows; y++)
     {
@@ -395,6 +401,7 @@ static Image *ReadDNGImage(const ImageInfo *image_info,ExceptionInfo *exception)
             profile=DestroyStringInfo(profile);
           }
       }
+#if LIBRAW_COMPILE_CHECK_VERSION_NOTLESS(0,18)
     if (raw_info->idata.xmpdata)
       {
         profile=BlobToStringInfo(raw_info->idata.xmpdata,
@@ -405,6 +412,7 @@ static Image *ReadDNGImage(const ImageInfo *image_info,ExceptionInfo *exception)
             profile=DestroyStringInfo(profile);
           }
       }
+#endif
     SetDNGProperties(image,raw_info,exception);
     libraw_close(raw_info);
     return(image);