]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Thu, 1 Mar 2012 01:41:41 +0000 (01:41 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Thu, 1 Mar 2012 01:41:41 +0000 (01:41 +0000)
25 files changed:
MagickCore/constitute.c
MagickCore/constitute.h
MagickCore/method-attribute.h
MagickCore/version.h
MagickCore/xml-tree-private.h
MagickCore/xml-tree.c
MagickCore/xml-tree.h
MagickWand/animate.c
MagickWand/compare.c
MagickWand/composite.c
MagickWand/conjure.c
MagickWand/convert.c
MagickWand/identify.c
MagickWand/method-attribute.h
MagickWand/mogrify.c
MagickWand/montage.c
Makefile.in
PerlMagick/Magick.xs
coders/caption.c
coders/jpeg.c
coders/xtrn.c
config/ImageMagick.rdf
config/Makefile.am
config/configure.xml
configure

index 205a0c2d7b763beec0566021c3136cb12b931313..908403881b41171f44b1b8cf6d0bf95b0ff630f0 100644 (file)
@@ -296,20 +296,23 @@ MagickExport Image *PingImage(const ImageInfo *image_info,
 %
 %  The format of the PingImage method is:
 %
-%      Image *PingImages(const ImageInfo *image_info,ExceptionInfo *exception)
+%      Image *PingImages(ImageInfo *image_info,const char *filename,
+%        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
 %    o image_info: the image info.
 %
+%    o filename: the image filename.
+%
 %    o exception: return any errors or warnings in this structure.
 %
 */
-MagickExport Image *PingImages(const ImageInfo *image_info,
+MagickExport Image *PingImages(ImageInfo *image_info,const char *filename,
   ExceptionInfo *exception)
 {
   char
-    filename[MaxTextExtent];
+    ping_filename[MaxTextExtent];
 
   Image
     *image,
@@ -327,9 +330,11 @@ MagickExport Image *PingImages(const ImageInfo *image_info,
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
       image_info->filename);
   assert(exception != (ExceptionInfo *) NULL);
+  (void) SetImageOption(image_info,"filename",filename);
+  (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
   (void) InterpretImageFilename(image_info,(Image *) NULL,image_info->filename,
-    (int) image_info->scene,filename,exception);
-  if (LocaleCompare(filename,image_info->filename) != 0)
+    (int) image_info->scene,ping_filename,exception);
+  if (LocaleCompare(ping_filename,image_info->filename) != 0)
     {
       ExceptionInfo
         *sans;
@@ -345,13 +350,13 @@ MagickExport Image *PingImages(const ImageInfo *image_info,
       sans=AcquireExceptionInfo();
       (void) SetImageInfo(read_info,0,sans);
       sans=DestroyExceptionInfo(sans);
-      (void) CopyMagickString(filename,read_info->filename,MaxTextExtent);
+      (void) CopyMagickString(ping_filename,read_info->filename,MaxTextExtent);
       images=NewImageList();
       extent=(ssize_t) (read_info->scene+read_info->number_scenes);
       for (scene=(ssize_t) read_info->scene; scene < (ssize_t) extent; scene++)
       {
-        (void) InterpretImageFilename(image_info,(Image *) NULL,filename,(int)
-          scene,read_info->filename,exception);
+        (void) InterpretImageFilename(image_info,(Image *) NULL,ping_filename,
+          (int) scene,read_info->filename,exception);
         image=PingImage(read_info,exception);
         if (image == (Image *) NULL)
           continue;
@@ -810,20 +815,23 @@ MagickExport Image *ReadImage(const ImageInfo *image_info,
 %
 %  The format of the ReadImage method is:
 %
-%      Image *ReadImages(const ImageInfo *image_info,ExceptionInfo *exception)
+%      Image *ReadImages(ImageInfo *image_info,const char *filename,
+%        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
 %    o image_info: the image info.
 %
+%    o filename: the image filename.
+%
 %    o exception: return any errors or warnings in this structure.
 %
 */
-MagickExport Image *ReadImages(const ImageInfo *image_info,
+MagickExport Image *ReadImages(ImageInfo *image_info,const char *filename,
   ExceptionInfo *exception)
 {
   char
-    filename[MaxTextExtent];
+    read_filename[MaxTextExtent];
 
   Image
     *image,
@@ -841,9 +849,11 @@ MagickExport Image *ReadImages(const ImageInfo *image_info,
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
       image_info->filename);
   assert(exception != (ExceptionInfo *) NULL);
-  (void) InterpretImageFilename(image_info,(Image *) NULL,image_info->filename,
-    (int) image_info->scene,filename,exception);
-  if (LocaleCompare(filename,image_info->filename) != 0)
+  (void) SetImageOption(image_info,"filename",filename);
+  (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
+  (void) InterpretImageFilename(image_info,(Image *) NULL,filename,
+    (int) image_info->scene,read_filename,exception);
+  if (LocaleCompare(read_filename,image_info->filename) != 0)
     {
       ExceptionInfo
         *sans;
@@ -864,13 +874,13 @@ MagickExport Image *ReadImages(const ImageInfo *image_info,
           read_info=DestroyImageInfo(read_info);
           return(ReadImage(image_info,exception));
         }
-      (void) CopyMagickString(filename,read_info->filename,MaxTextExtent);
+      (void) CopyMagickString(read_filename,read_info->filename,MaxTextExtent);
       images=NewImageList();
       extent=(ssize_t) (read_info->scene+read_info->number_scenes);
       for (scene=(ssize_t) read_info->scene; scene < (ssize_t) extent; scene++)
       {
-        (void) InterpretImageFilename(image_info,(Image *) NULL,filename,(int)
-          scene,read_info->filename,exception);
+        (void) InterpretImageFilename(image_info,(Image *) NULL,read_filename,
+          (int) scene,read_info->filename,exception);
         image=ReadImage(read_info,exception);
         if (image == (Image *) NULL)
           continue;
index 33d1ac71e2a0d4835bce92025a173383bbf4f6f7..c3fe5afd39ecbb471cc0f1b484fe2e5de611686b 100644 (file)
@@ -28,9 +28,9 @@ extern MagickExport Image
   *ConstituteImage(const size_t,const size_t,const char *,const StorageType,
     const void *,ExceptionInfo *),
   *PingImage(const ImageInfo *,ExceptionInfo *),
-  *PingImages(const ImageInfo *,ExceptionInfo *),
+  *PingImages(ImageInfo *,const char *,ExceptionInfo *),
   *ReadImage(const ImageInfo *,ExceptionInfo *),
-  *ReadImages(const ImageInfo *,ExceptionInfo *),
+  *ReadImages(ImageInfo *,const char *,ExceptionInfo *),
   *ReadInlineImage(const ImageInfo *,const char *,ExceptionInfo *);
 
 extern MagickExport MagickBooleanType
index 8141794b0709b7c9cc8f44bd0e9e743e4d49d228..4b79d2a6fcaa50b3468690b6d506ae094cda0dfa 100644 (file)
@@ -105,7 +105,7 @@ extern "C" {
 
 #define MagickSignature  0xabacadabUL
 #if !defined(MaxTextExtent)
-# define MaxTextExtent  8192
+# define MaxTextExtent  4096
 #endif
 
 #if defined(MAGICKCORE_HAVE___ATTRIBUTE__)
index 813809e1b04c60a2a3427ca4274b0f4ed7005610..00d4e0af371ff83773b26e37c0bca6fb18dcbd10 100644 (file)
@@ -27,14 +27,14 @@ extern "C" {
 */
 #define MagickPackageName "ImageMagick"
 #define MagickCopyright  "Copyright (C) 1999-2012 ImageMagick Studio LLC"
-#define MagickSVNRevision  "6986"
+#define MagickSVNRevision  "6997"
 #define MagickLibVersion  0x700
 #define MagickLibVersionText  "7.0.0"
 #define MagickLibVersionNumber  7,0,0
 #define MagickLibAddendum  "-0"
 #define MagickLibInterface  7
 #define MagickLibMinInterface  7
-#define MagickReleaseDate  "2012-02-28"
+#define MagickReleaseDate  "2012-02-29"
 #define MagickChangeDate   "20110801"
 #define MagickAuthoritativeURL  "http://www.imagemagick.org"
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
index 97fdd0c58eb52bea21206ebeb7b9a6083ed472cc..74a086d229cec2929c9656d4b5102f14726fc8c5 100644 (file)
@@ -29,7 +29,6 @@ extern MagickPrivate char
   *CanonicalXMLContent(const char *,const MagickBooleanType);
 
 extern MagickPrivate const char
-  *GetXMLTreeAttribute(XMLTreeInfo *,const char *),
   **GetXMLTreeProcessingInstructions(XMLTreeInfo *,const char *);
 
 extern MagickPrivate MagickBooleanType
@@ -37,7 +36,6 @@ extern MagickPrivate MagickBooleanType
 
 extern MagickPrivate XMLTreeInfo
   *AddPathToXMLTree(XMLTreeInfo *,const char *,const size_t),
-  *GetNextXMLTreeTag(XMLTreeInfo *),
   *GetXMLTreeOrdered(XMLTreeInfo *),
   *GetXMLTreePath(XMLTreeInfo *,const char *),
   *InsertTagIntoXMLTree(XMLTreeInfo *,XMLTreeInfo *,const size_t),
index d1bcf8477b8b5571cb2b4181ef716cdfa7ccbcb8..d695547b3a20ef69ca7e228157bf95781e9d7d63 100644 (file)
@@ -550,7 +550,7 @@ MagickExport XMLTreeInfo *DestroyXMLTree(XMLTreeInfo *xml_info)
 %    o xml_info: the xml info.
 %
 */
-MagickPrivate XMLTreeInfo *GetNextXMLTreeTag(XMLTreeInfo *xml_info)
+MagickExport XMLTreeInfo *GetNextXMLTreeTag(XMLTreeInfo *xml_info)
 {
   assert(xml_info != (XMLTreeInfo *) NULL);
   assert((xml_info->signature == MagickSignature) ||
@@ -584,7 +584,7 @@ MagickPrivate XMLTreeInfo *GetNextXMLTreeTag(XMLTreeInfo *xml_info)
 %    o tag: the attribute tag.
 %
 */
-MagickPrivate const char *GetXMLTreeAttribute(XMLTreeInfo *xml_info,
+MagickExport const char *GetXMLTreeAttribute(XMLTreeInfo *xml_info,
   const char *tag)
 {
   register ssize_t
index bbcfba2d29883c543fc0df256b07eea1249d0fd0..1ad11c8c1c2372b89aac0e7982a548583473f55b 100644 (file)
@@ -29,12 +29,14 @@ extern MagickExport char
   *XMLTreeInfoToXML(XMLTreeInfo *);
 
 extern MagickExport const char
+  *GetXMLTreeAttribute(XMLTreeInfo *,const char *),
   *GetXMLTreeContent(XMLTreeInfo *),
   *GetXMLTreeTag(XMLTreeInfo *);
 
 extern MagickExport XMLTreeInfo
   *AddChildToXMLTree(XMLTreeInfo *,const char *,const size_t),
   *DestroyXMLTree(XMLTreeInfo *),
+  *GetNextXMLTreeTag(XMLTreeInfo *),
   *GetXMLTreeChild(XMLTreeInfo *,const char *),
   *GetXMLTreeSibling(XMLTreeInfo *),
   *NewXMLTree(const char *,ExceptionInfo *),
index ad20b5229ca4e04cd5afcf977afa67eb1d3e833d..b84281f051dd6135c419d21b4655c775e9aa9e02 100644 (file)
@@ -452,11 +452,10 @@ WandExport MagickBooleanType AnimateImageCommand(ImageInfo *image_info,
             option=argv[++i];
             filename=option;
           }
-        (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
         if (image_info->ping != MagickFalse)
-          images=PingImages(image_info,exception);
+          images=PingImages(image_info,filename,exception);
         else
-          images=ReadImages(image_info,exception);
+          images=ReadImages(image_info,filename,exception);
         status&=(images != (Image *) NULL) &&
           (exception->severity < ErrorException);
         if (images == (Image *) NULL)
index 2fcb7e280b1fdd25eef9f9242a783325f376d206..e27e5b1cef861afe36856cca6bef9c68578ac70e 100644 (file)
@@ -325,8 +325,7 @@ WandExport MagickBooleanType CompareImagesCommand(ImageInfo *image_info,
         filename=argv[i];
         if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
           filename=argv[++i];
-        (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
-        images=ReadImages(image_info,exception);
+        images=ReadImages(image_info,filename,exception);
         status&=(images != (Image *) NULL) &&
           (exception->severity < ErrorException);
         if (images == (Image *) NULL)
index 4649c305462deaa31e735761a52d4bd356492b6d..7da939e5ace2779dd58ff90d10cf889bb7cb0802 100644 (file)
@@ -519,8 +519,7 @@ WandExport MagickBooleanType CompositeImageCommand(ImageInfo *image_info,
         filename=argv[i];
         if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
           filename=argv[++i];
-        (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
-        images=ReadImages(image_info,exception);
+        images=ReadImages(image_info,filename,exception);
         status&=(images != (Image *) NULL) &&
           (exception->severity < ErrorException);
         if (images == (Image *) NULL)
index 83f4f3355b5006e5747150ec039028748d997ee4..139e49bf2c69585d58fb84bc0bf68aa0bd712fee 100644 (file)
@@ -155,6 +155,7 @@ WandExport MagickBooleanType ConjureImageCommand(ImageInfo *image_info,
 }
 
   char
+    filename[MaxTextExtent],
     *option;
 
   Image
@@ -293,9 +294,8 @@ WandExport MagickBooleanType ConjureImageCommand(ImageInfo *image_info,
     status=SetImageOption(image_info,"filename",argv[i]);
     if (status == MagickFalse)
       ThrowConjureException(ImageError,"UnableToPersistKey",argv[i]);
-    (void) FormatLocaleString(image_info->filename,MaxTextExtent,"msl:%s",
-      argv[i]);
-    image=ReadImages(image_info,exception);
+    (void) FormatLocaleString(filename,MaxTextExtent,"msl:%s",argv[i]);
+    image=ReadImages(image_info,filename,exception);
     CatchException(exception);
     if (image != (Image *) NULL)
       image=DestroyImageList(image);
index c643bbc2c50ac3944c7bd1e4c8767c46056214a9..e235497876831d1bb5e92f18f74d339e42458400 100644 (file)
@@ -605,11 +605,10 @@ WandExport MagickBooleanType ConvertImageCommand(ImageInfo *image_info,
         filename=argv[i];
         if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
           filename=argv[++i];
-        (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
         if (image_info->ping != MagickFalse)
-          images=PingImages(image_info,exception);
+          images=PingImages(image_info,filename,exception);
         else
-          images=ReadImages(image_info,exception);
+          images=ReadImages(image_info,filename,exception);
         status&=(images != (Image *) NULL) &&
           (exception->severity < ErrorException);
         if (images == (Image *) NULL)
index 225eb75e6395ff4cf9a9f085005bec59267df884..a2b4d7b78e15ff37d1f54730caa945dbb4821d04 100644 (file)
@@ -313,11 +313,10 @@ WandExport MagickBooleanType IdentifyImageCommand(ImageInfo *image_info,
         filename=argv[i];
         if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
           filename=argv[++i];
-        (void) CopyMagickString(identify_info->filename,filename,MaxTextExtent);
         if (identify_info->ping != MagickFalse)
-          images=PingImages(identify_info,exception);
+          images=PingImages(identify_info,filename,exception);
         else
-          images=ReadImages(identify_info,exception);
+          images=ReadImages(identify_info,filename,exception);
         identify_info=DestroyImageInfo(identify_info);
         status&=(images != (Image *) NULL) &&
           (exception->severity < ErrorException);
index aa4ac7f4f92f147689ac7b9cb9607f9b4dabc139..6bdc6e0d5011773f96237fd9b388537eb3d14c8a 100644 (file)
@@ -98,7 +98,7 @@ extern "C" {
 
 #define WandSignature  0xabacadabUL
 #if !defined(MaxTextExtent)
-# define MaxTextExtent  8192
+# define MaxTextExtent  4096
 #endif
 
 #if defined(MAGICKCORE_HAVE___ATTRIBUTE__)
index 939b941b25d2f7c17b250cc6a3851ab11984b7c1..c63d7b99154606b4a639f858d2f0f040fe3215ad 100644 (file)
@@ -3741,8 +3741,7 @@ WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
         filename=argv[i];
         if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
           filename=argv[++i];
-        (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
-        images=ReadImages(image_info,exception);
+        images=ReadImages(image_info,filename,exception);
         status&=(images != (Image *) NULL) &&
           (exception->severity < ErrorException);
         if (images == (Image *) NULL)
index 2b9a08e6b59bdaf67bc8baff82766d8cbe8eb2ab..805046aaf0296ceb079ec2ba03277a7940a3a02c 100644 (file)
@@ -408,8 +408,10 @@ WandExport MagickBooleanType MontageImageCommand(ImageInfo *image_info,
           filename=argv[i];
           if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
             filename=argv[++i];
-          (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
-          if (first_scene != last_scene)
+          (void) CloneString(&image_info->font,montage_info->font);
+          if (first_scene == last_scene)
+            images=ReadImages(image_info,filename,exception);
+          else
             {
               char
                 filename[MaxTextExtent];
@@ -422,11 +424,8 @@ WandExport MagickBooleanType MontageImageCommand(ImageInfo *image_info,
               if (LocaleCompare(filename,image_info->filename) == 0)
                 (void) FormatLocaleString(filename,MaxTextExtent,"%s.%.20g",
                   image_info->filename,(double) scene);
-              (void) CopyMagickString(image_info->filename,filename,
-                MaxTextExtent);
+              images=ReadImages(image_info,filename,exception);
             }
-          (void) CloneString(&image_info->font,montage_info->font);
-          images=ReadImages(image_info,exception);
           status&=(images != (Image *) NULL) &&
             (exception->severity < ErrorException);
           if (images == (Image *) NULL)
index ae21a882ae9abcc18c3fd795426fb490612b518d..bfdaac541c3ce89702ddfa34511bed9aebda6435 100644 (file)
@@ -2863,6 +2863,7 @@ configlib_DATA = \
        config/magic.xml \
        config/mime.xml \
        config/policy.xml \
+       config/quantization-table.xml \
        config/sRGB.icc \
        config/thresholds.xml \
        config/type.xml \
@@ -2884,6 +2885,7 @@ CONFIG_EXTRA_DIST = \
        config/magic.xml \
        config/mime.xml \
        config/policy.xml \
+       config/quantization-table.xml \
        config/sRGB.icc \
        config/thresholds.xml \
        config/type-dejavu.xml.in \
index ea378a51dfdbd9e0276a334193af0d044213d0eb..6f725a79d2f4eed0a36bfa347ef80625817f2e42 100644 (file)
@@ -9326,10 +9326,9 @@ Mogrify(ref,...)
           /*
             Associate a profile with the image.
           */
-          profile_info=
-            CloneImageInfo(info ? info->image_info : (ImageInfo *) NULL);
-          (void) CopyMagickString(profile_info->filename,name,MaxTextExtent);
-          profile_image=ReadImages(profile_info,exception);
+          profile_info=CloneImageInfo(info ? info->image_info :
+            (ImageInfo *) NULL);
+          profile_image=ReadImages(profile_info,name,exception);
           if (profile_image == (Image *) NULL)
             break;
           ResetImageProfileIterator(profile_image);
@@ -13183,19 +13182,16 @@ Read(ref,...)
     number_images=0;
     for (i=0; i < n; i++)
     {
-      if ((package_info->image_info->file != (FILE *) NULL) ||
-          (package_info->image_info->blob != (void *) NULL))
+      if ((package_info->image_info->file == (FILE *) NULL) &&
+          (package_info->image_info->blob == (void *) NULL))
+        image=ReadImages(package_info->image_info,list[i],exception);
+      else
         {
-          image=ReadImages(package_info->image_info,exception);
+          image=ReadImages(package_info->image_info,
+            package_info->image_info->filename,exception);
           if (image != (Image *) NULL)
             DisassociateImageStream(image);
         }
-      else
-        {
-          (void) CopyMagickString(package_info->image_info->filename,list[i],
-            MaxTextExtent);
-          image=ReadImages(package_info->image_info,exception);
-        }
       if (image == (Image *) NULL)
         break;
       for ( ; image; image=image->next)
index 320b559fed108bfb0bc22ed8c32cd488bfcf8181..c4510bcdbbe7e6c4a5e62aaecaa039e2e214f528 100644 (file)
@@ -266,8 +266,12 @@ static Image *ReadCAPTIONImage(const ImageInfo *image_info,
   pango_font_description_set_size(description,PANGO_SCALE*draw_info->pointsize);
   pango_layout_set_font_description(layout,description);
   pango_font_description_free(description);
-  property=InterpretImageProperties(image_info,image,image_info->filename,
-    exception);
+  option=GetImageOption(image_info,"filename");
+  if (option != (const char *) NULL) 
+    property=InterpretImageProperties(image_info,image,option,exception);
+  else
+    property=InterpretImageProperties(image_info,image,image_info->filename,
+      exception);
   (void) SetImageProperty(image,"caption",property,exception);
   property=DestroyString(property);
   caption=ConstantString(GetImageProperty(image,"caption",exception));
index 5c884999189d39b33ba8df852a5a81b94e507605..809e405d59d4483210d5e30e21caa110b9ccd7c8 100644 (file)
@@ -78,6 +78,8 @@
 #include "MagickCore/string_.h"
 #include "MagickCore/string-private.h"
 #include "MagickCore/utility.h"
+#include "MagickCore/xml-tree.h"
+#include "MagickCore/xml-tree-private.h"
 #include <setjmp.h>
 #if defined(MAGICKCORE_JPEG_DELEGATE)
 #define JPEG_INTERNAL_OPTIONS
@@ -146,6 +148,21 @@ typedef struct _SourceManager
     start_of_blob;
 } SourceManager;
 #endif
+
+typedef struct _QuantizationTable
+{
+  char
+    *slot,
+    *description;
+
+  size_t
+    width,
+    height;
+
+  unsigned int
+    divisor,
+    *levels;
+} QuantizationTable;
 \f
 /*
   Forward declarations.
@@ -674,7 +691,7 @@ static boolean ReadProfile(j_decompress_ptr jpeg_info)
   previous_profile=GetImageProfile(image,name);
   if (previous_profile != (const StringInfo *) NULL)
     {
-      ssize_t
+      size_t
         length;
 
       length=GetStringInfoLength(profile);
@@ -1249,7 +1266,8 @@ static Image *ReadJPEGImage(const ImageInfo *image_info,
       if (jpeg_info.out_color_space == JCS_GRAYSCALE)
         for (i=0; i < (ssize_t) image->colors; i++)
         {
-          image->colormap[i].red=ScaleCharToQuantum(jpeg_info.colormap[0][i]);
+          image->colormap[i].red=(double) ScaleCharToQuantum(
+            jpeg_info.colormap[0][i]);
           image->colormap[i].green=image->colormap[i].red;
           image->colormap[i].blue=image->colormap[i].red;
           image->colormap[i].alpha=OpaqueAlpha;
@@ -1257,9 +1275,12 @@ static Image *ReadJPEGImage(const ImageInfo *image_info,
       else
         for (i=0; i < (ssize_t) image->colors; i++)
         {
-          image->colormap[i].red=ScaleCharToQuantum(jpeg_info.colormap[0][i]);
-          image->colormap[i].green=ScaleCharToQuantum(jpeg_info.colormap[1][i]);
-          image->colormap[i].blue=ScaleCharToQuantum(jpeg_info.colormap[2][i]);
+          image->colormap[i].red=(double) ScaleCharToQuantum(
+            jpeg_info.colormap[0][i]);
+          image->colormap[i].green=(double) ScaleCharToQuantum(
+            jpeg_info.colormap[1][i]);
+          image->colormap[i].blue=(double) ScaleCharToQuantum(
+            jpeg_info.colormap[2][i]);
           image->colormap[i].alpha=OpaqueAlpha;
         }
     }
@@ -1526,6 +1547,19 @@ ModuleExport void UnregisterJPEGImage(void)
 %
 */
 
+static QuantizationTable *DestroyQuantizationTable(QuantizationTable *table)
+{
+  assert(table != (QuantizationTable *) NULL);
+  if (table->slot != (char *) NULL)
+    table->slot=DestroyString(table->slot);
+  if (table->description != (char *) NULL)
+    table->description=DestroyString(table->description);
+  if (table->levels != (unsigned int *) NULL)
+    table->levels=(unsigned int *) RelinquishMagickMemory(table->levels);
+  table=(QuantizationTable *) RelinquishMagickMemory(table);
+  return(table);
+}
+
 static boolean EmptyOutputBuffer(j_compress_ptr cinfo)
 {
   DestinationManager
@@ -1540,6 +1574,198 @@ static boolean EmptyOutputBuffer(j_compress_ptr cinfo)
   return(TRUE);
 }
 
+static QuantizationTable *GetQuantizationTable(const char *filename,
+  const char *slot,ExceptionInfo *exception)
+{
+  char
+    *p,
+    *xml;
+
+  const char
+    *attribute,
+    *content;
+
+  double
+    value;
+
+  register ssize_t
+    i;
+
+  ssize_t
+    j;
+
+  QuantizationTable
+    *table;
+
+  XMLTreeInfo
+    *description,
+    *levels,
+    *quantization_tables,
+    *table_iterator;
+
+  (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
+    "Loading quantization tables \"%s\" ...",filename);
+  table=(QuantizationTable *) NULL;
+  xml=FileToString(filename,~0,exception);
+  if (xml == (char *) NULL)
+    return(table);
+  quantization_tables=NewXMLTree(xml,exception);
+  if (quantization_tables == (XMLTreeInfo *) NULL)
+    {
+      xml=DestroyString(xml);
+      return(table);
+    }
+  for (table_iterator=GetXMLTreeChild(quantization_tables,"table");
+       table_iterator != (XMLTreeInfo *) NULL;
+       table_iterator=GetNextXMLTreeTag(table_iterator))
+  {
+    attribute=GetXMLTreeAttribute(table_iterator,"slot");
+    if ((attribute != (char *) NULL) && (LocaleCompare(slot,attribute) == 0))
+      break;
+    attribute=GetXMLTreeAttribute(table_iterator,"alias");
+    if ((attribute != (char *) NULL) && (LocaleCompare(slot,attribute) == 0))
+      break;
+  }
+  if (table_iterator == (XMLTreeInfo *) NULL)
+    {
+      xml=DestroyString(xml);
+      return(table);
+    }
+  description=GetXMLTreeChild(table_iterator,"description");
+  if (description == (XMLTreeInfo *) NULL)
+    {
+      (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
+        "XmlMissingElement", "<description>, slot \"%s\"",slot);
+      quantization_tables=DestroyXMLTree(quantization_tables);
+      xml=DestroyString(xml);
+      return(table);
+    }
+  levels=GetXMLTreeChild(table_iterator,"levels");
+  if (levels == (XMLTreeInfo *) NULL)
+    {
+      (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
+        "XmlMissingElement", "<levels>, slot \"%s\"", slot);
+      quantization_tables=DestroyXMLTree(quantization_tables);
+      xml=DestroyString(xml);
+      return(table);
+    }
+  table=(QuantizationTable *) AcquireMagickMemory(sizeof(*table));
+  if (table == (QuantizationTable *) NULL)
+    ThrowFatalException(ResourceLimitFatalError,
+      "UnableToAcquireQuantizationTable");
+  table->slot=(char *) NULL;
+  table->description=(char *) NULL;
+  table->levels=(unsigned int *) NULL;
+  attribute=GetXMLTreeAttribute(table_iterator,"slot");
+  if (attribute != (char *) NULL)
+    table->slot=ConstantString(attribute);
+  content=GetXMLTreeContent(description);
+  if (content != (char *) NULL)
+    table->description=ConstantString(content);
+  attribute=GetXMLTreeAttribute(levels,"width");
+  if (attribute == (char *) NULL)
+    {
+      (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
+        "XmlMissingAttribute", "<levels width>, slot \"%s\"",slot);
+      quantization_tables=DestroyXMLTree(quantization_tables);
+      table=DestroyQuantizationTable(table);
+      xml=DestroyString(xml);
+      return(table);
+    }
+  table->width=StringToUnsignedLong(attribute);
+  if (table->width == 0)
+    {
+      (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
+       "XmlInvalidAttribute", "<levels width>, table \"%s\"",slot);
+      quantization_tables=DestroyXMLTree(quantization_tables);
+      table=DestroyQuantizationTable(table);
+      xml=DestroyString(xml);
+      return(table);
+    }
+  attribute=GetXMLTreeAttribute(levels,"height");
+  if (attribute == (char *) NULL)
+    {
+      (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
+        "XmlMissingAttribute", "<levels height>, table \"%s\"",slot);
+      quantization_tables=DestroyXMLTree(quantization_tables);
+      table=DestroyQuantizationTable(table);
+      xml=DestroyString(xml);
+      return(table);
+    }
+  table->height=StringToUnsignedLong(attribute);
+  if (table->height == 0)
+    {
+      (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
+        "XmlInvalidAttribute", "<levels height>, table \"%s\"",slot);
+      quantization_tables=DestroyXMLTree(quantization_tables);
+      table=DestroyQuantizationTable(table);
+      xml=DestroyString(xml);
+      return(table);
+    }
+  attribute=GetXMLTreeAttribute(levels,"divisor");
+  if (attribute == (char *) NULL)
+    {
+      (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
+        "XmlMissingAttribute", "<levels divisor>, table \"%s\"",slot);
+      quantization_tables=DestroyXMLTree(quantization_tables);
+      table=DestroyQuantizationTable(table);
+      xml=DestroyString(xml);
+      return(table);
+    }
+  table->divisor=(unsigned int) StringToLong(attribute);
+  if (table->divisor < 1)
+    {
+      (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
+        "XmlInvalidAttribute", "<levels divisor>, table \"%s\"",slot);
+      quantization_tables=DestroyXMLTree(quantization_tables);
+      table=DestroyQuantizationTable(table);
+      xml=DestroyString(xml);
+      return(table);
+    }
+  content=GetXMLTreeContent(levels);
+  if (content == (char *) NULL)
+    {
+      (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
+        "XmlMissingContent", "<levels>, table \"%s\"",slot);
+      quantization_tables=DestroyXMLTree(quantization_tables);
+      table=DestroyQuantizationTable(table);
+      xml=DestroyString(xml);
+      return(table);
+    }
+  table->levels=(unsigned int *) AcquireQuantumMemory((size_t) table->width,
+    table->height*sizeof(*table->levels));
+  if (table->levels == (unsigned int *) NULL)
+    ThrowFatalException(ResourceLimitFatalError,
+      "UnableToAcquireQuantizationTable");
+  for (i=0; i < (ssize_t) (table->width*table->height); i++)
+  {
+    table->levels[i]=(unsigned int) strtol(content,&p,10);
+    if (table->divisor != 1)
+      table->levels[i]/=table->divisor;
+    while (isspace((int) ((unsigned char) *p)) != 0)
+      p++;
+    if (*p == ',')
+      p++;
+    content=p;
+  }
+  for (j=i; i < 64; i++)
+    table->levels[j]=table->levels[j-1];
+  value=(double) strtol(content,&p,10);
+  (void) value;
+  if (p != content)
+    {
+      (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
+        "XmlInvalidContent", "<level> too many values, table \"%s\"",slot);
+     quantization_tables=DestroyXMLTree(quantization_tables);
+     table=DestroyQuantizationTable(table);
+     xml=DestroyString(xml);
+     return(table);
+   }
+  quantization_tables=DestroyXMLTree(quantization_tables);
+  xml=DestroyString(xml);
+  return(table);
+}
+
 static void InitializeDestination(j_compress_ptr cinfo)
 {
   DestinationManager
@@ -2122,77 +2348,44 @@ static MagickBooleanType WriteJPEGImage(const ImageInfo *image_info,
       jpeg_info.comp_info[i].h_samp_factor=1;
       jpeg_info.comp_info[i].v_samp_factor=1;
     }
-  if ((jpeg_info.comp_info[0].h_samp_factor >= 2) &&
-      (jpeg_info.comp_info[0].v_samp_factor >= 2))
+  option=GetImageOption(image_info,"jpeg:q-table");
+  if (option != (const char *) NULL)
     {
-      static const unsigned int
-        ChrominanceQTable[DCTSIZE2] =
-        {
-          17,  18,  22,  31,  50,  92,   193,  465,
-          18,  19,  24,  33,  54,  98,   207,  498,
-          22,  24,  29,  41,  66,  120,  253,  609,
-          31,  33,  41,  57,  92,  169,  355,  854,
-          50,  54,  66,  92,  148, 271,  570,  1370,
-          92,  98,  120, 169, 271, 498,  1046, 2516,
-          193, 207, 253, 355, 570, 1046, 2198, 5289,
-          465, 498, 609, 854, 1370,2516, 5289, 12725
-        },
-        LuminanceQTable[DCTSIZE2] =
-        {
-          16, 12, 14, 17, 22, 30, 45, 72,
-          12, 13, 14, 17, 22, 31, 46, 74,
-          14, 14, 16, 19, 25, 35, 52, 83,
-          17, 17, 19, 23, 30, 41, 62, 100,
-          22, 22, 25, 30, 39, 54, 80, 129,
-          30, 31, 35, 41, 54, 74, 111, 178,
-          45, 46, 52, 62, 80, 111, 166, 267,
-          72, 74, 83, 100, 129, 178, 267, 428
-        };
+      QuantizationTable
+        *table;
 
       /*
-        Nicolas Robidoux's remix of ISO-IEC 10918-1 : 1993(E) Annex K.
+        Custom quantization tables.
       */
-      jpeg_add_quant_table(&jpeg_info,0,LuminanceQTable,jpeg_quality_scaling(
-        quality),0);
-      jpeg_add_quant_table(&jpeg_info,1,ChrominanceQTable,jpeg_quality_scaling(
-        quality),0);
+      table=GetQuantizationTable(option,"0",exception);
+      if (table != (QuantizationTable *) NULL)
+        {
+          jpeg_add_quant_table(&jpeg_info,0,table->levels,jpeg_quality_scaling(
+            quality),0);
+          table=DestroyQuantizationTable(table);
+        }
+      table=GetQuantizationTable(option,"1",exception);
+      if (table != (QuantizationTable *) NULL)
+        {
+          jpeg_add_quant_table(&jpeg_info,1,table->levels,jpeg_quality_scaling(
+            quality),0);
+          table=DestroyQuantizationTable(table);
+        }
+      table=GetQuantizationTable(option,"2",exception);
+      if (table != (QuantizationTable *) NULL)
+        {
+          jpeg_add_quant_table(&jpeg_info,2,table->levels,jpeg_quality_scaling(
+            quality),0);
+          table=DestroyQuantizationTable(table);
+        }
+      table=GetQuantizationTable(option,"3",exception);
+      if (table != (QuantizationTable *) NULL)
+        {
+          jpeg_add_quant_table(&jpeg_info,3,table->levels,jpeg_quality_scaling(
+            quality),0);
+          table=DestroyQuantizationTable(table);
+        }
     }
-  else
-    if ((jpeg_info.comp_info[0].h_samp_factor >= 1) &&
-        (jpeg_info.comp_info[0].v_samp_factor >= 1))
-      {
-        static const unsigned int
-          ChrominanceQTable[DCTSIZE2] =
-          {
-             12,    15,    18,    26,    39,    69,    139,   279,
-             15,    18,    26,    39,    69,    139,   279,   559,
-             18,    26,    39,    69,    139,   279,   559,   1119,
-             26,    39,    69,    139,   279,   559,   1119,  2239,
-             39,    69,    139,   279,   559,   1119,  2239,  4479,
-             69,    139,   279,   559,   1119,  2239,  4479,  8959,
-             139,   279,   559,   1119,  2239,  4479,  8959,  17919,
-             279,   559,   1119,  2239,  4479,  8959,  17919, 35839
-          },
-          LuminanceQTable[DCTSIZE2] =
-          {
-             11,  11,  12,  15,   20,  27,   36,   47,
-             11,  12,  15,  20,   27,  36,   47,   93,
-             12,  15,  20,  27,   36,  47,   93,   185,
-             15,  20,  27,  36,   47,  93,   185,  369,
-             20,  27,  36,  47,   93,  185,  369,  737,
-             27,  36,  47,  93,   185, 369,  737,  1473,
-             36,  47,  93,  185,  369, 737,  1473, 2945,
-             47,  93,  185, 369,  737, 1473, 2945, 5889
-          };
-
-        /*
-          Nicolas Robidoux's remix of ISO-IEC 10918-1 : 1993(E) Annex K.
-        */
-        jpeg_add_quant_table(&jpeg_info,0,LuminanceQTable,jpeg_quality_scaling(
-          quality),0);
-        jpeg_add_quant_table(&jpeg_info,1,ChrominanceQTable,
-          jpeg_quality_scaling(quality),0);
-      }
   jpeg_start_compress(&jpeg_info,MagickTrue);
   if (image->debug != MagickFalse)
     {
index 41794d09254e5508d8889eaf0314d70592547a00..4fbb2b24e0253162475f8f23e2087c24461d53f7 100644 (file)
@@ -148,7 +148,7 @@ static Image *ReadXTRNImage(const ImageInfo *image_info,
       (void) sscanf(clone_info->filename,"%lx,%lx",&param1,&param2);
       image_ptr=(Image **) param2;
       if (*image_ptr != (Image *)NULL)
-        image=CloneImage(*image_ptr,0,0,MagickFalse,exception);
+        image=CloneImage(*image_ptr,0,0,MagickFalse,&(*image_ptr)->exception);
 #ifdef ALL_IMAGEINFO
       image_info_ptr=(ImageInfo **) param1;
       if (*image_info_ptr != (ImageInfo *)NULL)
@@ -477,8 +477,7 @@ size_t SafeArrayFifo(const Image *image,const void *data,const size_t length)
   return(tlen);
 }
 
-static MagickBooleanType WriteXTRNImage(const ImageInfo *image_info,
-  Image *image,ExceptionInfo *exception)
+static MagickBooleanType WriteXTRNImage(const ImageInfo *image_info,Image *image,ExceptionInfo *exception)
 {
   Image *
     p;
@@ -596,7 +595,7 @@ static MagickBooleanType WriteXTRNImage(const ImageInfo *image_info,
           SetImageInfo(clone_info,1,exception);
           (void) CopyMagickString(image->magick,clone_info->magick,
             MaxTextExtent);
-          status=WriteStream(clone_info,image,fifo,exception);
+          status=WriteStream(clone_info,image,fifo);
           if (status == MagickFalse)
             CatchImageException(image);
         }
@@ -625,7 +624,7 @@ static MagickBooleanType WriteXTRNImage(const ImageInfo *image_info,
           SetImageInfo(clone_info,1,exception);
           (void) CopyMagickString(image->magick,clone_info->magick,
             MaxTextExtent);
-          status=WriteStream(clone_info,image,SafeArrayFifo,exception);
+          status=WriteStream(clone_info,image,SafeArrayFifo);
           if (status == MagickFalse)
             CatchImageException(image);
         }
index 570f5c33c35099bb05fd984feabada036330c33d..4d79f4ab4c83b0f1a046214f6fa0c18c338b7553 100644 (file)
@@ -5,7 +5,7 @@
     <name>ImageMagick</name>
     <shortdesc xml:lang="en">ImageMagick: convert, edit, and compose images.</shortdesc>
     <homepage rdf:resource="http://www.imagemagick.org/"/>
-    <created>2012-02-28</created>
+    <created>2012-02-29</created>
 
     <description xml:lang="en">
 ImageMagick® is a software suite to create, edit, compose, or convert bitmap images. It can read and write images in a variety of formats (over 100) including DPX, EXR, GIF, JPEG, JPEG-2000, PDF, PhotoCD, PNG, Postscript, SVG, and TIFF. Use ImageMagick to resize, flip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves.
@@ -57,7 +57,7 @@ Examples of ImageMagick Usage shows how to use ImageMagick from the command-line
     <release>
       <Version>
           <name>stable</name>
-          <created>2012-02-28</created>
+          <created>2012-02-29</created>
           <revision>7.0.0</revision>
       </Version>
     </release>
index a41161ff400fd80f03fcb99e7665734ddbcf2202..870245ccf6927be71b51833a8ad067833a14e8ca 100644 (file)
@@ -39,6 +39,7 @@ configlib_DATA = \
        config/magic.xml \
        config/mime.xml \
        config/policy.xml \
+       config/quantization-table.xml \
        config/sRGB.icc \
        config/thresholds.xml \
        config/type.xml \
@@ -60,6 +61,7 @@ CONFIG_EXTRA_DIST = \
        config/magic.xml \
        config/mime.xml \
        config/policy.xml \
+       config/quantization-table.xml \
        config/sRGB.icc \
        config/thresholds.xml \
        config/type-dejavu.xml.in \
index 04616a19265711f0ebf23913c66222dd57d2fad1..5732e61d5f68199b5614307e413015b153d1f329 100644 (file)
@@ -10,8 +10,8 @@
   <configure name="VERSION" value="7.0.0"/>
   <configure name="LIB_VERSION" value="0x700"/>
   <configure name="LIB_VERSION_NUMBER" value="7,0,0,0"/>
-  <configure name="SVN_REVISION" value="6986" />
-  <configure name="RELEASE_DATE" value="2012-02-28"/>
+  <configure name="SVN_REVISION" value="6997" />
+  <configure name="RELEASE_DATE" value="2012-02-29"/>
   <configure name="CONFIGURE" value="./configure "/>
   <configure name="PREFIX" value="/usr/local"/>
   <configure name="EXEC-PREFIX" value="/usr/local"/>
index ff9da4ba5d2cf811262c04e27ad0be26d8a78057..329a028ad7338a2d667ff85fb23cf31c2508ae45 100755 (executable)
--- a/configure
+++ b/configure
@@ -3612,7 +3612,7 @@ MAGICK_LIBRARY_CURRENT_MIN=`expr $MAGICK_LIBRARY_CURRENT - $MAGICK_LIBRARY_AGE`
 
 MAGICK_LIBRARY_VERSION_INFO=$MAGICK_LIBRARY_CURRENT:$MAGICK_LIBRARY_REVISION:$MAGICK_LIBRARY_AGE
 
-MAGICK_SVN_REVISION=6986
+MAGICK_SVN_REVISION=6997