From: cristy Date: Thu, 1 Mar 2012 01:41:41 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 7.0.1-0~6104 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1b58f25a8c2616ecdf2898ab358e1ee63d1b522e;p=imagemagick --- diff --git a/MagickCore/constitute.c b/MagickCore/constitute.c index 205a0c2d7..908403881 100644 --- a/MagickCore/constitute.c +++ b/MagickCore/constitute.c @@ -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; diff --git a/MagickCore/constitute.h b/MagickCore/constitute.h index 33d1ac71e..c3fe5afd3 100644 --- a/MagickCore/constitute.h +++ b/MagickCore/constitute.h @@ -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 diff --git a/MagickCore/method-attribute.h b/MagickCore/method-attribute.h index 8141794b0..4b79d2a6f 100644 --- a/MagickCore/method-attribute.h +++ b/MagickCore/method-attribute.h @@ -105,7 +105,7 @@ extern "C" { #define MagickSignature 0xabacadabUL #if !defined(MaxTextExtent) -# define MaxTextExtent 8192 +# define MaxTextExtent 4096 #endif #if defined(MAGICKCORE_HAVE___ATTRIBUTE__) diff --git a/MagickCore/version.h b/MagickCore/version.h index 813809e1b..00d4e0af3 100644 --- a/MagickCore/version.h +++ b/MagickCore/version.h @@ -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) diff --git a/MagickCore/xml-tree-private.h b/MagickCore/xml-tree-private.h index 97fdd0c58..74a086d22 100644 --- a/MagickCore/xml-tree-private.h +++ b/MagickCore/xml-tree-private.h @@ -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), diff --git a/MagickCore/xml-tree.c b/MagickCore/xml-tree.c index d1bcf8477..d695547b3 100644 --- a/MagickCore/xml-tree.c +++ b/MagickCore/xml-tree.c @@ -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 diff --git a/MagickCore/xml-tree.h b/MagickCore/xml-tree.h index bbcfba2d2..1ad11c8c1 100644 --- a/MagickCore/xml-tree.h +++ b/MagickCore/xml-tree.h @@ -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 *), diff --git a/MagickWand/animate.c b/MagickWand/animate.c index ad20b5229..b84281f05 100644 --- a/MagickWand/animate.c +++ b/MagickWand/animate.c @@ -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) diff --git a/MagickWand/compare.c b/MagickWand/compare.c index 2fcb7e280..e27e5b1ce 100644 --- a/MagickWand/compare.c +++ b/MagickWand/compare.c @@ -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) diff --git a/MagickWand/composite.c b/MagickWand/composite.c index 4649c3054..7da939e5a 100644 --- a/MagickWand/composite.c +++ b/MagickWand/composite.c @@ -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) diff --git a/MagickWand/conjure.c b/MagickWand/conjure.c index 83f4f3355..139e49bf2 100644 --- a/MagickWand/conjure.c +++ b/MagickWand/conjure.c @@ -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); diff --git a/MagickWand/convert.c b/MagickWand/convert.c index c643bbc2c..e23549787 100644 --- a/MagickWand/convert.c +++ b/MagickWand/convert.c @@ -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) diff --git a/MagickWand/identify.c b/MagickWand/identify.c index 225eb75e6..a2b4d7b78 100644 --- a/MagickWand/identify.c +++ b/MagickWand/identify.c @@ -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); diff --git a/MagickWand/method-attribute.h b/MagickWand/method-attribute.h index aa4ac7f4f..6bdc6e0d5 100644 --- a/MagickWand/method-attribute.h +++ b/MagickWand/method-attribute.h @@ -98,7 +98,7 @@ extern "C" { #define WandSignature 0xabacadabUL #if !defined(MaxTextExtent) -# define MaxTextExtent 8192 +# define MaxTextExtent 4096 #endif #if defined(MAGICKCORE_HAVE___ATTRIBUTE__) diff --git a/MagickWand/mogrify.c b/MagickWand/mogrify.c index 939b941b2..c63d7b991 100644 --- a/MagickWand/mogrify.c +++ b/MagickWand/mogrify.c @@ -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) diff --git a/MagickWand/montage.c b/MagickWand/montage.c index 2b9a08e6b..805046aaf 100644 --- a/MagickWand/montage.c +++ b/MagickWand/montage.c @@ -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) diff --git a/Makefile.in b/Makefile.in index ae21a882a..bfdaac541 100644 --- a/Makefile.in +++ b/Makefile.in @@ -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 \ diff --git a/PerlMagick/Magick.xs b/PerlMagick/Magick.xs index ea378a51d..6f725a79d 100644 --- a/PerlMagick/Magick.xs +++ b/PerlMagick/Magick.xs @@ -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) diff --git a/coders/caption.c b/coders/caption.c index 320b559fe..c4510bcdb 100644 --- a/coders/caption.c +++ b/coders/caption.c @@ -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)); diff --git a/coders/jpeg.c b/coders/jpeg.c index 5c8849991..809e405d5 100644 --- a/coders/jpeg.c +++ b/coders/jpeg.c @@ -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 #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; /* 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", ", 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", ", 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", ", 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", ", 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", ", 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", ", 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", ", 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", ", 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", ", 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", " 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) { diff --git a/coders/xtrn.c b/coders/xtrn.c index 41794d092..4fbb2b24e 100644 --- a/coders/xtrn.c +++ b/coders/xtrn.c @@ -148,7 +148,7 @@ static Image *ReadXTRNImage(const ImageInfo *image_info, (void) sscanf(clone_info->filename,"%lx,%lx",¶m1,¶m2); 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); } diff --git a/config/ImageMagick.rdf b/config/ImageMagick.rdf index 570f5c33c..4d79f4ab4 100644 --- a/config/ImageMagick.rdf +++ b/config/ImageMagick.rdf @@ -5,7 +5,7 @@ ImageMagick ImageMagick: convert, edit, and compose images. - 2012-02-28 + 2012-02-29 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 stable - 2012-02-28 + 2012-02-29 7.0.0 diff --git a/config/Makefile.am b/config/Makefile.am index a41161ff4..870245ccf 100644 --- a/config/Makefile.am +++ b/config/Makefile.am @@ -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 \ diff --git a/config/configure.xml b/config/configure.xml index 04616a192..5732e61d5 100644 --- a/config/configure.xml +++ b/config/configure.xml @@ -10,8 +10,8 @@ - - + + diff --git a/configure b/configure index ff9da4ba5..329a028ad 100755 --- 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