diff options
Diffstat (limited to 'magick')
69 files changed, 2509 insertions, 1361 deletions
diff --git a/magick/GraphicsMagick-config.in b/magick/GraphicsMagick-config.in index 8b2f016..bef184c 100644 --- a/magick/GraphicsMagick-config.in +++ b/magick/GraphicsMagick-config.in @@ -11,7 +11,7 @@ usage='Usage: GraphicsMagick-config [--cflags] [--cppflags] [--exec-prefix] [--l For example, "example.c" may be compiled to produce "example" as follows: - "gcc -o example example.c `GraphicsMagick-config --cppflags --cflags --ldflags --libs`"' + "@CC@ -o example example.c `GraphicsMagick-config --cppflags --cflags --ldflags --libs`"' if test $# -eq 0; then echo "${usage}" 1>&2 @@ -29,6 +29,9 @@ while test $# -gt 0; do --version) echo @PACKAGE_VERSION@ ;; + --cc) + echo '@CC@' + ;; --cflags) echo '@CFLAGS@' ;; @@ -48,4 +51,3 @@ while test $# -gt 0; do esac shift done - diff --git a/magick/GraphicsMagick.pc.in b/magick/GraphicsMagick.pc.in index 5757b37..8fe4ccd 100644 --- a/magick/GraphicsMagick.pc.in +++ b/magick/GraphicsMagick.pc.in @@ -8,4 +8,5 @@ Name: GraphicsMagick Version: @PACKAGE_VERSION@ Description: GraphicsMagick image processing library Libs: -L${libdir} -lGraphicsMagick +Libs.private: @LDFLAGS@ @MAGICK_API_DEP_LIBS@ Cflags: -I${includedir} @MAGICK_API_PC_CPPFLAGS@ diff --git a/magick/Makefile.am b/magick/Makefile.am index 9360146..0b10572 100644 --- a/magick/Makefile.am +++ b/magick/Makefile.am @@ -315,6 +315,7 @@ MAGICK_NOINST_HDRS = \ magick/omp_data_view.h \ magick/pixel_cache-private.h \ magick/prefetch.h \ + magick/profile-private.h \ magick/random-private.h \ magick/registry-private.h \ magick/render-private.h \ diff --git a/magick/analyze.c b/magick/analyze.c index 1d18ece..5399a88 100644 --- a/magick/analyze.c +++ b/magick/analyze.c @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003 - 2019 GraphicsMagick Group +% Copyright (C) 2003 - 2022 GraphicsMagick Group % Copyright (C) 2003 ImageMagick Studio % Copyright 1991-1999 E. I. du Pont de Nemours and Company % @@ -253,7 +253,7 @@ MagickExport RectangleInfo GetImageBoundingBox(const Image *image, bounds.x=0; bounds.y=0; } - if (image->logging) + if (IsEventLogged(TransformEvent)) (void) LogMagickEvent(TransformEvent,GetMagickModule(), "Bounding Box: %lux%lu%+ld%+ld", bounds.width, bounds.height, bounds.x, bounds.y); @@ -294,6 +294,7 @@ MagickExport RectangleInfo GetImageBoundingBox(const Image *image, % % */ +#if MaxMap == MaxRGB static inline unsigned char MinimumDepthForValue(const Quantum quantum) { register unsigned int @@ -309,13 +310,12 @@ static inline unsigned char MinimumDepthForValue(const Quantum quantum) return depth; } -#if MaxMap == MaxRGB static magick_uint8_t* AllocateDepthMap(void) { magick_uint8_t *map; - map = MagickAllocateArray(unsigned char *, MaxMap+1, sizeof(magick_uint8_t)); + map = MagickAllocateResourceLimitedArray(unsigned char *, MaxMap+1, sizeof(magick_uint8_t)); if (map != (unsigned char *) NULL) { unsigned int @@ -467,7 +467,7 @@ MagickExport unsigned long GetImageDepth(const Image *image, image->rows,image,exception); } - MagickFreeMemory(map); + MagickFreeResourceLimitedMemory(map); return depth; } diff --git a/magick/animate.c b/magick/animate.c index 9f01fa6..6086173 100644 --- a/magick/animate.c +++ b/magick/animate.c @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003-2019 GraphicsMagick Group +% Copyright (C) 2003-2022 GraphicsMagick Group % Copyright (C) 2002 ImageMagick Studio % Copyright 1991-1999 E. I. du Pont de Nemours and Company % @@ -647,7 +647,7 @@ MagickExport void MagickXAnimateBackgroundImage(Display *display, */ window_attributes.width=XDisplayWidth(display,XDefaultScreen(display)); window_attributes.height=XDisplayHeight(display,XDefaultScreen(display)); - (void) strcpy(visual_type,"default"); + (void) strlcpy(visual_type,"default",sizeof(visual_type)); status=XGetWindowAttributes(display,window_info.id,&window_attributes); if (status != False) FormatString(visual_type,"0x%lx", @@ -825,7 +825,7 @@ MagickExport void MagickXAnimateBackgroundImage(Display *display, MagickFatalError(XServerFatalError,UnableToCreateXImage,(char *) NULL); window_info.x=0; window_info.y=0; - if (IsEventLogging()) + if (IsEventLogged(X11Event)) { (void) LogMagickEvent(X11Event,GetMagickModule(), "Image: %.1024s[%lu] %lux%lu ",image_list[0]->filename, @@ -941,7 +941,7 @@ MagickExport void MagickXAnimateBackgroundImage(Display *display, (unsigned int) image_list[scene]->rows); if (status == False) MagickFatalError(XServerFatalError,UnableToCreateXImage,(char *) NULL); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) { (void) LogMagickEvent(X11Event,GetMagickModule(), "Image: [%lu] %.1024s %lux%lu ",image_list[scene]->scene, @@ -1417,7 +1417,7 @@ MagickXAnimateImages(Display *display, (display_image->rows < image_list[scene]->rows)) display_image=image_list[scene]; } - if (IsEventLogging()) + if (IsEventLogged(X11Event)) { (void) LogMagickEvent(X11Event,GetMagickModule(), "Image: %.1024s[%lu] %lux%lu ",display_image->filename, @@ -1443,7 +1443,7 @@ MagickXAnimateImages(Display *display, manager_hints->initial_state=WithdrawnState; MagickXMakeWindow(display,root_window,argv,argc,class_hints,manager_hints, &windows->context); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Window id: 0x%lx (context)",windows->context.id); context_values.background=pixel->background_color.pixel; @@ -1494,7 +1494,7 @@ MagickXAnimateImages(Display *display, manager_hints->initial_state=IconicState; MagickXMakeWindow(display,root_window,argv,argc,class_hints,manager_hints, &windows->icon); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(),"Window id: 0x%lx (icon)", windows->icon.id); /* @@ -1590,7 +1590,7 @@ MagickXAnimateImages(Display *display, resource_info->iconic ? IconicState : NormalState; MagickXMakeWindow(display,root_window,argv,argc,class_hints,manager_hints, &windows->backdrop); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Window id: 0x%lx (backdrop)",windows->backdrop.id); (void) XMapWindow(display,windows->backdrop.id); @@ -1626,7 +1626,7 @@ MagickXAnimateImages(Display *display, manager_hints->flags|=(unsigned int) WindowGroupHint; manager_hints->window_group=windows->group_leader.id; (void) XSelectInput(display,windows->group_leader.id,StructureNotifyMask); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Window id: 0x%lx (group leader)",windows->group_leader.id); } @@ -1638,7 +1638,7 @@ MagickXAnimateImages(Display *display, if (windows->group_leader.id != (Window) NULL) (void) XSetTransientForHint(display,windows->image.id, windows->group_leader.id); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(),"Window id: 0x%lx (image)", windows->image.id); /* @@ -1669,7 +1669,7 @@ MagickXAnimateImages(Display *display, (void) XSetTransientForHint(display,windows->info.id,windows->image.id); if (windows->image.mapped) (void) XWithdrawWindow(display,windows->info.id,windows->info.screen); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(),"Window id: 0x%lx (info)", windows->info.id); /* @@ -1698,7 +1698,7 @@ MagickXAnimateImages(Display *display, windows->command.highlight_stipple=windows->info.highlight_stipple; windows->command.shadow_stipple=windows->info.shadow_stipple; (void) XSetTransientForHint(display,windows->command.id,windows->image.id); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(),"Window id: 0x%lx (command)", windows->command.id); /* @@ -1731,7 +1731,7 @@ MagickXAnimateImages(Display *display, windows->widget.highlight_stipple=windows->info.highlight_stipple; windows->widget.shadow_stipple=windows->info.shadow_stipple; (void) XSetTransientForHint(display,windows->widget.id,windows->image.id); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(),"Window id: 0x%lx (widget)", windows->widget.id); /* @@ -1760,7 +1760,7 @@ MagickXAnimateImages(Display *display, windows->popup.highlight_stipple=windows->info.highlight_stipple; windows->popup.shadow_stipple=windows->info.shadow_stipple; (void) XSetTransientForHint(display,windows->popup.id,windows->image.id); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(),"Window id: 0x%lx (pop up)", windows->popup.id); if (!windows->image.mapped || (windows->backdrop.id != (Window) NULL)) @@ -1827,7 +1827,7 @@ MagickXAnimateImages(Display *display, (unsigned int) image_list[scene]->rows); if (status == False) MagickFatalError(XServerFatalError,UnableToCreateXImage,(char *) NULL); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) { (void) LogMagickEvent(X11Event,GetMagickModule(), "Image: [%lu] %.1024s %lux%lu ",image_list[scene]->scene, @@ -2048,7 +2048,7 @@ MagickXAnimateImages(Display *display, { case ButtonPress: { - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Button Press: 0x%lx %u +%d+%d",event.xbutton.window, event.xbutton.button,event.xbutton.x,event.xbutton.y); @@ -2091,7 +2091,7 @@ MagickXAnimateImages(Display *display, } case ButtonRelease: { - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Button Release: 0x%lx %u +%d+%d",event.xbutton.window, event.xbutton.button,event.xbutton.x,event.xbutton.y); @@ -2099,7 +2099,7 @@ MagickXAnimateImages(Display *display, } case ClientMessage: { - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Client Message: 0x%lx 0x%lx %d 0x%lx",event.xclient.window, event.xclient.message_type,event.xclient.format,(unsigned long) @@ -2226,7 +2226,7 @@ MagickXAnimateImages(Display *display, } case ConfigureNotify: { - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Configure Notify: 0x%lx %dx%d+%d+%d %d",event.xconfigure.window, event.xconfigure.width,event.xconfigure.height,event.xconfigure.x, @@ -2290,7 +2290,7 @@ MagickXAnimateImages(Display *display, /* Group leader has exited. */ - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(),"Destroy Notify: 0x%lx", event.xdestroywindow.window); if (event.xdestroywindow.window == windows->group_leader.id) @@ -2316,7 +2316,7 @@ MagickXAnimateImages(Display *display, } case Expose: { - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Expose: 0x%lx %dx%d+%d+%d",event.xexpose.window, event.xexpose.width,event.xexpose.height,event.xexpose.x, @@ -2350,7 +2350,7 @@ MagickXAnimateImages(Display *display, length=XLookupString((XKeyEvent *) &event.xkey,command,sizeof(command), &key_symbol,(XComposeStatus *) NULL); *(command+length)='\0'; - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(),"Key press: 0x%lx (%c)", key_symbol,*command); command_type=NullCommand; @@ -2421,7 +2421,7 @@ MagickXAnimateImages(Display *display, */ (void) XLookupString((XKeyEvent *) &event.xkey,command,sizeof(command), &key_symbol,(XComposeStatus *) NULL); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Key release: 0x%lx (%c)",key_symbol,*command); break; @@ -2442,7 +2442,7 @@ MagickXAnimateImages(Display *display, } case MapNotify: { - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(),"Map Notify: 0x%lx", event.xmap.window); if (event.xmap.window == windows->backdrop.id) @@ -2528,7 +2528,7 @@ MagickXAnimateImages(Display *display, after, length; - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Property Notify: 0x%lx 0x%lx %d",event.xproperty.window, event.xproperty.atom,event.xproperty.state); @@ -2555,7 +2555,7 @@ MagickXAnimateImages(Display *display, } case ReparentNotify: { - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Reparent Notify: 0x%lx=>0x%lx",event.xreparent.parent, event.xreparent.window); @@ -2563,7 +2563,7 @@ MagickXAnimateImages(Display *display, } case UnmapNotify: { - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(),"Unmap Notify: 0x%lx", event.xunmap.window); if (event.xunmap.window == windows->backdrop.id) @@ -2616,7 +2616,7 @@ MagickXAnimateImages(Display *display, } default: { - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(),"Event type: %d", event.type); break; diff --git a/magick/attribute.c b/magick/attribute.c index 40f47a2..9f19213 100644 --- a/magick/attribute.c +++ b/magick/attribute.c @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003-2019 GraphicsMagick Group +% Copyright (C) 2003-2023 GraphicsMagick Group % Copyright (C) 2002 ImageMagick Studio % % This program is covered by multiple licenses, which are described in @@ -133,7 +133,7 @@ CloneImageAttributes(Image* clone_image, status = MagickFail; break; } - strcpy(cloned_attribute->value,attribute->value); + (void) strlcpy(cloned_attribute->value,attribute->value,cloned_attribute->length+1); if (cloned_attributes == (ImageAttribute *) NULL) { @@ -947,7 +947,7 @@ Generate8BIMAttribute(Image *image,const char *key) if ((count != 2) && (count != 3) && (count != 4)) return(False); if (count < 4) - (void)strcpy(format,"SVG"); + (void)strlcpy(format,"SVG",sizeof(format)); if (count < 3) *name='\0'; sub_number=1; @@ -1621,7 +1621,7 @@ GenerateEXIFAttribute(Image *image,const char *specification) debug=MagickFalse; assert((ArraySize(format_bytes)-1) == EXIF_NUM_FORMATS); - logging=IsEventLogging(); + logging=IsEventLogged(TransformEvent); { const char * env_value; @@ -2156,6 +2156,7 @@ GenerateEXIFAttribute(Image *image,const char *specification) } case EXIF_FMT_SINGLE: { + float fval; if ((pval < tiffp) || ((pval+sizeof(float)) > tiffp_max)) { if (logging) @@ -2164,12 +2165,14 @@ GenerateEXIFAttribute(Image *image,const char *specification) (MAGICK_SSIZE_T) (pval-tiffp)); goto generate_attribute_failure; } - FormatString(s,"%f",(double) *(float *) pval); + (void) memcpy(&fval,pval,sizeof(fval)); + FormatString(s,"%f",(double) fval); value=AllocateString(s); break; } case EXIF_FMT_DOUBLE: { + double dval; if ((pval < tiffp) || ((pval+sizeof(double)) > tiffp_max)) { if (logging) @@ -2178,7 +2181,8 @@ GenerateEXIFAttribute(Image *image,const char *specification) (MAGICK_SSIZE_T) (pval-tiffp)); goto generate_attribute_failure; } - FormatString(s,"%f",*(double *) pval); + (void) memcpy(&dval,pval,sizeof(dval)); + FormatString(s,"%f",dval); value=AllocateString(s); break; } @@ -2231,7 +2235,7 @@ GenerateEXIFAttribute(Image *image,const char *specification) } else { - i += sprintf(&value[i],"\\%03o", + i += snprintf(&value[i],(allocation_size-i),"\\%03o", (unsigned int) pval[a]); binary |= MagickTrue; } @@ -2524,7 +2528,22 @@ GetImageAttribute(const Image *image,const char *key) MagickExport const ImageAttribute * GetImageClippingPathAttribute(const Image *image) { - return(GetImageAttribute(image,"8BIM:1999,2998")); + /* Get the name of the clipping path, if any. The clipping path + length is indicated by the first character of the Pascal + string. */ + const ImageAttribute *path_name = GetImageAttribute(image, "8BIM:2999,2999"); + if ((path_name != (const ImageAttribute *) NULL) && + (path_name->length > 2) && + ((size_t) path_name->value[0] < path_name->length)) + { + static const char clip_prefix[] = "8BIM:1999,2998"; + char attr_name[271]; + /*sprintf(attr_name, "%s:%.255s", clip_prefix, path_name->value+1);*/ + sprintf(attr_name, "%s:%.*s", clip_prefix, Min(255,(int) path_name->length-1), + path_name->value+1); + return GetImageAttribute(image, attr_name); + } + return NULL; } /* @@ -2646,6 +2665,8 @@ GetImageInfoAttribute(const ImageInfo *image_info,const Image *image, { if (LocaleNCompare("name",key,2) == 0) { + /* What should this really be? */ + GetPathComponent(image->magick_filename,BasePath,filename); (void) strlcpy(attribute,filename,MaxTextExtent); break; } @@ -3178,9 +3199,6 @@ SetImageAttribute(Image *image,const char *key,const char *value) register ImageAttribute *p; - int - orientation; - /* Initialize new attribute. */ @@ -3271,6 +3289,9 @@ SetImageAttribute(Image *image,const char *key,const char *value) if (LocaleCompare(attribute->key,"EXIF:Orientation") == 0) { + int + orientation = 0; + /* Special handling for EXIF orientation tag. If new value differs from existing value, @@ -3278,17 +3299,19 @@ SetImageAttribute(Image *image,const char *key,const char *value) is valid. Don't append new value to existing value, replace it instead. */ - orientation = MagickAtoI(value); - if (orientation > 0 || orientation <= (int)LeftBottomOrientation) - SetEXIFOrientation(image, orientation); - - /* Replace current attribute with new one */ - attribute->next = p->next; - if (p->previous == (ImageAttribute *) NULL) - image->attributes=attribute; - else - p->previous->next = attribute; - DestroyImageAttribute(p); + if ((MagickAtoIChk(value, &orientation) == MagickPass) && + (orientation > 0 || orientation <= (int)LeftBottomOrientation)) + { + SetEXIFOrientation(image, orientation); + } + /* Assign changed value to attribute in list */ + if (LocaleCompare(p->value, attribute->value) != 0) + { + MagickFreeMemory(p->value); + p->value=attribute->value; + attribute->value = (char *) NULL; + } + DestroyImageAttribute(attribute); return(MagickPass); } else @@ -3301,8 +3324,11 @@ SetImageAttribute(Image *image,const char *key,const char *value) { /* nada */}; MagickReallocMemory(char *,p->value,realloc_l); if (p->value != (char *) NULL) - (void) strcat(p->value+p->length,attribute->value); - p->length += attribute->length; + { + (void) memcpy(p->value+p->length,attribute->value,min_l-p->length-1); + p->length += attribute->length; + p->value[p->length] = '\0'; + } DestroyImageAttribute(attribute); } if (p->value != (char *) NULL) diff --git a/magick/blob.c b/magick/blob.c index 68c05a8..3d98ee1 100644 --- a/magick/blob.c +++ b/magick/blob.c @@ -120,6 +120,7 @@ struct _BlobInfo MagickBool exempt, /* True if file descriptor should not be closed.*/ + logging, /* BlobEvent logging is enabled */ temporary; /* Associated file is a temporary file */ int @@ -147,6 +148,9 @@ struct _BlobInfo long reference_count; /* Number of times this blob is referenced. */ + char + *vbuf; /* Buffer for setvbuf() */ + unsigned long signature; /* Numeric value used to evaluate structure integrity. */ }; @@ -333,7 +337,7 @@ static void *ExtendBlobWriteStream(Image *image,const size_t length) blob->quantum<<=1; blob->extent+=length+blob->quantum; #if 0 - if (image->logging) + if (blob->logging) (void) LogMagickEvent(BlobEvent,GetMagickModule(), "MagickReallocMemory blob->data=%p," " blob->extent=%" MAGICK_SIZE_T_F "u", @@ -344,7 +348,7 @@ static void *ExtendBlobWriteStream(Image *image,const size_t length) if (blob->data == (unsigned char *) NULL) { #if 0 - if (image->logging) + if (blob->logging) (void) LogMagickEvent(BlobEvent,GetMagickModule(), "MagickReallocMemory failed! Detatching Blob..."); #endif @@ -545,7 +549,7 @@ MagickExport MagickPassFail BlobReserveSize(Image *image, magick_off_t size) status=MagickFail; } } - if (image->logging) + if (blob->logging) (void) LogMagickEvent(BlobEvent,GetMagickModule(), "Request to reserve %" MAGICK_OFF_F "u output bytes %s", size, @@ -946,7 +950,7 @@ MagickExport MagickPassFail CloseBlob(Image *image) if ((blob == (BlobInfo *) NULL) || (blob->type == UndefinedStream)) return MagickPass; - if (image->logging) + if (blob->logging) (void) LogMagickEvent(BlobEvent,GetMagickModule(), "Closing %sStream blob: image %p, blob %p, ref %lu", BlobStreamTypeToString(blob->type), @@ -1059,6 +1063,7 @@ MagickExport MagickPassFail CloseBlob(Image *image) blob->first_errno=errno; } } + MagickFreeMemory(image->blob->vbuf); break; } case PipeStream: @@ -1112,7 +1117,7 @@ MagickExport MagickPassFail CloseBlob(Image *image) } blob->type=UndefinedStream; blob->status=(status != 0); - if (image->logging && blob->status) + if (blob->logging && blob->status) (void) LogMagickEvent(BlobEvent,GetMagickModule(), "Closed blob: image %p, blob %p with " "errno %d (\"%s\")", @@ -1160,7 +1165,7 @@ MagickExport void DestroyBlob(Image *image) assert(image->blob->signature == MagickSignature); LockSemaphoreInfo(image->blob->semaphore); - if (image->logging) + if (image->blob->logging) (void) LogMagickEvent(BlobEvent,GetMagickModule(), "Destroy blob (ref counted): image %p, blob %p," " ref %lu, filename \"%s\"", @@ -1175,7 +1180,7 @@ MagickExport void DestroyBlob(Image *image) /* Destroy blob object. */ - if (image->logging) + if (image->blob->logging) (void) LogMagickEvent(BlobEvent,GetMagickModule(), " Destroy blob (real): image %p, blob %p," " ref %lu, filename \"%s\"", @@ -1278,7 +1283,8 @@ MagickExport void DetachBlob(BlobInfo *blob_info) assert(blob_info != (BlobInfo *) NULL); if (blob_info->mapped) { - (void) UnmapBlob(blob_info->data,blob_info->length); + if (blob_info->data != (unsigned char *) NULL) + (void) UnmapBlob(blob_info->data,blob_info->length); LiberateMagickResource(MapResource,blob_info->length); } blob_info->mapped=MagickFalse; @@ -1597,6 +1603,7 @@ MagickExport void GetBlobInfo(BlobInfo *blob_info) assert(blob_info != (BlobInfo *) NULL); (void) memset(blob_info,0,sizeof(BlobInfo)); blob_info->quantum=DefaultBlobQuantum; + blob_info->logging=IsEventLogged(BlobEvent); blob_info->fsync=MagickFalse; blob_info->semaphore=AllocateSemaphoreInfo(); LockSemaphoreInfo(blob_info->semaphore); @@ -1931,7 +1938,7 @@ MagickExport void *GetConfigureBlob(const char *filename,char *path, assert(length != (size_t *) NULL); assert(exception != (ExceptionInfo *) NULL); - logging=IsEventLogging(); + logging=IsEventLogged(ConfigureEvent); (void) strlcpy(path,filename,MaxTextExtent); path_map=MagickMapAllocateMap(MagickMapCopyString,MagickMapDeallocateString); @@ -2127,7 +2134,7 @@ MagickExport void *GetConfigureBlob(const char *filename,char *path, if (logging) (void) LogMagickEvent(ConfigureEvent,GetMagickModule(), "Found: %.1024s",test_path); - (void) strcpy(path,test_path); + (void) strlcpy(path,test_path,MaxTextExtent); (void) MagickFseek(file,0L,SEEK_END); *length=MagickFtell(file); /* FIXME: ftell returns long, but size_t may be unsigned */ if (*length > 0) @@ -2228,27 +2235,50 @@ MagickExport void *ImageToBlob(const ImageInfo *image_info,Image *image, *blob; unsigned int + i, status; + static const char no_blob_support[][6] = + { + "CACHE", + "MPC", + "MPR", + "MPRI", + "X" + }; + assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickSignature); assert(image != (Image *) NULL); assert(image->signature == MagickSignature); assert(exception != (ExceptionInfo *) NULL); - image->logging=IsEventLogging(); - if (image->logging) - (void) LogMagickEvent(BlobEvent,GetMagickModule(),"Entering ImageToBlob"); + if (image->blob->logging) + (void) LogMagickEvent(BlobEvent,GetMagickModule(), + "Entering ImageToBlob (image magick=\"%s\")", + image->magick); /* SetExceptionInfo(exception,UndefinedException); */ + for (i = 0; i < ArraySize(no_blob_support); i++) + { + if (LocaleCompare(image->magick,no_blob_support[i]) == 0) + { + ThrowException(exception,MissingDelegateError, + NoEncodeDelegateForThisImageFormat,image->magick); + if (image->blob->logging) + (void) LogMagickEvent(BlobEvent,GetMagickModule(), + "Exiting ImageToBlob"); + return((void *) NULL); + } + } clone_info=CloneImageInfo(image_info); (void) strlcpy(clone_info->magick,image->magick,MaxTextExtent); magick_info=GetMagickInfo(clone_info->magick,exception); if (magick_info == (const MagickInfo *) NULL) { ThrowException(exception,MissingDelegateError, - NoDecodeDelegateForThisImageFormat,clone_info->magick); + NoEncodeDelegateForThisImageFormat,clone_info->magick); DestroyImageInfo(clone_info); - if (image->logging) + if (image->blob->logging) (void) LogMagickEvent(BlobEvent,GetMagickModule(), "Exiting ImageToBlob"); return((void *) NULL); @@ -2265,7 +2295,7 @@ MagickExport void *ImageToBlob(const ImageInfo *image_info,Image *image, ThrowException(exception,ResourceLimitError,MemoryAllocationFailed, MagickMsg(BlobError,UnableToCreateBlob)); DestroyImageInfo(clone_info); - if (image->logging) + if (image->blob->logging) (void) LogMagickEvent(BlobEvent,GetMagickModule(), "Exiting ImageToBlob"); return((void *) NULL); @@ -2286,7 +2316,7 @@ MagickExport void *ImageToBlob(const ImageInfo *image_info,Image *image, clone_info->magick); MagickFreeMemory(image->blob->data); DestroyImageInfo(clone_info); - if (image->logging) + if (image->blob->logging) (void) LogMagickEvent(BlobEvent,GetMagickModule(), "Exiting ImageToBlob"); return((void *) NULL); @@ -2300,7 +2330,7 @@ MagickExport void *ImageToBlob(const ImageInfo *image_info,Image *image, /* Reset BlobInfo to original state (without freeing blob data). */ DetachBlob(image->blob); DestroyImageInfo(clone_info); - if (image->logging) + if (image->blob->logging) (void) LogMagickEvent(BlobEvent,GetMagickModule(), "Exiting ImageToBlob"); return(blob); @@ -2316,7 +2346,7 @@ MagickExport void *ImageToBlob(const ImageInfo *image_info,Image *image, DestroyImageInfo(clone_info); return((void *) NULL); } - if (image->logging) + if (image->blob->logging) (void) LogMagickEvent(BlobEvent,GetMagickModule(), "Allocated temporary file \"%s\"",unique); FormatString(image->filename,"%.1024s:%.1024s",image->magick,unique); @@ -2326,7 +2356,7 @@ MagickExport void *ImageToBlob(const ImageInfo *image_info,Image *image, { (void) LiberateTemporaryFile(unique); ThrowException(exception,BlobError,UnableToWriteBlob,image->filename); - if (image->logging) + if (image->blob->logging) (void) LogMagickEvent(BlobEvent,GetMagickModule(), "Exiting ImageToBlob"); return((void *) NULL); @@ -2335,7 +2365,7 @@ MagickExport void *ImageToBlob(const ImageInfo *image_info,Image *image, Read image from disk as blob. */ blob=(unsigned char *) FileToBlob(image->filename,length,exception); - if (image->logging) + if (image->blob->logging) (void) LogMagickEvent(BlobEvent,GetMagickModule(), "Liberating temporary file \"%s\"",image->filename); (void) LiberateTemporaryFile(image->filename); @@ -2343,12 +2373,12 @@ MagickExport void *ImageToBlob(const ImageInfo *image_info,Image *image, if (blob == (unsigned char *) NULL) { ThrowException(exception,BlobError,UnableToReadFile,filename); - if (image->logging) + if (image->blob->logging) (void) LogMagickEvent(BlobEvent,GetMagickModule(), "Exiting ImageToBlob"); return((void *) NULL); } - if (image->logging) + if (image->blob->logging) (void) LogMagickEvent(BlobEvent,GetMagickModule(), "Exiting ImageToBlob"); return(blob); @@ -2413,7 +2443,7 @@ MagickExport MagickPassFail ImageToFile(Image *image,const char *filename, assert(image->signature == MagickSignature); assert(filename != (const char *) NULL); - if (image->logging) + if (image->blob->logging) (void) LogMagickEvent(BlobEvent,GetMagickModule(), "Copying from Blob stream to file \"%s\"...",filename); if (MagickConfirmAccess(FileWriteConfirmAccessMode,filename,exception) @@ -2447,7 +2477,7 @@ MagickExport MagickPassFail ImageToFile(Image *image,const char *filename, break; } (void) close(file); - if (image->logging) + if (image->blob->logging) (void) LogMagickEvent(BlobEvent,GetMagickModule(), "Copied %"MAGICK_SIZE_T_F"u bytes from Blob stream to \"%s\"", (MAGICK_SIZE_T) total,filename); @@ -2672,8 +2702,8 @@ MagickExport void MSBOrderShort(unsigned char *p,const size_t length) % % OpenBlob() opens a file associated with the image. A file name of '-' sets % the file to stdin for type 'r' and stdout for type 'w'. If the filename -% suffix is '.gz' or '.Z', the image is decompressed for type 'r' and -% compressed for type 'w'. +% suffix is '.gz', the image is decompressed for type 'r' and compressed +% for type 'w'. % % The format of the OpenBlob method is: % @@ -2727,7 +2757,7 @@ MagickExport MagickPassFail OpenBlob(const ImageInfo *image_info,Image *image, assert(image_info->signature == MagickSignature); assert(image != (Image *) NULL); assert(image->signature == MagickSignature); - if (image->logging) + if (image->blob->logging) (void) LogMagickEvent(BlobEvent,GetMagickModule(), "Opening blob stream: image %p, blob %p," " mode %s ...", image, image->blob, @@ -2748,7 +2778,7 @@ MagickExport MagickPassFail OpenBlob(const ImageInfo *image_info,Image *image, if (image_info->blob != (void *) NULL) { AttachBlob(image->blob,image_info->blob,image_info->length); - if (image->logging) + if (image->blob->logging) (void) LogMagickEvent(BlobEvent,GetMagickModule(), " attached data blob (addr %p, len %" MAGICK_SIZE_T_F "u) to image %p, blob %p", @@ -2783,7 +2813,7 @@ MagickExport MagickPassFail OpenBlob(const ImageInfo *image_info,Image *image, if (*type == 'r') { image->blob->handle.std=stdin; - if (image->logging) + if (image->blob->logging) (void) LogMagickEvent(BlobEvent,GetMagickModule(), " using stdin as StandardStream image" " %p, blob %p", @@ -2792,7 +2822,7 @@ MagickExport MagickPassFail OpenBlob(const ImageInfo *image_info,Image *image, else { image->blob->handle.std=stdout; - if (image->logging) + if (image->blob->logging) (void) LogMagickEvent(BlobEvent,GetMagickModule(), " using stdout as StandardStream image" " %p, blob %p", @@ -2814,12 +2844,10 @@ MagickExport MagickPassFail OpenBlob(const ImageInfo *image_info,Image *image, */ if (!image_info->adjoin) FormMultiPartFilename(image,image_info); - (void) strcpy(filename,image->filename); + (void) strlcpy(filename,image->filename,sizeof(filename)); } #if defined(HasZLIB) && !defined(DISABLE_COMPRESSED_FILES) - if (((strlen(filename) > 2) && - (LocaleCompare(filename+strlen(filename)-2,".Z") == 0)) || - ((strlen(filename) > 3) && + if (((strlen(filename) > 3) && (LocaleCompare(filename+strlen(filename)-3,".gz") == 0)) || ((strlen(filename) > 5) && (LocaleCompare(filename+strlen(filename)-5,".svgz") == 0))) @@ -2832,7 +2860,7 @@ MagickExport MagickPassFail OpenBlob(const ImageInfo *image_info,Image *image, if (image->blob->handle.gz != (gzFile) NULL) { image->blob->type=ZipStream; - if (image->logging) + if (image->blob->logging) (void) LogMagickEvent(BlobEvent,GetMagickModule(), " opened file %s as ZipStream image" " %p, blob %p, mode %s", @@ -2840,7 +2868,7 @@ MagickExport MagickPassFail OpenBlob(const ImageInfo *image_info,Image *image, } else { - if (image->logging) + if (image->blob->logging) (void) LogMagickEvent(BlobEvent,GetMagickModule(), " failed to open file %s as ZipStream image" " %p, blob %p, mode %s", @@ -2861,7 +2889,7 @@ MagickExport MagickPassFail OpenBlob(const ImageInfo *image_info,Image *image, if (image->blob->handle.bz != (BZFILE *) NULL) { image->blob->type=BZipStream; - if (image->logging) + if (image->blob->logging) (void) LogMagickEvent(BlobEvent,GetMagickModule(), " opened file %s as BZipStream image" " %p, blob %p", @@ -2875,7 +2903,7 @@ MagickExport MagickPassFail OpenBlob(const ImageInfo *image_info,Image *image, image->blob->handle.std=image_info->file; image->blob->type=FileStream; image->blob->exempt=MagickTrue; - if (image->logging) + if (image->blob->logging) (void) LogMagickEvent(BlobEvent,GetMagickModule(), " opened image_info->file (%d) as" " FileStream image %p, blob %p", @@ -2903,11 +2931,12 @@ MagickExport MagickPassFail OpenBlob(const ImageInfo *image_info,Image *image, vbuf_size; vbuf_size=image->blob->block_size; - if (0 != vbuf_size) + image->blob->vbuf=MagickAllocateClearedMemory(char *, vbuf_size); + if ((0 != vbuf_size) && (image->blob->vbuf != (char *) NULL)) { - if (setvbuf(image->blob->handle.std,NULL,_IOFBF,vbuf_size) != 0) + if (setvbuf(image->blob->handle.std,image->blob->vbuf,_IOFBF,vbuf_size) != 0) { - if (image->logging) + if (image->blob->logging) (void) LogMagickEvent(BlobEvent,GetMagickModule(), " setvbuf of %" MAGICK_SIZE_T_F "u bytes returns failure!", @@ -2915,7 +2944,7 @@ MagickExport MagickPassFail OpenBlob(const ImageInfo *image_info,Image *image, } else { - if (image->logging) + if (image->blob->logging) (void) LogMagickEvent(BlobEvent,GetMagickModule(), " I/O buffer set to %" MAGICK_SIZE_T_F "u bytes", @@ -2931,13 +2960,13 @@ MagickExport MagickPassFail OpenBlob(const ImageInfo *image_info,Image *image, if (LocaleCompare(env,"TRUE") == 0) { image->blob->fsync=MagickTrue; - if (image->logging) + if (image->blob->logging) (void) LogMagickEvent(BlobEvent,GetMagickModule(), " fsync() on close requested"); } } image->blob->type=FileStream; - if (image->logging) + if (image->blob->logging) (void) LogMagickEvent(BlobEvent,GetMagickModule(), " opened file \"%s\" as FileStream image %p, blob %p", filename,image,image->blob); @@ -2962,7 +2991,7 @@ MagickExport MagickPassFail OpenBlob(const ImageInfo *image_info,Image *image, */ (void) fflush(image->blob->handle.std); #endif /* defined(POSIX) */ - if (image->logging) + if (image->blob->logging) (void) LogMagickEvent(BlobEvent,GetMagickModule(), " read %" MAGICK_SIZE_T_F "u magic header bytes", @@ -2976,7 +3005,7 @@ MagickExport MagickPassFail OpenBlob(const ImageInfo *image_info,Image *image, if (image->blob->handle.gz != (gzFile) NULL) { image->blob->type=ZipStream; - if (image->logging) + if (image->blob->logging) (void) LogMagickEvent(BlobEvent,GetMagickModule(), " reopened file \"%s\"" "as ZipStream image %p, blob %p", @@ -2993,7 +3022,7 @@ MagickExport MagickPassFail OpenBlob(const ImageInfo *image_info,Image *image, if (image->blob->handle.bz != (BZFILE *) NULL) { image->blob->type=BZipStream; - if (image->logging) + if (image->blob->logging) (void) LogMagickEvent(BlobEvent,GetMagickModule(), " reopened file %s as" " BZipStream image %p, blob %p", @@ -4511,28 +4540,123 @@ MagickExport size_t ReadBlobMSBShorts(Image *image, size_t octets, */ MagickExport char *ReadBlobString(Image *image,char *string) { + BlobInfo + * restrict blob; + + size_t + i = 0; + int c; - register unsigned int - i; - assert(image != (Image *) NULL); assert(image->signature == MagickSignature); - for (i=0; i < (MaxTextExtent-1); i++) - { - c=ReadBlobByte(image); - if (c == EOF) + assert(string != (char *) NULL); + + blob=image->blob; + + string[0] = '\0'; + + /* + Check if we will encounter read limit (assume that we will read + MaxTextExtent-1 characters) + */ + if ((blob->read_total + MaxTextExtent-1) > blob->read_limit) + { + blob->read_total = blob->read_limit; + if (MagickFalse == blob->eof) + { + blob->eof=MagickTrue; + if (blob->read_limit <= blob->read_total) + { + ThrowException(&image->exception,ResourceLimitError,ReadLimitExceeded, + image->filename); + } + } + return((char *) NULL); + } + + switch (blob->type) + { + case UndefinedStream: + break; + case FileStream: + case StandardStream: + case PipeStream: { - if (i == 0) - return((char *) NULL); + if (fgets(string,MaxTextExtent,blob->handle.std) != NULL) + { + i = strlen(string); + blob->read_total += i; + } + else + { + if (!(blob->status) && ferror(blob->handle.std)) + { + blob->status=1; + if (errno != 0) + blob->first_errno=errno; + } + return((char *) NULL); + } break; } - string[i]=c; - if ((string[i] == '\n') || (string[i] == '\r')) - break; - } - string[i]='\0'; + case ZipStream: + { +#if defined(HasZLIB) && !defined(DISABLE_COMPRESSED_FILES) + if (gzgets(blob->handle.gz, string, MaxTextExtent) != NULL) + { + i = strlen(string); + blob->read_total += i; + } + else + { + int + gzerror_errnum=Z_OK; + + (void) gzerror(blob->handle.gz,&gzerror_errnum); + if (gzerror_errnum != Z_OK) + { + blob->status=1; + if ((gzerror_errnum == Z_ERRNO) && (errno != 0)) + blob->first_errno=errno; + } + if (!blob->eof) + blob->eof = gzeof(blob->handle.gz); + } + break; +#endif + } + default : + { + i=0; + do + { + c=ReadBlobByte(image); + if (c == EOF) + { + if (!blob->eof) + blob->eof = MagickTrue; + break; + } + string[i] = c; + i++; + if (c == '\n') + break; + } while (i < MaxTextExtent-2); + string[i] = '\0'; + } + } + + /* Strip trailing NL and CR */ + while ((i > 0) && ((string[i-1] == '\r') || (string[i-1] == '\n'))) + { + --i; + string[i] = 0; + } + if ((i == 0) && (blob->eof)) + return((char *) NULL); + return(string); } @@ -4618,7 +4742,7 @@ MagickExport magick_off_t SeekBlob(Image *image,const magick_off_t offset, assert(image->blob != (BlobInfo *) NULL); assert(image->blob->type != UndefinedStream); #if 0 - if (image->logging) + if (image->blob->logging) (void) LogMagickEvent(BlobEvent,GetMagickModule(), "Seek %" MAGICK_OFF_F "d, whence = %s", offset, @@ -4654,29 +4778,34 @@ MagickExport magick_off_t SeekBlob(Image *image,const magick_off_t offset, return(-1); case BlobStream: { + magick_off_t + new_offset; + switch (whence) { case SEEK_SET: default: { - if (offset < 0) + new_offset=offset; + if (new_offset < 0) return(-1); - image->blob->offset=offset; + image->blob->offset=new_offset; break; } case SEEK_CUR: { - if ((image->blob->offset+offset) < 0) + new_offset=image->blob->offset+offset; + if (new_offset < 0) return(-1); - image->blob->offset+=offset; + image->blob->offset=new_offset; break; } case SEEK_END: { - if ((magick_off_t) - (image->blob->offset+image->blob->length+offset) < 0) + new_offset = ((magick_off_t) image->blob->length+offset); + if (new_offset < 0) return(-1); - image->blob->offset=image->blob->length+offset; + image->blob->offset=new_offset; break; } } @@ -5329,6 +5458,7 @@ MagickExport MagickPassFail WriteBlobFile(Image *image,const char *filename) */ MagickExport size_t WriteBlobLSBLong(Image *image,const magick_uint32_t value) { +#if defined(WORDS_BIGENDIAN) unsigned char buffer[4]; @@ -5339,6 +5469,12 @@ MagickExport size_t WriteBlobLSBLong(Image *image,const magick_uint32_t value) buffer[2]=(unsigned char) (value >> 16); buffer[3]=(unsigned char) (value >> 24); return(WriteBlob(image,4,buffer)); +#else + assert(image != (Image *) NULL); + assert(image->signature == MagickSignature); + assert(sizeof(value) == 4); + return(WriteBlob(image,4,&value)); +#endif } /* @@ -5473,6 +5609,21 @@ MagickExport size_t WriteBlobLSBSignedShort(Image *image,const magick_int16_t va buffer[1]=(unsigned char) (uvalue.uint16 >> 8); return(WriteBlob(image,2,buffer)); } + + +MagickExport size_t WriteBlobLSBDouble(Image *image, double d) +{ + assert(image != (Image *) NULL); + assert(image->signature == MagickSignature); + assert(sizeof(d) == 8); + +#if defined(WORDS_BIGENDIAN) + MagickSwabDouble(&d); +#endif + return(WriteBlob(image,8,&d)); +} + + /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -5525,6 +5676,7 @@ MagickExport size_t ReadBlobLSBShorts(Image *image, size_t octets, return octets_read; } + /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -5843,7 +5995,7 @@ MagickExport void DisassociateBlob(Image *image) assert(image->blob->signature == MagickSignature); clone=MagickFalse; LockSemaphoreInfo(image->blob->semaphore); - if (image->logging) + if (image->blob->logging) (void) LogMagickEvent(BlobEvent,GetMagickModule(), "Disassociate blob: image=%p, blob=%p, ref=%lu", image,image->blob,image->blob->reference_count); diff --git a/magick/blob.h b/magick/blob.h index 10669aa..b10b3ff 100644 --- a/magick/blob.h +++ b/magick/blob.h @@ -398,6 +398,7 @@ extern "C" { const magick_int32_t value); + extern MagickExport size_t WriteBlobLSBDouble(Image *image, double d); /* Write a 32-bit unsigned "long" value to the file or BLOB in big-endian diff --git a/magick/cdl.c b/magick/cdl.c index e33f11b..478e814 100644 --- a/magick/cdl.c +++ b/magick/cdl.c @@ -4,7 +4,7 @@ * American Society of Cinematographers Color Decision List (ASC-CDL) * implementation. * - * Original implementation by Clément Follet. Additional work by Bob + * Original implementation by CleÌment Follet. Additional work by Bob * Friesenhahn. */ diff --git a/magick/cdl.h b/magick/cdl.h index ffed18f..8c5b5be 100644 --- a/magick/cdl.h +++ b/magick/cdl.h @@ -4,7 +4,7 @@ * American Society of Cinematographers Color Decision List (ASC-CDL) * implementation. * - * Original implementation by Clément Follet. + * Original implementation by CleÌment Follet. */ #ifndef _MAGICK_CDL_H diff --git a/magick/color_lookup-private.h b/magick/color_lookup-private.h index 8985d4c..55a87aa 100644 --- a/magick/color_lookup-private.h +++ b/magick/color_lookup-private.h @@ -50,6 +50,42 @@ extern unsigned int extern MagickPassFail InitializeColorInfo(void); +#define BackgroundColor "#ffffffffffff" /* white */ +#define BackgroundColorInit(q) \ + do { SetRedSample(q,MaxRGB); \ + SetGreenSample(q,MaxRGB); \ + SetBlueSample(q,MaxRGB); \ + SetOpacitySample(q,0U); } while(0) + +#define BorderColor "#dfdfdfdfdfdf" /* gray */ +#define BorderColorInit(q) \ + do { \ + SetGraySample(q,ScaleShortToQuantum(0xdfdf)); \ + SetOpacitySample(q,0); \ + } while(0) + +#define ForegroundColor "#000000000000" /* black */ +#define ForegroundColorInit(q) \ + do { \ + SetGraySample(q,0); \ + SetOpacitySample(q,0); } \ + while(0) + +#define HighlightColor "#f1f100001e1e" /* light red */ +#define HighlightColorInit(q) \ + do { SetRedSample(q,ScaleShortToQuantum(0xf1f1)); \ + SetGreenSample(q,ScaleShortToQuantum(0x000)); \ + SetBlueSample(q,ScaleShortToQuantum(0x1e1e)); \ + SetOpacitySample(q,0); \ + } while(0) + +#define MatteColor "#bdbdbdbdbdbd" /* gray */ +#define MatteColorInit(q) \ + do { \ + SetGraySample(q,ScaleShortToQuantum(0xbdbd)); \ + SetOpacitySample(q,0); \ + } while(0) + /* * Local Variables: * mode: c diff --git a/magick/colorspace.c b/magick/colorspace.c index 40cd2ee..63b3db7 100644 --- a/magick/colorspace.c +++ b/magick/colorspace.c @@ -258,7 +258,7 @@ XYZTransformPackets(void *mutable_data, /* User provided mutable data * /* 3D transform pixels from RGB to alternate colorspace. */ - float + double b, g, r; @@ -285,17 +285,17 @@ XYZTransformPackets(void *mutable_data, /* User provided mutable data * y_index = ScaleQuantumToMap(pixels[i].green); z_index = ScaleQuantumToMap(pixels[i].blue); - r = (xform->x[x_index].x + xform->y[y_index].x + xform->z[z_index].x + xform->primary_info.x); - g = (xform->x[x_index].y + xform->y[y_index].y + xform->z[z_index].y + xform->primary_info.y); - b = (xform->x[x_index].z + xform->y[y_index].z + xform->z[z_index].z + xform->primary_info.z); + r = xform->x[x_index].x + xform->y[y_index].x + xform->z[z_index].x + xform->primary_info.x; + g = xform->x[x_index].y + xform->y[y_index].y + xform->z[z_index].y + xform->primary_info.y; + b = xform->x[x_index].z + xform->y[y_index].z + xform->z[z_index].z + xform->primary_info.z; - r = r < 0.0f ? 0.0f : r > MaxMapFloat ? MaxMapFloat : (r + 0.5f); - g = g < 0.0f ? 0.0f : g > MaxMapFloat ? MaxMapFloat : (g + 0.5f); - b = b < 0.0f ? 0.0f : b > MaxMapFloat ? MaxMapFloat : (b + 0.5f); + r = r < 0.0 ? 0.0 : r > MaxMapDouble ? MaxMapDouble : (r + 0.5); + g = g < 0.0 ? 0.0 : g > MaxMapDouble ? MaxMapDouble : (g + 0.5); + b = b < 0.0 ? 0.0 : b > MaxMapDouble ? MaxMapDouble : (b + 0.5); - pixels[i].red = ScaleMapToQuantum((Quantum) r); - pixels[i].green = ScaleMapToQuantum((Quantum) g); - pixels[i].blue = ScaleMapToQuantum((Quantum) b); + pixels[i].red = ScaleMapToQuantum(floor(r)); + pixels[i].green = ScaleMapToQuantum(floor(g)); + pixels[i].blue = ScaleMapToQuantum(floor(b)); } return MagickPass; @@ -1266,7 +1266,7 @@ RGBTransformPackets(void *mutable_data, /* User provided mutable data */ /* 3D transform pixels to RGB. */ - float + double b, g, r; @@ -1293,13 +1293,13 @@ RGBTransformPackets(void *mutable_data, /* User provided mutable data */ g_index = ScaleQuantumToMap(pixels[i].green); b_index = ScaleQuantumToMap(pixels[i].blue); - r = (xform->r[r_index].r + xform->g[g_index].r + xform->b[b_index].r); - g = (xform->r[r_index].g + xform->g[g_index].g + xform->b[b_index].g); - b = (xform->r[r_index].b + xform->g[g_index].b + xform->b[b_index].b); + r = xform->r[r_index].r + xform->g[g_index].r + xform->b[b_index].r; + g = xform->r[r_index].g + xform->g[g_index].g + xform->b[b_index].g; + b = xform->r[r_index].b + xform->g[g_index].b + xform->b[b_index].b; - r = r < 0.0f ? 0.0f : r > MaxMapFloat ? MaxMapFloat : (r + 0.5f); - g = g < 0.0f ? 0.0f : g > MaxMapFloat ? MaxMapFloat : (g + 0.5f); - b = b < 0.0f ? 0.0f : b > MaxMapFloat ? MaxMapFloat : (b + 0.5f); + r = r < 0.0 ? 0.0 : r > MaxMapDouble ? MaxMapDouble : (r + 0.5); + g = g < 0.0 ? 0.0 : g > MaxMapDouble ? MaxMapDouble : (g + 0.5); + b = b < 0.0 ? 0.0 : b > MaxMapDouble ? MaxMapDouble : (b + 0.5); if ( xform->rgb_map != 0 ) { @@ -1317,9 +1317,9 @@ RGBTransformPackets(void *mutable_data, /* User provided mutable data */ } else { - pixels[i].red = ScaleMapToQuantum(r); - pixels[i].green = ScaleMapToQuantum(g); - pixels[i].blue = ScaleMapToQuantum(b); + pixels[i].red = ScaleMapToQuantum(floor(r)); + pixels[i].green = ScaleMapToQuantum(floor(g)); + pixels[i].blue = ScaleMapToQuantum(floor(b)); } } diff --git a/magick/command.c b/magick/command.c index f51017a..1b51eac 100644 --- a/magick/command.c +++ b/magick/command.c @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003 - 2022 GraphicsMagick Group +% Copyright (C) 2003 - 2023 GraphicsMagick Group % Copyright (C) 2002 ImageMagick Studio % % This program is covered by multiple licenses, which are described in @@ -129,13 +129,19 @@ typedef int (*CommandLineParser)(FILE *in, int acmax, char **av); #define SIZE_OPTION_VALUE 256 typedef struct _BatchOptions { - MagickBool stop_on_error, - is_feedback_enabled, - is_echo_enabled; - char prompt[SIZE_OPTION_VALUE], - pass[SIZE_OPTION_VALUE], - fail[SIZE_OPTION_VALUE]; - CommandLineParser command_line_parser; + MagickBool + stop_on_error, + is_feedback_enabled, + is_echo_enabled, + is_tap_mode; + + char + prompt[SIZE_OPTION_VALUE], + pass[SIZE_OPTION_VALUE], + fail[SIZE_OPTION_VALUE]; + + CommandLineParser + command_line_parser; } BatchOptions; typedef MagickPassFail (*CommandVectorHandler)(ImageInfo *image_info, @@ -1161,7 +1167,11 @@ MagickExport MagickPassFail AnimateImageCommand(ImageInfo *image_info, { if (LocaleCompare("map",option+1) == 0) { - (void) strcpy(argv[i]+1,"sans"); + /* + Indicate that option was already handled so + MogrifyImage() will ignore it. + */ + (void) strlcpy(argv[i]+1,"Z",strlen(argv[i]+1)+1); resource_info.map_type=(char *) NULL; if (*option == '-') { @@ -1470,6 +1480,7 @@ MagickExport MagickPassFail AnimateImageCommand(ImageInfo *image_info, (void) CatchImageException(image); AppendImageToList(&image_list,image); } + image_list=GetFirstImageInList(image_list); if (resource_info.window_id != (char *) NULL) MagickXAnimateBackgroundImage(display,&resource_info,image_list); else @@ -1542,6 +1553,7 @@ static MagickPassFail BatchCommand(int argc, char **argv) MagickBool hasInputFile; int ac; char *av[MAX_PARAM+1]; + unsigned int line_no = 0; #if defined(MSWINDOWS) InitializeMagick((char *) NULL); @@ -1595,9 +1607,15 @@ static MagickPassFail BatchCommand(int argc, char **argv) (void) fflush(stdout); } + while (!(ferror(stdin) || ferror(stdout) || ferror(stderr) || feof(stdin))) { - if (batch_options.prompt[0]) + if (batch_options.is_tap_mode) + { + (void) fputs("# ", stdout); + (void) fflush(stdout); + } + else if (batch_options.prompt[0]) { (void) fputs(batch_options.prompt, stdout); (void) fflush(stdout); @@ -1609,7 +1627,7 @@ static MagickPassFail BatchCommand(int argc, char **argv) result = MagickPass; break; }; - if (batch_options.is_echo_enabled) + if (batch_options.is_tap_mode || batch_options.is_echo_enabled) { int i; for (i = 1; i < ac; i++) @@ -1636,8 +1654,14 @@ static MagickPassFail BatchCommand(int argc, char **argv) MAX_PARAM); result = MagickFail; } + ++line_no; - if (batch_options.is_feedback_enabled) + if (batch_options.is_tap_mode) + { + /* FIXME: Support TAP test description */ + (void) fprintf(stdout, "%s %u\n", result ? "ok" : "not ok", line_no); + } + else if (batch_options.is_feedback_enabled) { (void) fputs(result ? batch_options.pass : batch_options.fail, stdout); (void) fputc('\n', stdout); @@ -1649,7 +1673,7 @@ static MagickPassFail BatchCommand(int argc, char **argv) break; } - if (batch_options.prompt[0]) + if (!batch_options.is_tap_mode && batch_options.prompt[0]) { (void) fputs("\n", stdout); (void) fflush(stdout); @@ -1697,6 +1721,12 @@ static void BatchOptionUsage(void) " -stop-on-error on|off\n" " when turned on, batch execution quits prematurely when\n" " any command returns error\n" + " -tap-mode on|off\n" + " when turned on, a simple implementation of Test Anything\n" + " Protocol (TAP) is enabled to produce \"ok N\" and \n" + " \"not ok N\" feedback to indicate the test number, and to\n" + " supplant the function of -fail, -pass, -feedback in order\n" + " to support simple TAP output messaging\n" "\n" "Unix escape allows the use backslash(\\), single quote(') and double quote(\") in\n" "the command line. Windows escape only uses double quote(\"). For example,\n" @@ -3796,8 +3826,12 @@ MagickExport MagickPassFail CompositeImageCommand(ImageInfo *image_info, break; if (LocaleCompare("noop",option+1) == 0) { + if (image == NULL) + ThrowCompositeException(OptionError,NoImagesDefined, + "no images in composite image list"); + status&=CompositeImageList(image_info,&image,composite_image, - mask_image,&option_info,exception); + mask_image,&option_info,exception); if (composite_image != (Image *) NULL) { DestroyImageList(composite_image); @@ -5590,6 +5624,11 @@ MagickExport MagickPassFail ConvertImageCommand(ImageInfo *image_info, ThrowConvertException(OptionError,MissingArgument, option); } + else + { + ThrowConvertException(OptionError,MissingArgument, + option); + } break; } if (LocaleCompare("ordered-dither",option+1) == 0) @@ -5778,7 +5817,7 @@ MagickExport MagickPassFail ConvertImageCommand(ImageInfo *image_info, if (*option == '-') { i++; - if ((i == (argc-1)) || !IsGeometry(argv[i])) + if ((i == argc) || !IsGeometry(argv[i])) ThrowConvertException(OptionError,MissingArgument,option); } break; @@ -6215,15 +6254,18 @@ MagickExport MagickPassFail ConvertImageCommand(ImageInfo *image_info, ThrowConvertException(OptionError,MissingAnImageFilename,(char *) NULL); if (image == (Image *) NULL) { - status&=MogrifyImages(image_info,i-j,argv+j,&image_list); + if (!ping) + status&=MogrifyImages(image_info,i-j,argv+j,&image_list); GetImageException(image_list,exception); } else { - status&=MogrifyImages(image_info,i-j,argv+j,&image); + if (!ping) + status&=MogrifyImages(image_info,i-j,argv+j,&image); GetImageException(image,exception); AppendImageToList(&image_list,image); } + image_list=GetFirstImageInList(image_list); status&=WriteImages(image_info,image_list,argv[argc-1],exception); if (metadata != (char **) NULL) { @@ -6481,7 +6523,7 @@ static void ConjureUsage(void) (void) puts(" -verbose print detailed information about the image"); (void) puts(" -version print version information"); (void) puts(""); - (void) puts("In additiion, define any key value pairs required by your script. For"); + (void) puts("In addition, define any key value pairs required by your script. For"); (void) puts("example,"); (void) puts(""); (void) puts(" conjure -size 100x100 -color blue -foo bar script.msl"); @@ -6582,10 +6624,12 @@ MagickExport MagickPassFail ConjureImageCommand(ImageInfo *image_info, Persist key/value pair. */ (void) SetImageAttribute(image_info->attributes,option+1,(char *) NULL); - status&=SetImageAttribute(image_info->attributes,option+1,argv[i+1]); + i++; + if (i == argc) + MagickFatalError(OptionFatalError,MissingArgument,option); + status&=SetImageAttribute(image_info->attributes,option+1,argv[i]); if (status == MagickFail) MagickFatalError(ImageFatalError,UnableToPersistKey,option); - i++; continue; } /* @@ -6922,7 +6966,7 @@ MagickExport MagickPassFail DisplayImageCommand(ImageInfo *image_info, (void) MagickSceneFileName(filename,image_info->filename,".%lu",MagickTrue,scene); (void) strlcpy(image_info->filename,filename,MaxTextExtent); } - (void) strcpy(image_info->magick,"MIFF"); + (void) strlcpy(image_info->magick,"MIFF",sizeof(image_info->magick)); image_info->colorspace=quantize_info->colorspace; image_info->dither=quantize_info->dither; DestroyExceptionInfo(exception); @@ -7590,7 +7634,11 @@ MagickExport MagickPassFail DisplayImageCommand(ImageInfo *image_info, } if (LocaleCompare("map",option+1) == 0) { - (void) strcpy(argv[i]+1,"sans"); + /* + Indicate that option was already handled so + MogrifyImage() will ignore it. + */ + (void) strlcpy(argv[i]+1,"Z",strlen(argv[i]+1)+1); resource_info.map_type=(char *) NULL; if (*option == '-') { @@ -8834,15 +8882,15 @@ static void IdentifyUsage(void) */ static void InitializeBatchOptions(MagickBool prompt) { - strcpy(batch_options.pass, "PASS"); - strcpy(batch_options.fail, "FAIL"); + strlcpy(batch_options.pass, "PASS", sizeof(batch_options.pass)); + strlcpy(batch_options.fail, "FAIL", sizeof(batch_options.fail)); #if defined(MSWINDOWS) batch_options.command_line_parser = ParseWindowsCommandLine; #else batch_options.command_line_parser = ParseUnixCommandLine; #endif if (prompt) - strcpy(batch_options.prompt, "GM> "); + strlcpy(batch_options.prompt, "GM> ", sizeof(batch_options.prompt)); } @@ -8942,12 +8990,9 @@ MagickExport MagickPassFail MagickCommand(ImageInfo *image_info, char command_name[MaxTextExtent]; - const char - *pos; - /* - Append subcommand name to existing client name if end of - existing client name is not identical to subcommand name. + Append subcommand name to existing client name if existing + client name is not identical to subcommand name. */ LockSemaphoreInfo(command_semaphore); if (run_mode == BatchMode) @@ -8955,9 +9000,7 @@ MagickExport MagickPassFail MagickCommand(ImageInfo *image_info, else { GetPathComponent(GetClientName(),BasePath,command_name); - pos=strrchr(command_name,' '); - if ((pos == (const char *) NULL) || - (LocaleCompare(commands[i].command,pos+1) != 0)) + if (LocaleCompare(commands[i].command,command_name) != 0) { char client_name[MaxTextExtent]; @@ -9421,6 +9464,11 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info, type=(*option); option=argv[++i]; colorspace=StringToColorspaceType(option); + if (colorspace == UndefinedColorspace) + { + ThrowException(&(*image)->exception,OptionError,MissingArgument,"colorspace"); + break; + } quantize_info.colorspace=colorspace; /* Never quantize in CMYK colorspace */ if (IsCMYKColorspace(colorspace)) @@ -9681,7 +9729,12 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info, */ MagickFreeMemory(draw_info->primitive); draw_info->primitive=AmpersandTranslateText(clone_info,*image,argv[++i]); - (void) DrawImage(*image,draw_info); + if (draw_info->primitive == (char *) NULL) + { + ThrowException(&(*image)->exception,OptionError,MissingArgument,option); + break; + } + (void) DrawImage(*image,draw_info); continue; } break; @@ -10093,10 +10146,16 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info, /* Local adaptive threshold image. */ - offset=0; - height=3; - width=3; - (void) sscanf(argv[++i],"%lux%lu%lf",&width,&height,&offset); + if (sscanf(argv[++i],"%lux%lu%lf",&width,&height,&offset) != 3) + { + ThrowException(&(*image)->exception,OptionError,MissingArgument,option); + break; + } + if ((width == 0) || (height == 0)) + { + ThrowException3(&(*image)->exception,OptionError,UnableToThresholdImage,NonzeroWidthAndHeightRequired); + break; + } if (strchr(argv[i],'%') != (char *) NULL) offset*=((double) MaxRGB/100.0); threshold_image=AdaptiveThresholdImage(*image,width,height,offset, @@ -10360,34 +10419,53 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info, } if (LocaleCompare("operator",option+1) == 0) { - ChannelType - channel; + if (*option == '-') + { + ChannelType + channel; - QuantumOperator - quantum_operator; + QuantumOperator + quantum_operator; - double - rvalue; + double + rvalue; - /* channel */ - channel=StringToChannelType(argv[++i]); + if (i+3 > argc) + { + ThrowException(&(*image)->exception,OptionError,MissingArgument,option+1); + break; + } - /* operator id */ - quantum_operator=StringToQuantumOperator(argv[++i]); + /* channel */ + channel=StringToChannelType(argv[++i]); - /* rvalue */ - option=argv[++i]; - rvalue=StringToDouble(option,MaxRGB); - (void) QuantumOperatorImage(*image,channel,quantum_operator, - rvalue,&(*image)->exception); + /* operator id */ + quantum_operator=StringToQuantumOperator(argv[++i]); - continue; + /* rvalue */ + option=argv[++i]; + rvalue=StringToDouble(option,MaxRGBDouble); + (void) QuantumOperatorImage(*image,channel,quantum_operator, + rvalue,&(*image)->exception); + + continue; + } + else + { + ThrowException(&(*image)->exception,OptionError,MissingArgument,option+1); + break; + } } if (LocaleCompare("ordered-dither",option+1) == 0) { /* Ordered-dither image. */ + if (i+2 > argc) + { + ThrowException(&(*image)->exception,OptionError,MissingArgument,option+1); + break; + } (void) RandomChannelThresholdImage(*image,argv[i+1],argv[i+2], &(*image)->exception); i+=2; @@ -10589,6 +10667,11 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info, /* Threshold image. */ + if (i+2 > argc) + { + ThrowException(&(*image)->exception,OptionError,MissingArgument,option+1); + break; + } (void) RandomChannelThresholdImage(*image,argv[i+1],argv[i+2], &(*image)->exception); i+=2; @@ -10685,6 +10768,7 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info, region_geometry.y); DestroyImage(*image); *image=region_image; + region_image=(Image *) NULL; } if (*option == '+') continue; @@ -10896,9 +10980,6 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info, NormalizeSamplingFactor(clone_info); continue; } - if (LocaleCompare("sans",option+1) == 0) - if (*option == '-') - i++; if (LocaleCompare("scale",option+1) == 0) { Image @@ -10930,10 +11011,20 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info, *key, *value; + if (i+1 > argc) + { + ThrowException(&(*image)->exception,OptionError,MissingArgument,option+1); + break; + } key=argv[++i]; (void) SetImageAttribute(*image,key,(char *) NULL); if (*option == '-') { + if (i+1 > argc) + { + ThrowException(&(*image)->exception,OptionError,MissingArgument,option+1); + break; + } value=argv[++i]; (void) SetImageAttribute(*image,key,value); } @@ -11388,11 +11479,25 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info, } break; } + case 'Z': + { + /* + Option -Z (used to be "sans") indicates an already handled + option (so ignore it). + */ + if (LocaleCompare("Z",option+1) == 0) + if (*option == '-') + { + i++; + continue; + } + break; + } default: break; } } - if (region_image != (Image *) NULL) + if ((region_image != (Image *) NULL) && (region_image != *image)) { /* Composite transformed region onto image. @@ -11564,6 +11669,7 @@ MagickExport MagickPassFail MogrifyImages(const ImageInfo *image_info, } AppendImageToList(&mogrify_images,image); } + mogrify_images=GetFirstImageInList(mogrify_images); /* Apply options to the entire image list. @@ -11945,7 +12051,7 @@ static MagickPassFail* TransmogrifyImage(TransmogrifyOptions *options) if (IsWriteable(output_filename)) { (void) strlcpy(temporary_filename,output_filename,MaxTextExtent); - (void) strcat(temporary_filename,"~"); + (void) strlcat(temporary_filename,"~",sizeof(temporary_filename)); if (rename(output_filename,temporary_filename) == 0) { if (image_info->verbose) @@ -12671,7 +12777,7 @@ MagickExport MagickPassFail MogrifyImageCommand(ImageInfo *image_info, option); (void) CloneString(&format,argv[i]); (void) strlcpy(image_info->filename,format,MaxTextExtent); - (void) strcat(image_info->filename,":"); + (void) strlcat(image_info->filename,":",sizeof(image_info->filename)); (void) SetImageInfo(image_info,SETMAGICK_WRITE,exception); if (*image_info->magick == '\0') ThrowMogrifyException(OptionError,UnrecognizedImageFormat,format); @@ -13202,6 +13308,11 @@ MagickExport MagickPassFail MogrifyImageCommand(ImageInfo *image_info, ThrowMogrifyException(OptionError,MissingArgument, option); } + else + { + ThrowMogrifyException(OptionError,MissingArgument, + option); + } break; } if (LocaleCompare("ordered-dither",option+1) == 0) @@ -13378,16 +13489,6 @@ MagickExport MagickPassFail MogrifyImageCommand(ImageInfo *image_info, if (*option == '-') { i++; - if ((i == (argc-1)) || !IsGeometry(argv[i])) - ThrowMogrifyException(OptionError,MissingArgument,option); - } - break; - } - if (LocaleCompare("resize",option+1) == 0) - { - if (*option == '-') - { - i++; if ((i == argc) || !IsGeometry(argv[i])) ThrowMogrifyException(OptionError,MissingArgument,option); } @@ -13399,8 +13500,7 @@ MagickExport MagickPassFail MogrifyImageCommand(ImageInfo *image_info, { i++; if ((i == argc) || !IsGeometry(argv[i])) - ThrowMogrifyException(OptionError,MissingArgument, - option); + ThrowMogrifyException(OptionError,MissingArgument,option); } break; } @@ -14584,7 +14684,11 @@ MagickExport MagickPassFail MontageImageCommand(ImageInfo *image_info, if (LocaleCompare("frame",option+1) == 0) { (void) CloneString(&montage_info->frame,(char *) NULL); - (void) strcpy(argv[i]+1,"sans"); + /* + Indicate that option was already handled so + MogrifyImage() will ignore it. + */ + (void) strlcpy(argv[i]+1,"Z",strlen(argv[i]+1)+1); if (*option == '-') { i++; @@ -14813,6 +14917,10 @@ MagickExport MagickPassFail MontageImageCommand(ImageInfo *image_info, break; ThrowMontageException(OptionError,UnrecognizedOption,option) } + case 'o': + { + ThrowMontageException(OptionError,UnrecognizedOption,option) + } case 'p': { if (LocaleCompare("page",option+1) == 0) @@ -15031,7 +15139,11 @@ MagickExport MagickPassFail MontageImageCommand(ImageInfo *image_info, if (LocaleCompare("tile",option+1) == 0) { (void) CloneString(&montage_info->tile,(char *) NULL); - (void) strcpy(argv[i]+1,"sans"); + /* + Indicate that option was already handled so + MogrifyImage() will ignore it. + */ + (void) strlcpy(argv[i]+1,"Z",strlen(argv[i]+1)+1); if (*option == '-') { i++; @@ -15097,7 +15209,11 @@ MagickExport MagickPassFail MontageImageCommand(ImageInfo *image_info, } break; } - ThrowMontageException(OptionError,UnrecognizedOption,option) + ThrowMontageException(OptionError,UnrecognizedOption,option); + } + case 'u': + { + ThrowMontageException(OptionError,UnrecognizedOption,option); } case 'v': { @@ -15168,6 +15284,7 @@ MagickExport MagickPassFail MontageImageCommand(ImageInfo *image_info, */ (void) strlcpy(montage_info->filename,argv[argc-1],MaxTextExtent); /* (void) memmove(montage_info->filename,argv[argc-1],strlen(argv[argc-1])+1); */ + image_list=GetFirstImageInList(image_list); montage_image=MontageImages(image_list,montage_info,exception); if (montage_image == (Image *) NULL) ThrowMontageException(OptionError,RequestDidNotReturnAnImage,(char *) NULL); @@ -16061,7 +16178,11 @@ MagickExport MagickPassFail ImportImageCommand(ImageInfo *image_info, } if (LocaleCompare("snaps",option+1) == 0) { - (void) strcpy(argv[i]+1,"sans"); + /* + Indicate that option was already handled so + MogrifyImage() will ignore it. + */ + (void) strlcpy(argv[i]+1,"Z",strlen(argv[i]+1)+1); i++; if ((i == argc) || !sscanf(argv[i],"%ld",&x)) MagickFatalError(OptionFatalError,MissingArgument,option); @@ -16178,8 +16299,8 @@ MagickExport MagickPassFail ImportImageCommand(ImageInfo *image_info, status&=next_image != (Image *) NULL; if (next_image == (Image *) NULL) continue; - (void) strlcpy(next_image->filename,filename,MaxTextExtent); - (void) strcpy(next_image->magick,"PS"); + (void) strlcpy(next_image->filename,filename,sizeof(next_image->filename)); + (void) strlcpy(next_image->magick,"PS",sizeof(next_image->magick)); next_image->scene=i; next_image->previous=image; if (image != (Image *) NULL) @@ -16665,6 +16786,10 @@ static int ProcessBatchOptions(int argc, char **argv, BatchOptions *options) if (LocaleCompare(option = "-stop-on-error", p) == 0) status = GetOnOffOptionValue(option, argv[++i], &options->stop_on_error); break; + case 't': + if (LocaleCompare(option = "-tap-mode", p) == 0) + status = GetOnOffOptionValue(option, argv[++i], &options->is_tap_mode); + break; } if (status == OptionSuccess) continue; @@ -16741,6 +16866,8 @@ static unsigned int SetCommand(ImageInfo *image_info, printf("stop-on-error : %s\n", on_off_option_values[batch_options.stop_on_error]); printf("pass : %s\n", batch_options.pass); printf("prompt : %s\n", batch_options.prompt); + printf("tap-mode : %s\n", on_off_option_values[batch_options.is_tap_mode]); + return MagickTrue; } @@ -17366,8 +17493,8 @@ static MagickPassFail RegisterCommand(ImageInfo *image_info, ARG_NOT_USED(exception); memset(szKey, 0, _MAX_PATH*2*sizeof(char)); - strcpy(szKey, szRegPath); - strcat(szKey, "GraphicsMagick"); + strlcpy(szKey, szRegPath, sizeof(szKey)); + strlcat(szKey, "GraphicsMagick", sizeof(szKey)); /* open the registry event source key */ lRet = RegCreateKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, NULL, diff --git a/magick/common.h b/magick/common.h index 1fc2e94..377d728 100644 --- a/magick/common.h +++ b/magick/common.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2009-2016 GraphicsMagick Group + Copyright (C) 2009-2022 GraphicsMagick Group This program is covered by multiple licenses, which are described in Copyright.txt. You should have received a copy of Copyright.txt with this @@ -145,9 +145,17 @@ extern "C" { # if ((MAGICK_HAS_ATTRIBUTE(__malloc__)) || \ (__GNUC__ >= 3)) /* 3.0+ */ # define MAGICK_FUNC_MALLOC MAGICK_ATTRIBUTE((__malloc__)) +# if (__GNUC__ >= 11) /* Clang 15 does not support extended malloc attributes */ +/* # warning "Using extended malloc attribute!" */ +# define MAGICK_FUNC_MALLOC_1ARG(deallocator) MAGICK_ATTRIBUTE((__malloc__,__malloc__(deallocator))) +# define MAGICK_FUNC_MALLOC_2ARG(deallocator, ptrindex) MAGICK_ATTRIBUTE((__malloc__,__malloc__(deallocator,ptrindex))) +# else +# define MAGICK_FUNC_MALLOC_1ARG(deallocator) MAGICK_ATTRIBUTE((__malloc__)) +# define MAGICK_FUNC_MALLOC_2ARG(deallocator, ptrindex) MAGICK_ATTRIBUTE((__malloc__)) +# endif # endif # if ((MAGICK_HAS_ATTRIBUTE(__nonnull__)) || \ - (((__GNUC__) > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)))) /* 3.3+ */ + (((__GNUC__) >= 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)))) /* 3.3+ */ /* Supports argument syntax like MAGICK_ATTRIBUTE((nonnull (1, 2))) but don't know how to support non-GCC fallback. */ # define MAGICK_FUNC_NONNULL MAGICK_ATTRIBUTE((__nonnull__)) @@ -244,6 +252,12 @@ extern "C" { #if !defined(MAGICK_FUNC_MALLOC) # define MAGICK_FUNC_MALLOC /*nothing*/ #endif +#if !defined(MAGICK_FUNC_MALLOC_1ARG) +# define MAGICK_FUNC_MALLOC_1ARG(deallocator) /*nothing*/ +#endif +#if !defined(MAGICK_FUNC_MALLOC_2ARG) +# define MAGICK_FUNC_MALLOC_2ARG(deallocator,ptrindex) /*nothing*/ +#endif #if !defined (MAGICK_FUNC_NONNULL) # define MAGICK_FUNC_NONNULL /*nothing*/ #endif diff --git a/magick/compare.c b/magick/compare.c index 3538fd7..adce81b 100644 --- a/magick/compare.c +++ b/magick/compare.c @@ -990,10 +990,13 @@ InitializeDifferenceImageOptions(DifferenceImageOptions *options, ExceptionInfo *exception) { assert(options != (DifferenceImageOptions *) NULL); + ARG_NOT_USED(exception); + memset(options,0,sizeof(DifferenceImageOptions)); options->channel=AllChannels; options->highlight_style=TintHighlightStyle; - (void) QueryColorDatabase(HighlightColor,&options->highlight_color,exception); + /* (void) QueryColorDatabase(HighlightColor,&options->highlight_color,exception); */ + HighlightColorInit(&options->highlight_color); } diff --git a/magick/constitute.c b/magick/constitute.c index a25389b..165aec6 100644 --- a/magick/constitute.c +++ b/magick/constitute.c @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003 - 2020 GraphicsMagick Group +% Copyright (C) 2003 - 2022 GraphicsMagick Group % Copyright (C) 2002 ImageMagick Studio % % This program is covered by multiple licenses, which are described in @@ -569,7 +569,8 @@ MagickExport Image *ConstituteImage(const unsigned long width, } } } - indexes++; + if (NULL != (IndexPacket *) indexes) + indexes++; q++; } if (!SyncImagePixels(image)) @@ -1444,17 +1445,17 @@ static void RemoveTemporaryInputFile(ImageInfo *image_info) (LocaleCompare(image_info->filename+filename_length-4,".mpc") == 0)) { char remove_name[MaxTextExtent]; - (void) strcpy(remove_name,image_info->filename); + (void) strlcpy(remove_name,image_info->filename,sizeof(remove_name)); remove_name[filename_length-4]=0; - (void) strcat(remove_name,".cache"); + (void) strlcat(remove_name,".cache",sizeof(remove_name)); (void) printf("removing %s\n", remove_name); (void) remove(remove_name); } else if (LocaleCompare(image_info->magick,"mpc") == 0) { char remove_name[MaxTextExtent]; - (void) strcpy(remove_name,image_info->filename); - (void) strcat(remove_name,".cache"); + (void) strlcpy(remove_name,image_info->filename,sizeof(remove_name)); + (void) strlcat(remove_name,".cache",sizeof(remove_name)); (void) printf("removing %s\n", remove_name); (void) remove(remove_name); } @@ -1462,6 +1463,57 @@ static void RemoveTemporaryInputFile(ImageInfo *image_info) errno=0; } +/* + Test if image list is a simple ordered list already in the bounds of + subimage/subrange or if it needs to be reconciled. +*/ +static MagickBool MagickReconcileListNeeded(const Image* image, const ImageInfo *image_info) MAGICK_FUNC_PURE; +static MagickBool MagickReconcileListNeeded(const Image* image, const ImageInfo *image_info) +{ + const Image + *list; + + const unsigned long + min_scene = image_info->subimage, + max_scene = image_info->subimage+image_info->subrange; + + MagickBool + res = MagickFalse; + + do + { + if (strchr(image_info->tile, ',') != (char *) NULL) + { + res=MagickTrue; + break; + } + + for (list = image; list != (Image *) NULL; list=list->next) + { + if (!(list->scene >= min_scene)) + { + res=MagickTrue; + break; + } + + if (!(list->scene < max_scene)) + { + res=MagickTrue; + break; + } + + if ((list->next) && (list->scene+1 != list->next->scene)) + { + res=MagickTrue; + break; + } + } + + } while (0); + + return res; +} + MagickExport Image *ReadImage(const ImageInfo *image_info, ExceptionInfo *exception) { @@ -1633,6 +1685,7 @@ MagickExport Image *ReadImage(const ImageInfo *image_info, if (image != (Image *) NULL) { + image=GetFirstImageInList(image); (void) LogMagickEvent(CoderEvent,GetMagickModule(), "Returned from \"%.1024s\" decoder: frames=%lu cache=%s" " monochrome=%s grayscale=%s class=%s colorspace=%s", @@ -1749,6 +1802,7 @@ MagickExport Image *ReadImage(const ImageInfo *image_info, if (image != (Image *) NULL) { + image=GetFirstImageInList(image); (void) LogMagickEvent(CoderEvent,GetMagickModule(), "Returned from \"%.1024s\" decoder: frames=%lu" " cache=%s monochrome=%s grayscale=%s class=%s" @@ -1817,7 +1871,8 @@ MagickExport Image *ReadImage(const ImageInfo *image_info, if (GetBlobTemporary(image)) RemoveTemporaryInputFile(clone_info); - if ((image->next != (Image *) NULL) && IsSubimage(clone_info->tile,False)) + if ((image->next != (Image *) NULL) && IsSubimage(clone_info->tile,False) && + MagickReconcileListNeeded(image,clone_info)) { char *q; @@ -2167,7 +2222,7 @@ WriteImage(const ImageInfo *image_info,Image *image) assert(image->signature == MagickSignature); if (LocaleNCompare(image_info->magick,"INFO",sizeof("INFO")-1)) GetTimerInfo(&image->timer); - image->logging=IsEventLogging(); + image->logging=IsEventLogged(CoderEvent); clone_info=CloneImageInfo(image_info); (void) strlcpy(clone_info->filename,image->filename,MaxTextExtent); (void) strlcpy(clone_info->magick,image->magick,MaxTextExtent); @@ -2402,7 +2457,7 @@ WriteImages(const ImageInfo *image_info,Image *image, assert(image != (Image *) NULL); assert(image->signature == MagickSignature); assert(exception != (ExceptionInfo *) NULL); - image->logging=IsEventLogging(); + image->logging=IsEventLogged(CoderEvent); clone_info=CloneImageInfo(image_info); if (clone_info) { @@ -2490,7 +2545,7 @@ MagickExport MagickPassFail WriteImagesFile(const ImageInfo *image_info,Image *i assert(image != (Image *) NULL); assert(image->signature == MagickSignature); assert(exception != (ExceptionInfo *) NULL); - image->logging=IsEventLogging(); + image->logging=IsEventLogged(CoderEvent); clone_info=CloneImageInfo(image_info); if (clone_info) { diff --git a/magick/delegate.c b/magick/delegate.c index 8777701..a4893ce 100644 --- a/magick/delegate.c +++ b/magick/delegate.c @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003 - 2020 GraphicsMagick Group +% Copyright (C) 2003 - 2022 GraphicsMagick Group % Copyright (C) 2002 ImageMagick Studio % % This program is covered by multiple licenses, which are described in @@ -1194,8 +1194,8 @@ MagickExport unsigned int ListDelegateInfo(FILE *file,ExceptionInfo *exception) continue; *delegate='\0'; if (p->encode != (char *) NULL) - (void) strlcpy(delegate,p->encode,MaxTextExtent); - (void) strcat(delegate," "); + (void) strlcpy(delegate,p->encode,sizeof(delegate)); + (void) strlcat(delegate," ",sizeof(delegate)); delegate[8]='\0'; commands=StringToList(p->commands); if (commands == (char **) NULL) @@ -1287,12 +1287,12 @@ static void CatDelegatePath(char *path, const char *binpath, const char *command) { - strcpy(path,binpath); - strcat(path,command); + strlcpy(path,binpath,MaxTextExtent); + strlcat(path,command,MaxTextExtent); if (IsAccessibleNoLogging(path)) return; - strcpy(path,command); + strlcpy(path,command,MaxTextExtent); return; } #endif /* defined(MSWINDOWS) */ @@ -1459,7 +1459,7 @@ static unsigned int ReadConfigureFile(const char *basename, # endif /* defined(UseInstalledMagick) */ if ((BinPath[0] != 0) && (BinPath[strlen(BinPath)-1] != *DirectorySeparator)) - strcat(BinPath,DirectorySeparator); + strlcat(BinPath,DirectorySeparator,sizeof(BinPath)); /* Substitute @GMDelegate@ with path to gm.exe */ CatDelegatePath(path,BinPath,"gm.exe"); diff --git a/magick/deprecate.c b/magick/deprecate.c index 3c83560..01aa98d 100644 --- a/magick/deprecate.c +++ b/magick/deprecate.c @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003 - 2021 GraphicsMagick Group +% Copyright (C) 2003 - 2022 GraphicsMagick Group % Copyright (C) 2002 ImageMagick Studio % % This program is covered by multiple licenses, which are described in @@ -137,7 +137,7 @@ AcquireCacheView(ViewInfo *view, */ MagickExport void *AcquireMemory(const size_t size) { - if (IsEventLogging()) + if (IsEventLogged(DeprecateEvent)) (void) LogMagickEvent(DeprecateEvent,GetMagickModule(), "Method has been deprecated"); @@ -172,7 +172,7 @@ MagickExport void *AcquireMemory(const size_t size) MagickExport void *CloneMemory(void *destination,const void *source, const size_t size) { - if (IsEventLogging()) + if (IsEventLogged(DeprecateEvent)) (void) LogMagickEvent(DeprecateEvent,GetMagickModule(), "Method has been deprecated"); @@ -247,7 +247,7 @@ MagickExport void LiberateMemory(void **memory) { assert(memory != (void **) NULL); - if (IsEventLogging()) + if (IsEventLogged(DeprecateEvent)) (void) LogMagickEvent(DeprecateEvent,GetMagickModule(), "Method has been deprecated"); @@ -312,7 +312,7 @@ MagickExport unsigned int PopImagePixels(const Image *image, quantum_size=32; } - if (image->logging) + if (IsEventLogged(DeprecateEvent)) (void) LogMagickEvent(DeprecateEvent,GetMagickModule(), "Method has been deprecated"); @@ -378,7 +378,7 @@ MagickExport unsigned int PushImagePixels(Image *image, quantum_size=32; } - if (image->logging) + if (IsEventLogged(DeprecateEvent)) (void) LogMagickEvent(DeprecateEvent,GetMagickModule(), "Method has been deprecated"); @@ -417,7 +417,7 @@ MagickExport void ReacquireMemory(void **memory,const size_t size) { assert(memory != (void **) NULL); - if (IsEventLogging()) + if (IsEventLogged(DeprecateEvent)) (void) LogMagickEvent(DeprecateEvent,GetMagickModule(), "Method has been deprecated"); diff --git a/magick/display.c b/magick/display.c index 7afb85f..526c2f8 100644 --- a/magick/display.c +++ b/magick/display.c @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003 - 2019 GraphicsMagick Group +% Copyright (C) 2003 - 2022 GraphicsMagick Group % Copyright (C) 2002 ImageMagick Studio % Copyright 1991-1999 E. I. du Pont de Nemours and Company % @@ -2246,9 +2246,12 @@ static unsigned int MagickXAnnotateEditImage(Display *display, annotate_context,x,y,p,1); x+=XTextWidth(font_info,p,1); p++; - if ((x+font_info->max_bounds.width) < (int) windows->image.width) - break; - break; /* Not completely sure about this break (used to fall through) */ + /* + This was active: + if ((x+font_info->max_bounds.width) < (int) windows->image.width) + break; + */ + break; /* FIXME: Not completely sure about this break (used to fall through) */ } case XK_Return: case XK_KP_Enter: @@ -3275,12 +3278,12 @@ static unsigned int MagickXColorEditImage(Display *display, (*image)->fuzz=StringToDouble(FuzzMenu[entry],MaxRGB); break; } - (void) strcpy(fuzz,"20%"); + (void) strlcpy(fuzz,"20%",sizeof(fuzz)); (void) MagickXDialogWidget(display,windows,"Ok", "Enter fuzz factor (0.0 - 99.9%):",fuzz); if (*fuzz == '\0') break; - (void) strcat(fuzz,"%"); + (void) strlcat(fuzz,"%",sizeof(fuzz)); (*image)->fuzz=StringToDouble(fuzz,MaxRGB); break; } @@ -3901,7 +3904,7 @@ static unsigned int MagickXCompositeImage(Display *display, { case ButtonPress: { - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Button Press: 0x%lx %u +%d+%d",event.xbutton.window, event.xbutton.button,event.xbutton.x,event.xbutton.y); @@ -3921,7 +3924,7 @@ static unsigned int MagickXCompositeImage(Display *display, } case ButtonRelease: { - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Button Release: 0x%lx %u +%d+%d",event.xbutton.window, event.xbutton.button,event.xbutton.x,event.xbutton.y); @@ -3961,7 +3964,7 @@ static unsigned int MagickXCompositeImage(Display *display, length=XLookupString((XKeyEvent *) &event.xkey,command,sizeof(command), &key_symbol,(XComposeStatus *) NULL); *(command+length)='\0'; - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Key press: 0x%lx (%.1024s)",key_symbol,command); switch ((int) key_symbol) @@ -4022,7 +4025,7 @@ static unsigned int MagickXCompositeImage(Display *display, } default: { - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(),"Event type: %d", event.type); break; @@ -4192,7 +4195,7 @@ static unsigned int MagickXConfigureImage(Display *display, */ width=windows->image.window_changes.width; height=windows->image.window_changes.height; - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Configure Image: %dx%d=>%lux%lu",windows->image.ximage->width, windows->image.ximage->height,width,height); @@ -7089,7 +7092,7 @@ static Image *MagickXMagickCommand(Display *display,MagickXResourceInfo *resourc if (*geometry == '\0') break; if (!status) - (void) strcat(geometry,"!"); + (void) strlcat(geometry,"!",sizeof(geometry)); (void) GetMagickGeometry(geometry,&x,&y,&width,&height); windows->image.window_changes.width=(unsigned int) width; windows->image.window_changes.height=(unsigned int) height; @@ -7815,7 +7818,7 @@ static Image *MagickXMagickCommand(Display *display,MagickXResourceInfo *resourc /* Query user for threshold value. */ - (void) sprintf(factor,"%lu",(unsigned long)(MaxRGB+1)/2); + (void) snprintf(factor,sizeof(factor),"%lu",(unsigned long)(MaxRGB+1)/2); (void) MagickXDialogWidget(display,windows,"Threshold", "Enter threshold value:",factor); if (*factor == '\0') @@ -9229,12 +9232,12 @@ static unsigned int MagickXMatteEditImage(Display *display, (*image)->fuzz=StringToDouble(FuzzMenu[entry],MaxRGB); break; } - (void) strcpy(fuzz,"20%"); + (void) strlcpy(fuzz,"20%",sizeof(fuzz)); (void) MagickXDialogWidget(display,windows,"Ok", "Enter fuzz factor (0.0 - 99.9%):",fuzz); if (*fuzz == '\0') break; - (void) strcat(fuzz,"%"); + (void) strlcat(fuzz,"%",sizeof(fuzz)); (*image)->fuzz=StringToDouble(fuzz,MaxRGB); break; } @@ -9659,7 +9662,7 @@ static Image *MagickXOpenImage(Display *display,MagickXResourceInfo *resource_in /* User may want to delay the X server screen grab. */ - (void) strcpy(seconds,"0"); + (void) strlcpy(seconds,"0",sizeof(seconds)); (void) MagickXDialogWidget(display,windows,"Grab","Enter any delay in seconds:", seconds); if (*seconds == '\0') @@ -9684,7 +9687,7 @@ static Image *MagickXOpenImage(Display *display,MagickXResourceInfo *resource_in /* Request image size from the user. */ - (void) strcpy(geometry,"512x512"); + (void) strlcpy(geometry,"512x512",sizeof(geometry)); if (image_info->size != (char *) NULL) (void) strlcpy(geometry,image_info->size,MaxTextExtent); (void) MagickXDialogWidget(display,windows,"Load","Enter the image geometry:", @@ -10127,7 +10130,7 @@ static unsigned int MagickXPasteImage(Display *display,MagickXResourceInfo *reso { case ButtonPress: { - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Button Press: 0x%lx %u +%d+%d",event.xbutton.window, event.xbutton.button,event.xbutton.x,event.xbutton.y); @@ -10156,7 +10159,7 @@ static unsigned int MagickXPasteImage(Display *display,MagickXResourceInfo *reso } case ButtonRelease: { - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Button Release: 0x%lx %u +%d+%d",event.xbutton.window, event.xbutton.button,event.xbutton.x,event.xbutton.y); @@ -10196,7 +10199,7 @@ static unsigned int MagickXPasteImage(Display *display,MagickXResourceInfo *reso length=XLookupString((XKeyEvent *) &event.xkey,command,sizeof(command), &key_symbol,(XComposeStatus *) NULL); *(command+length)='\0'; - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Key press: 0x%lx (%.1024s)",key_symbol,command); switch ((int) key_symbol) @@ -10257,7 +10260,7 @@ static unsigned int MagickXPasteImage(Display *display,MagickXResourceInfo *reso } default: { - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(),"Event type: %d", event.type); break; @@ -12487,9 +12490,10 @@ static Image *MagickXTileImage(Display *display,MagickXResourceInfo *resource_in Load tile image. */ MagickXCheckRefreshWindows(display,windows); - (void) strcpy(resource_info->image_info->magick,"MIFF"); + (void) strlcpy(resource_info->image_info->magick,"MIFF", + sizeof(resource_info->image_info->magick)); (void) strlcpy(resource_info->image_info->filename,filename, - MaxTextExtent); + sizeof(resource_info->image_info->filename)); tile_image=ReadImage(resource_info->image_info,&image->exception); if (image->exception.severity != UndefinedException) MagickError2(image->exception.severity,image->exception.reason, @@ -13168,7 +13172,7 @@ MagickExport unsigned int MagickXDisplayBackgroundImage(Display *display, */ window_attributes.width=XDisplayWidth(display,XDefaultScreen(display)); window_attributes.height=XDisplayHeight(display,XDefaultScreen(display)); - (void) strcpy(visual_type,"default"); + (void) strlcpy(visual_type,"default",sizeof(visual_type)); status=XGetWindowAttributes(display,window_info.id,&window_attributes); if (status != False) FormatString(visual_type,"0x%lx", @@ -13256,7 +13260,7 @@ MagickExport unsigned int MagickXDisplayBackgroundImage(Display *display, MagickFatalError(XServerFatalError,UnableToCreateXImage,(char *) NULL); window_info.x=0; window_info.y=0; - if (IsEventLogging()) + if (IsEventLogged(X11Event)) { (void) LogMagickEvent(X11Event,GetMagickModule(), "Image: %.1024s[%lu] %lux%lu ",image->filename,image->scene, @@ -13916,7 +13920,7 @@ MagickXDisplayImage(Display *display,MagickXResourceInfo *resource_info, manager_hints=windows->manager_hints; root_window=XRootWindow(display,visual_info->screen); nexus=(Image *) NULL; - if (IsEventLogging()) + if (IsEventLogged(X11Event)) { (void) LogMagickEvent(X11Event,GetMagickModule(), "Image: %.1024s[%lu] %lux%lu ",display_image->filename, @@ -13943,7 +13947,7 @@ MagickXDisplayImage(Display *display,MagickXResourceInfo *resource_info, manager_hints->initial_state=WithdrawnState; MagickXMakeWindow(display,root_window,argv,argc,class_hints,manager_hints, &windows->context); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(),"Window id: 0x%lx (context)", windows->context.id); (void) memset(&context_values,0,sizeof(context_values)); @@ -13995,7 +13999,7 @@ MagickXDisplayImage(Display *display,MagickXResourceInfo *resource_info, manager_hints->initial_state=IconicState; MagickXMakeWindow(display,root_window,argv,argc,class_hints,manager_hints, &windows->icon); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(),"Window id: 0x%lx (icon)", windows->icon.id); /* @@ -14117,7 +14121,7 @@ MagickXDisplayImage(Display *display,MagickXResourceInfo *resource_info, resource_info->iconic ? IconicState : NormalState; MagickXMakeWindow(display,root_window,argv,argc,class_hints,manager_hints, &windows->backdrop); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Window id: 0x%lx (backdrop)",windows->backdrop.id); (void) XMapWindow(display,windows->backdrop.id); @@ -14153,7 +14157,7 @@ MagickXDisplayImage(Display *display,MagickXResourceInfo *resource_info, manager_hints->flags|=WindowGroupHint; manager_hints->window_group=windows->group_leader.id; (void) XSelectInput(display,windows->group_leader.id,StructureNotifyMask); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Window id: 0x%lx (group leader)",windows->group_leader.id); } @@ -14165,7 +14169,7 @@ MagickXDisplayImage(Display *display,MagickXResourceInfo *resource_info, if (windows->group_leader.id != (Window) NULL) (void) XSetTransientForHint(display,windows->image.id, windows->group_leader.id); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(),"Window id: 0x%lx (image)", windows->image.id); /* @@ -14196,7 +14200,7 @@ MagickXDisplayImage(Display *display,MagickXResourceInfo *resource_info, (void) XSetTransientForHint(display,windows->info.id,windows->image.id); if (windows->image.mapped) (void) XWithdrawWindow(display,windows->info.id,windows->info.screen); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(),"Window id: 0x%lx (info)", windows->info.id); /* @@ -14227,7 +14231,7 @@ MagickXDisplayImage(Display *display,MagickXResourceInfo *resource_info, (void) XSetTransientForHint(display,windows->command.id,windows->image.id); if (windows->command.mapped) (void) XMapRaised(display,windows->command.id); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(),"Window id: 0x%lx (command)", windows->command.id); /* @@ -14257,7 +14261,7 @@ MagickXDisplayImage(Display *display,MagickXResourceInfo *resource_info, windows->widget.highlight_stipple=windows->info.highlight_stipple; windows->widget.shadow_stipple=windows->info.shadow_stipple; (void) XSetTransientForHint(display,windows->widget.id,windows->image.id); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(),"Window id: 0x%lx (widget)", windows->widget.id); /* @@ -14283,7 +14287,7 @@ MagickXDisplayImage(Display *display,MagickXResourceInfo *resource_info, windows->popup.highlight_stipple=windows->info.highlight_stipple; windows->popup.shadow_stipple=windows->info.shadow_stipple; (void) XSetTransientForHint(display,windows->popup.id,windows->image.id); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(),"Window id: 0x%lx (pop up)", windows->popup.id); /* @@ -14323,7 +14327,7 @@ MagickXDisplayImage(Display *display,MagickXResourceInfo *resource_info, manager_hints->window_group=windows->image.id; MagickXMakeWindow(display,root_window,argv,argc,class_hints,manager_hints, &windows->magnify); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(),"Window id: 0x%lx (magnify)", windows->magnify.id); (void) XSetTransientForHint(display,windows->magnify.id,windows->image.id); @@ -14352,7 +14356,7 @@ MagickXDisplayImage(Display *display,MagickXResourceInfo *resource_info, manager_hints->window_group=windows->image.id; MagickXMakeWindow(display,root_window,argv,argc,class_hints,manager_hints, &windows->pan); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(),"Window id: 0x%lx (pan)", windows->pan.id); (void) XSetTransientForHint(display,windows->pan.id,windows->image.id); @@ -14511,7 +14515,7 @@ MagickXDisplayImage(Display *display,MagickXResourceInfo *resource_info, { case ButtonPress: { - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Button Press: 0x%lx %u +%d+%d",event.xbutton.window, event.xbutton.button,event.xbutton.x,event.xbutton.y); @@ -14664,7 +14668,7 @@ MagickXDisplayImage(Display *display,MagickXResourceInfo *resource_info, } case ButtonRelease: { - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Button Release: 0x%lx %u +%d+%d",event.xbutton.window, event.xbutton.button,event.xbutton.x,event.xbutton.y); @@ -14672,7 +14676,7 @@ MagickXDisplayImage(Display *display,MagickXResourceInfo *resource_info, } case ClientMessage: { - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Client Message: 0x%lx 0x%lx %d 0x%lx",event.xclient.window, event.xclient.message_type,event.xclient.format,(unsigned long) @@ -14836,7 +14840,7 @@ MagickXDisplayImage(Display *display,MagickXResourceInfo *resource_info, } case ConfigureNotify: { - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Configure Notify: 0x%lx %dx%d+%d+%d %d",event.xconfigure.window, event.xconfigure.width,event.xconfigure.height,event.xconfigure.x, @@ -15006,7 +15010,7 @@ MagickXDisplayImage(Display *display,MagickXResourceInfo *resource_info, /* Group leader has exited. */ - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(),"Destroy Notify: 0x%lx", event.xdestroywindow.window); if (event.xdestroywindow.window == windows->group_leader.id) @@ -15032,7 +15036,7 @@ MagickXDisplayImage(Display *display,MagickXResourceInfo *resource_info, } case Expose: { - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Expose: 0x%lx %dx%d+%d+%d",event.xexpose.window, event.xexpose.width,event.xexpose.height,event.xexpose.x, @@ -15079,7 +15083,7 @@ MagickXDisplayImage(Display *display,MagickXResourceInfo *resource_info, length=XLookupString((XKeyEvent *) &event.xkey,command,sizeof(command), &key_symbol,(XComposeStatus *) NULL); *(command+length)='\0'; - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Key press: %d 0x%lx (%.1024s)",event.xkey.state,key_symbol, command); @@ -15117,7 +15121,7 @@ MagickXDisplayImage(Display *display,MagickXResourceInfo *resource_info, */ (void) XLookupString((XKeyEvent *) &event.xkey,command,sizeof(command), &key_symbol,(XComposeStatus *) NULL); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Key release: 0x%lx (%c)",key_symbol,*command); break; @@ -15138,7 +15142,7 @@ MagickXDisplayImage(Display *display,MagickXResourceInfo *resource_info, } case MapNotify: { - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(),"Map Notify: 0x%lx", event.xmap.window); if (event.xmap.window == windows->backdrop.id) @@ -15245,7 +15249,7 @@ MagickXDisplayImage(Display *display,MagickXResourceInfo *resource_info, after, length; - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Property Notify: 0x%lx 0x%lx %d",event.xproperty.window, event.xproperty.atom,event.xproperty.state); @@ -15273,7 +15277,7 @@ MagickXDisplayImage(Display *display,MagickXResourceInfo *resource_info, } case ReparentNotify: { - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Reparent Notify: 0x%lx=>0x%lx",event.xreparent.parent, event.xreparent.window); @@ -15281,7 +15285,7 @@ MagickXDisplayImage(Display *display,MagickXResourceInfo *resource_info, } case UnmapNotify: { - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(),"Unmap Notify: 0x%lx", event.xunmap.window); if (event.xunmap.window == windows->backdrop.id) @@ -15344,7 +15348,7 @@ MagickXDisplayImage(Display *display,MagickXResourceInfo *resource_info, } default: { - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(),"Event type: %d", event.type); break; diff --git a/magick/effect.c b/magick/effect.c index 4e4aee2..dcc5abf 100644 --- a/magick/effect.c +++ b/magick/effect.c @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003-2021 GraphicsMagick Group +% Copyright (C) 2003-2023 GraphicsMagick Group % Copyright (C) 2002 ImageMagick Studio % % This program is covered by multiple licenses, which are described in @@ -161,6 +161,10 @@ MagickExport Image *AdaptiveThresholdImage(const Image * image, assert(exception != (ExceptionInfo *) NULL); assert(exception->signature == MagickSignature); + if ((width == 0) || (height == 0)) + ThrowImageException3(OptionError, UnableToThresholdImage, + NonzeroWidthAndHeightRequired); + if ((image->columns < width) || (image->rows < height)) ThrowImageException3(OptionError, UnableToThresholdImage, ImageSmallerThanRadius); @@ -224,7 +228,7 @@ MagickExport Image *AdaptiveThresholdImage(const Image * image, LongPixelPacket min_sum; - if (image->logging) + if (IsEventLogged(TransformEvent)) (void) LogMagickEvent(TransformEvent,GetMagickModule(), "LAT: overflow handling activated " "(y=%lu)!",y); @@ -790,7 +794,7 @@ static int GetBlurKernel(unsigned long width,const double sigma,double **kernel) */ if (width == 0) width=3; - *kernel=MagickAllocateMemory(double *,width*sizeof(double)); + *kernel=MagickAllocateResourceLimitedArray(double *,width,sizeof(double)); if (*kernel == (double *) NULL) return(0); for (i=0; i < (long) width; i++) @@ -967,21 +971,21 @@ BlurImage(const Image *original_image,const double radius, while ((long) (MaxRGB*kernel[0]) > 0) { if (last_kernel != (double *)NULL) - MagickFreeMemory(last_kernel); + MagickFreeResourceLimitedMemory(last_kernel); last_kernel=kernel; kernel=(double *) NULL; width=GetBlurKernel(width+2,sigma,&kernel); } if (last_kernel != (double *) NULL) { - MagickFreeMemory(kernel); + MagickFreeResourceLimitedMemory(kernel); width-=2; kernel=last_kernel; } } if (width < 3) { - MagickFreeMemory(kernel); + MagickFreeResourceLimitedMemory(kernel); ThrowImageException3(OptionError,UnableToBlurImage, KernelRadiusIsTooSmall); } @@ -1017,7 +1021,7 @@ BlurImage(const Image *original_image,const double radius, status&=BlurImageScanlines(blur_image,kernel,width,BlurImageRowsText, exception); - MagickFreeMemory(kernel); + MagickFreeResourceLimitedMemory(kernel); if (blur_image != (Image *) NULL) blur_image->is_grayscale=original_image->is_grayscale; @@ -4235,7 +4239,8 @@ MagickExport Image *SharpenImageChannel(const Image *image, %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % SpreadImage() is a special effects method that randomly displaces each -% pixel in a block defined by the radius parameter. +% pixel in a block defined by the radius parameter. Useful values are 1 +% to than less than 100. % % The format of the SpreadImage method is: % @@ -4268,8 +4273,13 @@ MagickExport Image *SpreadImage(const Image *image,const unsigned int radius, assert(image->signature == MagickSignature); assert(exception != (ExceptionInfo *) NULL); assert(exception->signature == MagickSignature); - if ((image->columns < 3) || (image->rows < 3)) - return((Image *) NULL); + if ((image->columns < 3) || (image->rows < 3) || + ((image->columns < radius) && (image->rows < radius))) + { + ThrowImageException3(OptionError, UnableToSpreadImage, + ImageSmallerThanRadius); + } + /* Initialize spread image attributes. */ @@ -4381,6 +4391,8 @@ MagickExport Image *SpreadImage(const Image *image,const unsigned int radius, tries; tries=0; + if (offsets_index == OFFSETS_ENTRIES) + offsets_index=0; do { x_distance=offsets[offsets_index++]; @@ -4396,6 +4408,8 @@ MagickExport Image *SpreadImage(const Image *image,const unsigned int radius, } while (((x+x_distance) < 0) || ((x+x_distance) >= (long) image->columns)); tries=0; + if (offsets_index == OFFSETS_ENTRIES) + offsets_index=0; do { y_distance=offsets[offsets_index++]; diff --git a/magick/enhance.c b/magick/enhance.c index 3b7664e..e943ffb 100644 --- a/magick/enhance.c +++ b/magick/enhance.c @@ -169,7 +169,7 @@ ContrastImagePixels(void *mutable_data, /* User provided mutable data */ sign = *((const double *) immutable_data); static const double - alpha=0.5+MagickEpsilon; + alpha=0.50000000000099997787827987849595956504344940185546875; /* 0.5+MagickEpsilon */ register long i; diff --git a/magick/error.c b/magick/error.c index a0b9f02..bc96255 100644 --- a/magick/error.c +++ b/magick/error.c @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003-2019 GraphicsMagick Group +% Copyright (C) 2003-2023 GraphicsMagick Group % Copyright (C) 2002 ImageMagick Studio % Copyright 1991-1999 E. I. du Pont de Nemours and Company % @@ -307,8 +307,12 @@ static void DefaultErrorHandler(const ExceptionType severity,const char *reason, FIXME: The following captures a random errno value rather than the errno associated with the actual error. */ +#if 0 if ((severity != OptionError) && errno) (void) fprintf(stderr," [%.1024s]",GetErrorMessageString(errno)); +#else + (void) severity; +#endif (void) fprintf(stderr,".\n"); } @@ -347,11 +351,31 @@ static void DefaultFatalErrorHandler(const ExceptionType severity, { if (reason != (char *) NULL) { - (void) fprintf(stderr,"%.1024s: %.1024s",GetClientName(),reason); - if (description != (char *) NULL) - (void) fprintf(stderr," (%.1024s)",description); + (void) fprintf(stderr,"%.1024s: ",GetClientName()); + if (strstr(reason,"%s") && description) + { + /* + Reason contains printf specification. %s in reason string + is substituted with description. + */ + (void) fprintf(stderr,reason,description); + } + else + { + (void) fprintf(stderr,"%.1024s",reason); + if (description != (char *) NULL) + (void) fprintf(stderr," (%.1024s)",description); + } + /* + FIXME: The following captures a random errno value rather than the + errno associated with the actual error. + */ +#if 0 if ((severity != OptionError) && errno) (void) fprintf(stderr," [%.1024s]",GetErrorMessageString(errno)); +#else + (void) severity; +#endif (void) fprintf(stderr,".\n"); } /* @@ -386,8 +410,7 @@ static void DefaultFatalErrorHandler(const ExceptionType severity, % % o warning: Specifies the numeric warning category. % -% o reason: Specifies the reason to display before terminating the -% program. +% o reason: Specifies the reason to display. % % o description: Specifies any description to the reason. % @@ -1030,15 +1053,24 @@ MagickExport void ThrowLoggedException(ExceptionInfo *exception, if (reason) { if (description) - (void) LogMagickEvent(severity,module,function,line,"Ignored: %.1024s (%.1024s)", + (void) LogMagickEvent(severity, + module != NULL ? module : "", + function != NULL ? function : "", + line,"Ignored: %.1024s (%.1024s)", reason,description); else - (void) LogMagickEvent(severity,module,function,line,"Ignored: %.1024s", + (void) LogMagickEvent(severity, + module != NULL ? module : "", + function != NULL ? function : "", + line,"Ignored: %.1024s", reason); } else { - (void) LogMagickEvent(severity,module,function,line, + (void) LogMagickEvent(severity, + module != NULL ? module : "", + function != NULL ? function : "", + line, "Ignored: exception contains no reason!"); } ignore=MagickTrue; @@ -1085,15 +1117,24 @@ MagickExport void ThrowLoggedException(ExceptionInfo *exception, if (exception->reason) { if (exception->description) - (void) LogMagickEvent(severity,module,function,line,"%.1024s (%.1024s)", + (void) LogMagickEvent(severity, + module != NULL ? module : "", + function != NULL ? function : "", + line,"%.1024s (%.1024s)", exception->reason,exception->description ); else - (void) LogMagickEvent(severity,module,function,line,"%.1024s", + (void) LogMagickEvent(severity, + module != NULL ? module : "", + function != NULL ? function : "", + line,"%.1024s", exception->reason); } else { - (void) LogMagickEvent(severity,module,function,line, + (void) LogMagickEvent(severity, + module != NULL ? module : "", + function != NULL ? function : "", + line, "exception contains no reason!"); } } diff --git a/magick/error.h b/magick/error.h index 22957f2..d5a41be 100644 --- a/magick/error.h +++ b/magick/error.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2003-2020 GraphicsMagick Group + Copyright (C) 2003-2023 GraphicsMagick Group Copyright (C) 2002 ImageMagick Studio Copyright 1991-1999 E. I. du Pont de Nemours and Company @@ -186,8 +186,9 @@ typedef enum */ /* - ExceptionInfo is used to report exceptions to higher level routines, - and to the user. + The ExceptionInfo structure is used to report exceptions to higher level + routines, and to the user. The ExceptionInfo structure must be initialized + using the GetExceptionInfo() function prior to use. */ typedef struct _ExceptionInfo { @@ -229,46 +230,46 @@ typedef struct _ExceptionInfo Exception typedef declarations. */ typedef void - (*ErrorHandler)(const ExceptionType,const char *,const char *); + (*ErrorHandler)(const ExceptionType severity,const char *reason,const char *description); typedef void - (*FatalErrorHandler)(const ExceptionType,const char *,const char *) MAGICK_FUNC_NORETURN; + (*FatalErrorHandler)(const ExceptionType severity,const char *reason,const char *description) MAGICK_FUNC_NORETURN; typedef void - (*WarningHandler)(const ExceptionType,const char *,const char *); + (*WarningHandler)(const ExceptionType severity,const char *reason,const char *description); /* Exception declarations. */ extern MagickExport const char - *GetLocaleExceptionMessage(const ExceptionType,const char *), - *GetLocaleMessage(const char *); + *GetLocaleExceptionMessage(const ExceptionType severity,const char *tag), + *GetLocaleMessage(const char *tag); extern MagickExport ErrorHandler - SetErrorHandler(ErrorHandler); + SetErrorHandler(ErrorHandler handler); extern MagickExport FatalErrorHandler - SetFatalErrorHandler(FatalErrorHandler); + SetFatalErrorHandler(FatalErrorHandler handler); extern MagickExport void - CatchException(const ExceptionInfo *), - CopyException(ExceptionInfo *copy, const ExceptionInfo *original), - DestroyExceptionInfo(ExceptionInfo *), - GetExceptionInfo(ExceptionInfo *), - MagickError(const ExceptionType,const char *,const char *), - MagickFatalError(const ExceptionType,const char *,const char *) MAGICK_FUNC_NORETURN, - MagickWarning(const ExceptionType,const char *,const char *), - _MagickError(const ExceptionType,const char *,const char *), - _MagickFatalError(const ExceptionType,const char *,const char *) MAGICK_FUNC_NORETURN, - _MagickWarning(const ExceptionType,const char *,const char *), - SetExceptionInfo(ExceptionInfo *,ExceptionType), - ThrowException(ExceptionInfo *,const ExceptionType,const char *,const char *), - ThrowLoggedException(ExceptionInfo *exception, const ExceptionType severity, - const char *reason,const char *description,const char *module, - const char *function,const unsigned long line); + CatchException(const ExceptionInfo *exception), + CopyException(ExceptionInfo *copy,const ExceptionInfo *original), + DestroyExceptionInfo(ExceptionInfo *exception), + GetExceptionInfo(ExceptionInfo *exception), + MagickError(const ExceptionType error,const char *reason,const char *description), + MagickFatalError(const ExceptionType error,const char *reason,const char *description) MAGICK_FUNC_NORETURN, + MagickWarning(const ExceptionType severity,const char *reason,const char *description), + _MagickError(const ExceptionType severity,const char *reason, const char *description), + _MagickFatalError(const ExceptionType severity,const char *reason,const char *description) MAGICK_FUNC_NORETURN, + _MagickWarning(const ExceptionType warning,const char *reason,const char *description), + SetExceptionInfo(ExceptionInfo *exception,ExceptionType severity), + ThrowException(ExceptionInfo *exception,const ExceptionType severity,const char *reason,const char *description), + ThrowLoggedException(ExceptionInfo *exception,const ExceptionType severity,const char *reason, + const char *description,const char *module,const char *function, + const unsigned long line); extern MagickExport WarningHandler - SetWarningHandler(WarningHandler); + SetWarningHandler(WarningHandler handler); /* Exception define definitions. diff --git a/magick/export.c b/magick/export.c index 4f6ba14..c35c9b2 100644 --- a/magick/export.c +++ b/magick/export.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2003 - 2018 GraphicsMagick Group + Copyright (C) 2003 - 2022 GraphicsMagick Group Copyright (C) 2002 ImageMagick Studio This program is covered by multiple licenses, which are described in @@ -3085,7 +3085,6 @@ ExportViewPixelArea(const ViewInfo *view, sample_type = UnsignedQuantumSampleType; unsigned int - unsigned_maxvalue=MaxRGB, sample_bits; unsigned long @@ -3156,9 +3155,6 @@ ExportViewPixelArea(const ViewInfo *view, double_scale=(double) (double_maxvalue-double_minvalue)/MaxRGB; if ((sample_type != FloatQuantumSampleType) && (sample_bits <= 32U)) { - /* Maximum value which may be represented by a sample */ - unsigned_maxvalue=MaxValueGivenBits(sample_bits); - if (QuantumDepth == sample_bits) { } @@ -3167,11 +3163,16 @@ ExportViewPixelArea(const ViewInfo *view, /* Divide to scale down */ unsigned_scale=(MaxRGB / (MaxRGB >> (QuantumDepth-sample_bits))); } +#if QuantumDepth < 32 else if (QuantumDepth < sample_bits) { + /* Maximum value which may be represented by a sample */ + const unsigned int unsigned_maxvalue=MaxValueGivenBits(sample_bits); + /* Multiply to scale up */ unsigned_scale=(unsigned_maxvalue/MaxRGB); } +#endif /* #if QuantumDepth < 32 */ } image=GetCacheViewImage(view); diff --git a/magick/floats.c b/magick/floats.c index cc96420..7a92290 100644 --- a/magick/floats.c +++ b/magick/floats.c @@ -310,7 +310,7 @@ int _Gm_convert_fp32_to_fp16 (const float *fp32, fp_16bits *fp16, const int mode bit = mant & (1 << i); if (bit == 0) { - new_mant = (mant | ((unsigned short)1 << i)) & (0xFFFF << i); + new_mant = (mant | ((unsigned short)1 << i)) & (0xFFFFU << i); mp = (unsigned char *)&new_mant; break; } @@ -326,7 +326,7 @@ int _Gm_convert_fp32_to_fp16 (const float *fp32, fp_16bits *fp16, const int mode bit = mant & (1 << i); if (bit == 0) { - new_mant = (mant | ((unsigned short)1 << i)) & (0xFFFF << i); + new_mant = (mant | ((unsigned short)1 << i)) & (0xFFFFU << i); mp = (unsigned char *)&new_mant; break; } @@ -812,7 +812,7 @@ int _Gm_convert_fp32_to_fp24 (const float *fp32, fp_24bits *fp24, const int mode * clearing bits to the right */ new_mant = (mant | ((unsigned int)1 << i)) & - (0xFFFF << i); + (0xFFFFU << i); mp = (unsigned char *)&new_mant; break; } @@ -829,7 +829,7 @@ int _Gm_convert_fp32_to_fp24 (const float *fp32, fp_24bits *fp24, const int mode if (bit == 0) { new_mant = (mant | ((unsigned int)1 << i)) & - (0xFFFF << i); + (0xFFFFU << i); mp = (unsigned char *)&new_mant; break; } diff --git a/magick/fx.c b/magick/fx.c index 130f127..9e98c67 100644 --- a/magick/fx.c +++ b/magick/fx.c @@ -1222,8 +1222,8 @@ SolarizeImagePixelsCB(void *mutable_data, /* User provided mutable data ExceptionInfo *exception) /* Exception report */ { - const Quantum - threshold = *((const double *) immutable_data); + const unsigned int + threshold = *((const unsigned int *) immutable_data); register long i; @@ -1250,7 +1250,8 @@ MagickExport MagickPassFail SolarizeImage(Image *image,const double threshold) #define SolarizeImageText "[%s] Solarize..." unsigned int - is_grayscale; + is_grayscale, + threshold_int; MagickPassFail status=MagickPass; @@ -1258,6 +1259,9 @@ MagickExport MagickPassFail SolarizeImage(Image *image,const double threshold) assert(image != (Image *) NULL); assert(image->signature == MagickSignature); is_grayscale=image->is_grayscale; + threshold_int=(threshold < 0.0 ? 0U : + (threshold > MaxRGBDouble) ? MaxRGB : + (unsigned int) (threshold + 0.5)); switch (image->storage_class) { case DirectClass: @@ -1269,7 +1273,7 @@ MagickExport MagickPassFail SolarizeImage(Image *image,const double threshold) status=PixelIterateMonoModify(SolarizeImagePixelsCB, NULL, SolarizeImageText, - NULL,&threshold,0,0,image->columns,image->rows, + NULL,&threshold_int,0,0,image->columns,image->rows, image,&image->exception); break; } @@ -1279,7 +1283,7 @@ MagickExport MagickPassFail SolarizeImage(Image *image,const double threshold) Solarize PseudoClass packets. */ SolarizeImagePixelsCB(0, - &threshold, + &threshold_int, image, image->colormap, (IndexPacket *) NULL, diff --git a/magick/gem.c b/magick/gem.c index 32b7e82..8fcb76b 100644 --- a/magick/gem.c +++ b/magick/gem.c @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003-2021 GraphicsMagick Group +% Copyright (C) 2003-2023 GraphicsMagick Group % Copyright (C) 2002 ImageMagick Studio % % This program is covered by multiple licenses, which are described in @@ -70,7 +70,7 @@ MagickExport void Contrast(const int sign,Quantum *red,Quantum *green, Quantum *blue) { static const double - alpha=0.5+MagickEpsilon; + alpha=0.50000000000099997787827987849595956504344940185546875; /* 0.5+MagickEpsilon */ double brightness, @@ -672,7 +672,7 @@ MagickExport void Hull(const long x_offset,const long y_offset, assert(g != (Quantum *) NULL); p=f+((size_t) columns+2); q=g+((size_t) columns+2); - r=p+(y_offset*((size_t) columns+2)+x_offset); + r=p+(long) (y_offset*((long) columns+2)+x_offset); #if defined(HAVE_OPENMP) # if defined(TUNE_OPENMP) # pragma omp parallel for schedule(runtime) @@ -721,8 +721,8 @@ MagickExport void Hull(const long x_offset,const long y_offset, } p=f+((size_t) columns+2); q=g+((size_t) columns+2); - r=q+(y_offset*((size_t) columns+2)+x_offset); - s=q-(y_offset*((size_t) columns+2)+x_offset); + r=q+(long) (y_offset*((long) columns+2)+x_offset); + s=q-(long) (y_offset*((long) columns+2)+x_offset); #if defined(HAVE_OPENMP) # if defined(TUNE_OPENMP) # pragma omp parallel for schedule(runtime) diff --git a/magick/gem.h b/magick/gem.h index d8736ab..c888a04 100644 --- a/magick/gem.h +++ b/magick/gem.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2003-2009 GraphicsMagick Group + Copyright (C) 2003-2023 GraphicsMagick Group Copyright (C) 2002 ImageMagick Studio This program is covered by multiple licenses, which are described in @@ -21,7 +21,7 @@ extern "C" { Graphic gems define declarations. */ extern MagickExport double - ExpandAffine(const AffineMatrix *), + ExpandAffine(const AffineMatrix *) MAGICK_FUNC_PURE, GenerateDifferentialNoise(const Quantum pixel,const NoiseType noise_type, MagickRandomKernel *kernel); diff --git a/magick/gradient.c b/magick/gradient.c index 1bf98ce..ddddee6 100644 --- a/magick/gradient.c +++ b/magick/gradient.c @@ -189,7 +189,13 @@ MagickExport MagickPassFail GradientImage(Image *restrict image, ThrowBinaryException(ResourceLimitError,MemoryAllocationFailed, image->filename); if (span <= MaxColormapSize) - AllocateImageColormap(image,(unsigned long) span); + if (!AllocateImageColormap(image,(unsigned long) span)) + { + MagickFreeMemory(pixel_packets); + ThrowException3(&image->exception, ResourceLimitError,MemoryAllocationFailed, + UnableToConstituteImage); + return MagickFail; + } /* Generate gradient pixels using alpha blending diff --git a/magick/image-private.h b/magick/image-private.h index b8bae5a..659f57b 100644 --- a/magick/image-private.h +++ b/magick/image-private.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 - 2020 GraphicsMagick Group + Copyright (C) 2018 - 2022 GraphicsMagick Group This program is covered by multiple licenses, which are described in Copyright.txt. You should have received a copy of Copyright.txt with this @@ -9,6 +9,20 @@ */ /* + Maximum unsigned RGB value which fits in the specified bits + + If bits <= 0, then zero is returned. If bits exceeds bits in unsigned long, + then max value of unsigned long is returned. + + Emulates ((1U << bits)-1) but without the overflow problems. +*/ +#define MaxValueGivenBits(bits) \ + ((unsigned long) \ + ((bits <= 0) ? 0 : \ + ((0x01UL << (Min(sizeof(unsigned long)*8U,(size_t)bits)-1)) + \ + ((0x01UL << (Min(sizeof(unsigned long)*8U,(size_t)bits)-1))-1)))) + +/* ImageExtra allows for expansion of Image without increasing its size. The internals are defined only in this private header file. Clients using the library can access the internals via the access diff --git a/magick/image.c b/magick/image.c index a580a3d..efa1624 100644 --- a/magick/image.c +++ b/magick/image.c @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003-2019 GraphicsMagick Group +% Copyright (C) 2003-2022 GraphicsMagick Group % Copyright (C) 2003 ImageMagick Studio % Copyright 1991-1999 E. I. du Pont de Nemours and Company % @@ -353,7 +353,7 @@ MagickExport Image *AllocateImage(const ImageInfo *image_info) /* Initialize Image structure. */ - (void) strcpy(allocate_image->magick,"MIFF"); + (void) strlcpy(allocate_image->magick,"MIFF",sizeof(allocate_image->magick)); allocate_image->storage_class=DirectClass; allocate_image->depth=QuantumDepth; allocate_image->interlace=NoInterlace; @@ -361,12 +361,9 @@ MagickExport Image *AllocateImage(const ImageInfo *image_info) allocate_image->compose=OverCompositeOp; allocate_image->blur=1.0; GetExceptionInfo(&allocate_image->exception); - (void) QueryColorDatabase(BackgroundColor,&allocate_image->background_color, - &allocate_image->exception); - (void) QueryColorDatabase(BorderColor,&allocate_image->border_color, - &allocate_image->exception); - (void) QueryColorDatabase(MatteColor,&allocate_image->matte_color, - &allocate_image->exception); + BackgroundColorInit(&allocate_image->background_color); + BorderColorInit(&allocate_image->border_color); + MatteColorInit(&allocate_image->matte_color); allocate_image->orientation=UndefinedOrientation; GetTimerInfo(&allocate_image->timer); GetCacheInfo(&allocate_image->cache); @@ -1944,10 +1941,9 @@ MagickExport void GetImageInfo(ImageInfo *image_info) image_info->dither=True; image_info->progress=True; GetExceptionInfo(&exception); - (void) QueryColorDatabase(BackgroundColor,&image_info->background_color, - &exception); - (void) QueryColorDatabase(BorderColor,&image_info->border_color,&exception); - (void) QueryColorDatabase(MatteColor,&image_info->matte_color,&exception); + BackgroundColorInit(&image_info->background_color); + BorderColorInit(&image_info->border_color); + MatteColorInit(&image_info->matte_color); DestroyExceptionInfo(&exception); image_info->signature=MagickSignature; } @@ -2700,6 +2696,10 @@ MagickExport MagickPassFail SetImageDepth(Image *image,const unsigned long depth MagickPassFail status=MagickPass; + MagickBool + is_monochrome = image->is_monochrome, + is_grayscale = image->is_grayscale; + assert(image != (Image *) NULL); status=QuantumOperatorImage(image,AllChannels,DepthQuantumOp,(double) depth, @@ -2708,6 +2708,8 @@ MagickExport MagickPassFail SetImageDepth(Image *image,const unsigned long depth status=QuantumOperatorImage(image,OpacityChannel,DepthQuantumOp,(double) depth, &image->exception); image->depth=Min(depth,QuantumDepth); + image->is_monochrome = is_monochrome; + image->is_grayscale = is_grayscale; return status; } @@ -3101,10 +3103,10 @@ SetImageInfo(ImageInfo *image_info,const unsigned int flags, Backward compatability and interoperability namimg */ if (LocaleCompare(format,"GRADATION") == 0) - (void) strcpy(format,"GRADIENT"); + (void) strlcpy(format,"GRADIENT",sizeof(format)); if (LocaleCompare(format,"MAGICK") == 0) - (void) strcpy(format,"IMAGE"); + (void) strlcpy(format,"IMAGE",sizeof(format)); LocaleUpper(format); /* @@ -3118,7 +3120,7 @@ SetImageInfo(ImageInfo *image_info,const unsigned int flags, char base_filename[MaxTextExtent]; p++; (void) strlcpy(base_filename,p,MaxTextExtent); - (void) strcpy(image_info->filename,base_filename); + (void) strlcpy(image_info->filename,base_filename,MaxTextExtent); (void) strlcpy(magic,format,MaxTextExtent); (void) strlcpy(image_info->magick,magic,MaxTextExtent); if (LocaleCompare(magic,"TMP") != 0) @@ -3134,14 +3136,20 @@ SetImageInfo(ImageInfo *image_info,const unsigned int flags, */ if (*magic == '\0') { + MagickBool + compressed_extension = MagickFalse; + /* Restore p to end of modified filename */ p=image_info->filename+Max((long) strlen(image_info->filename)-1,0); while ((*p != '.') && (p > (image_info->filename+1))) p--; + if ((LocaleCompare(p,".gz") == 0) || - (LocaleCompare(p,".Z") == 0) || (LocaleCompare(p,".bz2") == 0)) + compressed_extension = MagickTrue; + + if (compressed_extension) do { p--; @@ -3197,7 +3205,22 @@ SetImageInfo(ImageInfo *image_info,const unsigned int flags, magick_info=GetMagickInfo(magic,exception); if (magick_info != (const MagickInfo *) NULL) { - if (magick_info->extension_treatment == IgnoreExtensionTreatment) + /* + For compressed files with expected extensions + (e.g. name.ext.gz) we have already deduced the + expected format based on the base file extension, and + if the extension is considered to be a good hint, and + if seekable_stream is false for that format, use + "affirm" in order to avoid using a temporary file. + */ + if (LocaleCompare(magick_info->name,"SVGZ") == 0) + compressed_extension = MagickTrue; + + if ((magick_info->extension_treatment == HintExtensionTreatment) && + (magick_info->seekable_stream == MagickFalse) && + (compressed_extension)) + image_info->affirm=MagickTrue; + else if (magick_info->extension_treatment == IgnoreExtensionTreatment) exclude=MagickTrue; else if (magick_info->extension_treatment == ObeyExtensionTreatment) image_info->affirm=MagickTrue; @@ -3226,6 +3249,9 @@ SetImageInfo(ImageInfo *image_info,const unsigned int flags, DestroyImage(image); return(MagickFail); } + /* + FIXME: Avoid creating temporary files unless absolutely necessary! + */ if (!BlobIsSeekable(image)) { /* @@ -3245,7 +3271,7 @@ SetImageInfo(ImageInfo *image_info,const unsigned int flags, return(MagickFail); } CloseBlob(image); - (void) strcpy(image->filename,filename); + (void) strlcpy(image->filename,filename,MaxTextExtent); status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); if (status == MagickFail) { @@ -3253,7 +3279,7 @@ SetImageInfo(ImageInfo *image_info,const unsigned int flags, DestroyImage(image); return(MagickFail); } - (void) strcpy(image_info->filename,filename); + (void) strlcpy(image_info->filename,filename,MaxTextExtent); image_info->temporary=MagickTrue; } magick[0]='\0'; @@ -3448,11 +3474,11 @@ MagickExport MagickPassFail SetImageType(Image *image,const ImageType image_type status = MagickPass; MagickBool - logging; + xform_logging; assert(image != (Image *) NULL); assert(image->signature == MagickSignature); - logging=IsEventLogging(); + xform_logging=IsEventLogged(TransformEvent); switch (image_type) { case BilevelType: @@ -3462,7 +3488,7 @@ MagickExport MagickPassFail SetImageType(Image *image,const ImageType image_type if (!IsRGBColorspace(image->colorspace)) { - if (logging) + if (xform_logging) (void) LogMagickEvent(TransformEvent,GetMagickModule(), "SetImageType(Bilevel) Transforming to RGB colorspace ..."); (void) TransformColorspace(image,RGBColorspace); @@ -3481,7 +3507,7 @@ MagickExport MagickPassFail SetImageType(Image *image,const ImageType image_type /* Threshold image to bilevel */ - if (logging) + if (xform_logging) (void) LogMagickEvent(TransformEvent,GetMagickModule(), "SetImageType(Bilevel) Smashing to bilevel using Threshold method ..."); (void) ThresholdImage(image,(double)MaxRGB/2); @@ -3498,7 +3524,7 @@ MagickExport MagickPassFail SetImageType(Image *image,const ImageType image_type quantize_info.dither=image->dither; quantize_info.tree_depth=8; quantize_info.number_colors=2; - if (logging) + if (xform_logging) (void) LogMagickEvent(TransformEvent,GetMagickModule(), "SetImageType(Bilevel) Dithering to bilevel using Quantize method ..."); (void) QuantizeImage(&quantize_info,image); @@ -3512,14 +3538,14 @@ MagickExport MagickPassFail SetImageType(Image *image,const ImageType image_type { if (!IsRGBColorspace(image->colorspace)) { - if (logging) + if (xform_logging) (void) LogMagickEvent(TransformEvent,GetMagickModule(), "SetImageType(Grayscale) Transforming to RGB colorspace ..."); (void) TransformColorspace(image,RGBColorspace); } if (!image->is_grayscale) { - if (logging) + if (xform_logging) (void) LogMagickEvent(TransformEvent,GetMagickModule(), "SetImageType(Grayscale) Transforming to gray colorspace ..."); (void) TransformColorspace(image,GRAYColorspace); @@ -3532,21 +3558,21 @@ MagickExport MagickPassFail SetImageType(Image *image,const ImageType image_type { if (!IsRGBColorspace(image->colorspace)) { - if (logging) + if (xform_logging) (void) LogMagickEvent(TransformEvent,GetMagickModule(), "SetImageType(GrayscaleMatte) Transforming to RGB colorspace ..."); (void) TransformColorspace(image,RGBColorspace); } if (!image->is_grayscale) { - if (logging) + if (xform_logging) (void) LogMagickEvent(TransformEvent,GetMagickModule(), "SetImageType(GrayscaleMatte) Transforming to gray colorspace ..."); (void) TransformColorspace(image,GRAYColorspace); } if (!image->matte) { - if (logging) + if (xform_logging) (void) LogMagickEvent(TransformEvent,GetMagickModule(), "SetImageType(GrayscaleMatte) Adding opaque matte channel ..."); SetImageOpacity(image,OpaqueOpacity); @@ -3559,14 +3585,14 @@ MagickExport MagickPassFail SetImageType(Image *image,const ImageType image_type { if (!IsRGBColorspace(image->colorspace)) { - if (logging) + if (xform_logging) (void) LogMagickEvent(TransformEvent,GetMagickModule(), "SetImageType(Palette) Transforming to RGB colorspace ..."); (void) TransformColorspace(image,RGBColorspace); } if (image->storage_class != PseudoClass) { - if (logging) + if (xform_logging) (void) LogMagickEvent(TransformEvent,GetMagickModule(), "SetImageType(Palette) Using Quantize method ..."); GetQuantizeInfo(&quantize_info); @@ -3579,21 +3605,21 @@ MagickExport MagickPassFail SetImageType(Image *image,const ImageType image_type { if (!IsRGBColorspace(image->colorspace)) { - if (logging) + if (xform_logging) (void) LogMagickEvent(TransformEvent,GetMagickModule(), "SetImageType(PaletteMatte) Transforming to RGB colorspace ..."); (void) TransformColorspace(image,RGBColorspace); } if (!image->matte) { - if (logging) + if (xform_logging) (void) LogMagickEvent(TransformEvent,GetMagickModule(), "SetImageType(PaletteMatte) Adding opaque matte channel ..."); SetImageOpacity(image,OpaqueOpacity); } if (image->storage_class != PseudoClass) { - if (logging) + if (xform_logging) (void) LogMagickEvent(TransformEvent,GetMagickModule(), "SetImageType(PaletteMatteType) Using Quantize method ..."); GetQuantizeInfo(&quantize_info); @@ -3607,7 +3633,7 @@ MagickExport MagickPassFail SetImageType(Image *image,const ImageType image_type { if (!IsRGBColorspace(image->colorspace)) { - if (logging) + if (xform_logging) (void) LogMagickEvent(TransformEvent,GetMagickModule(), "SetImageType(TrueColor) Transforming to RGB colorspace ..."); (void) TransformColorspace(image,RGBColorspace); @@ -3620,7 +3646,7 @@ MagickExport MagickPassFail SetImageType(Image *image,const ImageType image_type if (!IsRGBColorspace(image->colorspace)) { - if (logging) + if (xform_logging) (void) LogMagickEvent(TransformEvent,GetMagickModule(), "SetImageType(TrueColorMatte) Transforming to RGB colorspace ..."); (void) TransformColorspace(image,RGBColorspace); @@ -3628,7 +3654,7 @@ MagickExport MagickPassFail SetImageType(Image *image,const ImageType image_type image->storage_class=DirectClass; if (!image->matte) { - if (logging) + if (xform_logging) (void) LogMagickEvent(TransformEvent,GetMagickModule(), "SetImageType(TrueColorMatte) Adding opaque matte channel ..."); SetImageOpacity(image,OpaqueOpacity); @@ -3639,7 +3665,7 @@ MagickExport MagickPassFail SetImageType(Image *image,const ImageType image_type { if (image->colorspace != CMYKColorspace) { - if (logging) + if (xform_logging) (void) LogMagickEvent(TransformEvent,GetMagickModule(), "SetImageType(ColorSeparation) Transforming to CMYK colorspace ..."); (void) TransformColorspace(image,CMYKColorspace); @@ -3650,14 +3676,14 @@ MagickExport MagickPassFail SetImageType(Image *image,const ImageType image_type { if (image->colorspace != CMYKColorspace) { - if (logging) + if (xform_logging) (void) LogMagickEvent(TransformEvent,GetMagickModule(), "SetImageType(ColorSeparationMatte) Transforming to CMYK colorspace ..."); (void) TransformColorspace(image,CMYKColorspace); } if (!image->matte) { - if (logging) + if (xform_logging) (void) LogMagickEvent(TransformEvent,GetMagickModule(), "SetImageType(ColorSeparationMatte) Adding opaque matte channel ..."); SetImageOpacity(image,OpaqueOpacity); diff --git a/magick/image.h b/magick/image.h index ed67c55..7733b2d 100644 --- a/magick/image.h +++ b/magick/image.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2003 - 2019 GraphicsMagick Group + Copyright (C) 2003 - 2023 GraphicsMagick Group Copyright (C) 2002 ImageMagick Studio Copyright 1991-1999 E. I. du Pont de Nemours and Company @@ -31,17 +31,6 @@ extern "C" { # define QuantumDepth 16 #endif -/* - Maximum unsigned RGB value which fits in the specified bits - - If bits <= 0, then zero is returned. If bits exceeds bits in unsigned long, - then max value of unsigned long is returned. -*/ -#define MaxValueGivenBits(bits) ((unsigned long) \ - (((int) bits <= 0) ? 0 : \ - ((0x01UL << (Min(sizeof(unsigned long)*8U,(size_t)bits)-1)) + \ - ((0x01UL << (Min(sizeof(unsigned long)*8U,(size_t)bits)-1))-1)))) - #if (QuantumDepth == 8) # define MaxColormapSize 256U # define MaxMap 255U @@ -91,7 +80,7 @@ extern "C" { #elif (QuantumDepth == 32) # define MaxColormapSize 65536U # define MaxRGB 4294967295U -# define MaxRGBFloat 4294967295.0f +# define MaxRGBFloat 4294967295.0 /* 4294967295.0f is represented as 4294967296! */ # define MaxRGBDouble 4294967295.0 # define ScaleCharToQuantum(value) ((Quantum) (16843009U*(value))) # define ScaleLongToQuantum(value) ((Quantum) ((value))) @@ -137,6 +126,8 @@ typedef unsigned int Quantum; #define TransparentOpacity MaxRGB #define RoundDoubleToQuantum(value) ((Quantum) (value < 0.0 ? 0U : \ (value > MaxRGBDouble) ? MaxRGB : value + 0.5)) +#define RoundDoubleToQuantumN(value) ((Quantum) (MAGICK_ISNAN(value) ? 0U : \ + (value < 0.0 ? 0U : (value > MaxRGBDouble) ? MaxRGB : value + 0.5))) #define RoundFloatToQuantum(value) ((Quantum) (value < 0.0f ? 0U : \ (value > MaxRGBFloat) ? MaxRGB : value + 0.5f)) #define ConstrainToRange(min,max,value) (value < min ? min : \ diff --git a/magick/import.c b/magick/import.c index 7563cd5..4725290 100644 --- a/magick/import.c +++ b/magick/import.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2003 - 2018 GraphicsMagick Group + Copyright (C) 2003 - 2023 GraphicsMagick Group Copyright (C) 2002 ImageMagick Studio This program is covered by multiple licenses, which are described in @@ -187,8 +187,6 @@ static const PixelPacket WhitePixel = {MaxRGB, MaxRGB, MaxRGB, OpaqueOpacity}; fu_.c[0]=*p++; \ value=fu_.f; \ } \ - if (MAGICK_ISNAN(value)) \ - value = 0.0; \ } #define ImportFloat64Quantum(endian,value,p) \ { \ @@ -215,8 +213,6 @@ static const PixelPacket WhitePixel = {MaxRGB, MaxRGB, MaxRGB, OpaqueOpacity}; du_.c[0]=*p++; \ value=du_.d; \ } \ - if (MAGICK_ISNAN(value)) \ - value = 0.0; \ } /* @@ -978,7 +974,7 @@ ImportGrayQuantumType(const unsigned char *source, ImportFloat16Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetGraySample(q,RoundDoubleToQuantum(double_value)); + SetGraySample(q,RoundDoubleToQuantumN(double_value)); q++; } break; @@ -990,7 +986,7 @@ ImportGrayQuantumType(const unsigned char *source, ImportFloat24Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetGraySample(q,RoundDoubleToQuantum(double_value)); + SetGraySample(q,RoundDoubleToQuantumN(double_value)); q++; } break; @@ -1002,7 +998,7 @@ ImportGrayQuantumType(const unsigned char *source, ImportFloat32Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetGraySample(q,RoundDoubleToQuantum(double_value)); + SetGraySample(q,RoundDoubleToQuantumN(double_value)); q++; } break; @@ -1014,7 +1010,7 @@ ImportGrayQuantumType(const unsigned char *source, ImportFloat64Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetGraySample(q,RoundDoubleToQuantum(double_value)); + SetGraySample(q,RoundDoubleToQuantumN(double_value)); q++; } break; @@ -1324,11 +1320,11 @@ ImportGrayAlphaQuantumType(const unsigned char *source, ImportFloat16Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetGraySample(q,RoundDoubleToQuantum(double_value)); + SetGraySample(q,RoundDoubleToQuantumN(double_value)); ImportFloat16Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetOpacitySample(q,MaxRGB-RoundDoubleToQuantum(double_value)); + SetOpacitySample(q,MaxRGB-RoundDoubleToQuantumN(double_value)); q++; } break; @@ -1340,11 +1336,11 @@ ImportGrayAlphaQuantumType(const unsigned char *source, ImportFloat24Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetGraySample(q,RoundDoubleToQuantum(double_value)); + SetGraySample(q,RoundDoubleToQuantumN(double_value)); ImportFloat24Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetOpacitySample(q,MaxRGB-RoundDoubleToQuantum(double_value)); + SetOpacitySample(q,MaxRGB-RoundDoubleToQuantumN(double_value)); q++; } break; @@ -1356,11 +1352,11 @@ ImportGrayAlphaQuantumType(const unsigned char *source, ImportFloat32Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetGraySample(q,RoundDoubleToQuantum(double_value)); + SetGraySample(q,RoundDoubleToQuantumN(double_value)); ImportFloat32Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetOpacitySample(q,MaxRGB-RoundDoubleToQuantum(double_value)); + SetOpacitySample(q,MaxRGB-RoundDoubleToQuantumN(double_value)); q++; } break; @@ -1372,11 +1368,11 @@ ImportGrayAlphaQuantumType(const unsigned char *source, ImportFloat64Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetGraySample(q,RoundDoubleToQuantum(double_value)); + SetGraySample(q,RoundDoubleToQuantumN(double_value)); ImportFloat64Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetOpacitySample(q,MaxRGB-RoundDoubleToQuantum(double_value)); + SetOpacitySample(q,MaxRGB-RoundDoubleToQuantumN(double_value)); q++; } break; @@ -1509,7 +1505,7 @@ ImportRedQuantumType(const unsigned char *source, ImportFloat16Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetRedSample(q,RoundDoubleToQuantum(double_value)); + SetRedSample(q,RoundDoubleToQuantumN(double_value)); q++; } break; @@ -1521,7 +1517,7 @@ ImportRedQuantumType(const unsigned char *source, ImportFloat24Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetRedSample(q,RoundDoubleToQuantum(double_value)); + SetRedSample(q,RoundDoubleToQuantumN(double_value)); q++; } break; @@ -1533,7 +1529,7 @@ ImportRedQuantumType(const unsigned char *source, ImportFloat32Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetRedSample(q,RoundDoubleToQuantum(double_value)); + SetRedSample(q,RoundDoubleToQuantumN(double_value)); q++; } break; @@ -1545,7 +1541,7 @@ ImportRedQuantumType(const unsigned char *source, ImportFloat64Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetRedSample(q,RoundDoubleToQuantum(double_value)); + SetRedSample(q,RoundDoubleToQuantumN(double_value)); q++; } break; @@ -1678,7 +1674,7 @@ ImportGreenQuantumType(const unsigned char *source, ImportFloat16Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetGreenSample(q,RoundDoubleToQuantum(double_value)); + SetGreenSample(q,RoundDoubleToQuantumN(double_value)); q++; } break; @@ -1690,7 +1686,7 @@ ImportGreenQuantumType(const unsigned char *source, ImportFloat24Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetGreenSample(q,RoundDoubleToQuantum(double_value)); + SetGreenSample(q,RoundDoubleToQuantumN(double_value)); q++; } break; @@ -1702,7 +1698,7 @@ ImportGreenQuantumType(const unsigned char *source, ImportFloat32Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetGreenSample(q,RoundDoubleToQuantum(double_value)); + SetGreenSample(q,RoundDoubleToQuantumN(double_value)); q++; } break; @@ -1714,7 +1710,7 @@ ImportGreenQuantumType(const unsigned char *source, ImportFloat64Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetGreenSample(q,RoundDoubleToQuantum(double_value)); + SetGreenSample(q,RoundDoubleToQuantumN(double_value)); q++; } break; @@ -1848,7 +1844,7 @@ ImportBlueQuantumType(const unsigned char *source, ImportFloat16Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetBlueSample(q,RoundDoubleToQuantum(double_value)); + SetBlueSample(q,RoundDoubleToQuantumN(double_value)); q++; } break; @@ -1860,7 +1856,7 @@ ImportBlueQuantumType(const unsigned char *source, ImportFloat24Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetBlueSample(q,RoundDoubleToQuantum(double_value)); + SetBlueSample(q,RoundDoubleToQuantumN(double_value)); q++; } break; @@ -1872,7 +1868,7 @@ ImportBlueQuantumType(const unsigned char *source, ImportFloat32Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetBlueSample(q,RoundDoubleToQuantum(double_value)); + SetBlueSample(q,RoundDoubleToQuantumN(double_value)); q++; } break; @@ -1884,7 +1880,7 @@ ImportBlueQuantumType(const unsigned char *source, ImportFloat64Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetBlueSample(q,RoundDoubleToQuantum(double_value)); + SetBlueSample(q,RoundDoubleToQuantumN(double_value)); q++; } break; @@ -2013,7 +2009,7 @@ ImportAlphaQuantumType(const unsigned char *source, ImportFloat16Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - *indexes++=(IndexPacket) MaxRGB-RoundDoubleToQuantum(double_value); + *indexes++=(IndexPacket) MaxRGB-RoundDoubleToQuantumN(double_value); } break; } @@ -2024,7 +2020,7 @@ ImportAlphaQuantumType(const unsigned char *source, ImportFloat24Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - *indexes++=(IndexPacket) MaxRGB-RoundDoubleToQuantum(double_value); + *indexes++=(IndexPacket) MaxRGB-RoundDoubleToQuantumN(double_value); } break; } @@ -2035,7 +2031,7 @@ ImportAlphaQuantumType(const unsigned char *source, ImportFloat32Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - *indexes++=(IndexPacket) MaxRGB-RoundDoubleToQuantum(double_value); + *indexes++=(IndexPacket) MaxRGB-RoundDoubleToQuantumN(double_value); } break; } @@ -2046,7 +2042,7 @@ ImportAlphaQuantumType(const unsigned char *source, ImportFloat64Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - *indexes++=(IndexPacket) MaxRGB-RoundDoubleToQuantum(double_value); + *indexes++=(IndexPacket) MaxRGB-RoundDoubleToQuantumN(double_value); } break; } @@ -2136,7 +2132,7 @@ ImportAlphaQuantumType(const unsigned char *source, ImportFloat16Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetOpacitySample(q,MaxRGB-RoundDoubleToQuantum(double_value)); + SetOpacitySample(q,MaxRGB-RoundDoubleToQuantumN(double_value)); q++; } break; @@ -2148,7 +2144,7 @@ ImportAlphaQuantumType(const unsigned char *source, ImportFloat24Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetOpacitySample(q,MaxRGB-RoundDoubleToQuantum(double_value)); + SetOpacitySample(q,MaxRGB-RoundDoubleToQuantumN(double_value)); q++; } break; @@ -2160,7 +2156,7 @@ ImportAlphaQuantumType(const unsigned char *source, ImportFloat32Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetOpacitySample(q,MaxRGB-RoundDoubleToQuantum(double_value)); + SetOpacitySample(q,MaxRGB-RoundDoubleToQuantumN(double_value)); q++; } break; @@ -2172,7 +2168,7 @@ ImportAlphaQuantumType(const unsigned char *source, ImportFloat64Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetOpacitySample(q,MaxRGB-RoundDoubleToQuantum(double_value)); + SetOpacitySample(q,MaxRGB-RoundDoubleToQuantumN(double_value)); q++; } break; @@ -2306,7 +2302,7 @@ ImportBlackQuantumType(const unsigned char *source, ImportFloat16Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetBlackSample(q,RoundDoubleToQuantum(double_value)); + SetBlackSample(q,RoundDoubleToQuantumN(double_value)); q++; } break; @@ -2318,7 +2314,7 @@ ImportBlackQuantumType(const unsigned char *source, ImportFloat24Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetBlackSample(q,RoundDoubleToQuantum(double_value)); + SetBlackSample(q,RoundDoubleToQuantumN(double_value)); q++; } break; @@ -2330,7 +2326,7 @@ ImportBlackQuantumType(const unsigned char *source, ImportFloat32Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetBlackSample(q,RoundDoubleToQuantum(double_value)); + SetBlackSample(q,RoundDoubleToQuantumN(double_value)); q++; } break; @@ -2342,7 +2338,7 @@ ImportBlackQuantumType(const unsigned char *source, ImportFloat64Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetBlackSample(q,RoundDoubleToQuantum(double_value)); + SetBlackSample(q,RoundDoubleToQuantumN(double_value)); q++; } break; @@ -2502,15 +2498,15 @@ ImportRGBQuantumType(const unsigned char *source, ImportFloat16Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetRedSample(q,RoundDoubleToQuantum(double_value)); + SetRedSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat16Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetGreenSample(q,RoundDoubleToQuantum(double_value)); + SetGreenSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat16Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetBlueSample(q,RoundDoubleToQuantum(double_value)); + SetBlueSample(q,RoundDoubleToQuantumN(double_value)); SetOpacitySample(q,OpaqueOpacity); q++; } @@ -2523,15 +2519,15 @@ ImportRGBQuantumType(const unsigned char *source, ImportFloat24Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetRedSample(q,RoundDoubleToQuantum(double_value)); + SetRedSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat24Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetGreenSample(q,RoundDoubleToQuantum(double_value)); + SetGreenSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat24Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetBlueSample(q,RoundDoubleToQuantum(double_value)); + SetBlueSample(q,RoundDoubleToQuantumN(double_value)); SetOpacitySample(q,OpaqueOpacity); q++; } @@ -2544,15 +2540,15 @@ ImportRGBQuantumType(const unsigned char *source, ImportFloat32Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetRedSample(q,RoundDoubleToQuantum(double_value)); + SetRedSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat32Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetGreenSample(q,RoundDoubleToQuantum(double_value)); + SetGreenSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat32Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetBlueSample(q,RoundDoubleToQuantum(double_value)); + SetBlueSample(q,RoundDoubleToQuantumN(double_value)); SetOpacitySample(q,OpaqueOpacity); q++; } @@ -2565,15 +2561,15 @@ ImportRGBQuantumType(const unsigned char *source, ImportFloat64Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetRedSample(q,RoundDoubleToQuantum(double_value)); + SetRedSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat64Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetGreenSample(q,RoundDoubleToQuantum(double_value)); + SetGreenSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat64Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetBlueSample(q,RoundDoubleToQuantum(double_value)); + SetBlueSample(q,RoundDoubleToQuantumN(double_value)); SetOpacitySample(q,OpaqueOpacity); q++; } @@ -2734,19 +2730,19 @@ ImportRGBAQuantumType(const unsigned char *source, ImportFloat16Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetRedSample(q,RoundDoubleToQuantum(double_value)); + SetRedSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat16Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetGreenSample(q,RoundDoubleToQuantum(double_value)); + SetGreenSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat16Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetBlueSample(q,RoundDoubleToQuantum(double_value)); + SetBlueSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat16Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetOpacitySample(q,MaxRGB-RoundDoubleToQuantum(double_value)); + SetOpacitySample(q,MaxRGB-RoundDoubleToQuantumN(double_value)); q++; } break; @@ -2758,19 +2754,19 @@ ImportRGBAQuantumType(const unsigned char *source, ImportFloat24Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetRedSample(q,RoundDoubleToQuantum(double_value)); + SetRedSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat24Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetGreenSample(q,RoundDoubleToQuantum(double_value)); + SetGreenSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat24Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetBlueSample(q,RoundDoubleToQuantum(double_value)); + SetBlueSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat24Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetOpacitySample(q,MaxRGB-RoundDoubleToQuantum(double_value)); + SetOpacitySample(q,MaxRGB-RoundDoubleToQuantumN(double_value)); q++; } break; @@ -2782,19 +2778,19 @@ ImportRGBAQuantumType(const unsigned char *source, ImportFloat32Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetRedSample(q,RoundDoubleToQuantum(double_value)); + SetRedSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat32Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetGreenSample(q,RoundDoubleToQuantum(double_value)); + SetGreenSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat32Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetBlueSample(q,RoundDoubleToQuantum(double_value)); + SetBlueSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat32Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetOpacitySample(q,MaxRGB-RoundDoubleToQuantum(double_value)); + SetOpacitySample(q,MaxRGB-RoundDoubleToQuantumN(double_value)); q++; } break; @@ -2806,19 +2802,19 @@ ImportRGBAQuantumType(const unsigned char *source, ImportFloat64Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetRedSample(q,RoundDoubleToQuantum(double_value)); + SetRedSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat64Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetGreenSample(q,RoundDoubleToQuantum(double_value)); + SetGreenSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat64Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetBlueSample(q,RoundDoubleToQuantum(double_value)); + SetBlueSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat64Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetOpacitySample(q,MaxRGB-RoundDoubleToQuantum(double_value)); + SetOpacitySample(q,MaxRGB-RoundDoubleToQuantumN(double_value)); q++; } break; @@ -2978,19 +2974,19 @@ ImportCMYKQuantumType(const unsigned char *source, ImportFloat16Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetCyanSample(q,RoundDoubleToQuantum(double_value)); + SetCyanSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat16Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetMagentaSample(q,RoundDoubleToQuantum(double_value)); + SetMagentaSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat16Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetYellowSample(q,RoundDoubleToQuantum(double_value)); + SetYellowSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat16Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetBlackSample(q,RoundDoubleToQuantum(double_value)); + SetBlackSample(q,RoundDoubleToQuantumN(double_value)); q++; } break; @@ -3002,19 +2998,19 @@ ImportCMYKQuantumType(const unsigned char *source, ImportFloat24Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetCyanSample(q,RoundDoubleToQuantum(double_value)); + SetCyanSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat24Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetMagentaSample(q,RoundDoubleToQuantum(double_value)); + SetMagentaSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat24Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetYellowSample(q,RoundDoubleToQuantum(double_value)); + SetYellowSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat24Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetBlackSample(q,RoundDoubleToQuantum(double_value)); + SetBlackSample(q,RoundDoubleToQuantumN(double_value)); q++; } break; @@ -3026,19 +3022,19 @@ ImportCMYKQuantumType(const unsigned char *source, ImportFloat32Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetCyanSample(q,RoundDoubleToQuantum(double_value)); + SetCyanSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat32Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetMagentaSample(q,RoundDoubleToQuantum(double_value)); + SetMagentaSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat32Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetYellowSample(q,RoundDoubleToQuantum(double_value)); + SetYellowSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat32Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetBlackSample(q,RoundDoubleToQuantum(double_value)); + SetBlackSample(q,RoundDoubleToQuantumN(double_value)); q++; } break; @@ -3050,19 +3046,19 @@ ImportCMYKQuantumType(const unsigned char *source, ImportFloat64Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetCyanSample(q,RoundDoubleToQuantum(double_value)); + SetCyanSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat64Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetMagentaSample(q,RoundDoubleToQuantum(double_value)); + SetMagentaSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat64Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetYellowSample(q,RoundDoubleToQuantum(double_value)); + SetYellowSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat64Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetBlackSample(q,RoundDoubleToQuantum(double_value)); + SetBlackSample(q,RoundDoubleToQuantumN(double_value)); q++; } break; @@ -3237,23 +3233,23 @@ ImportCMYKAQuantumType(const unsigned char *source, ImportFloat16Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetCyanSample(q,RoundDoubleToQuantum(double_value)); + SetCyanSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat16Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetMagentaSample(q,RoundDoubleToQuantum(double_value)); + SetMagentaSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat16Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetYellowSample(q,RoundDoubleToQuantum(double_value)); + SetYellowSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat16Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetBlackSample(q,RoundDoubleToQuantum(double_value)); + SetBlackSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat16Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - *indexes++=(IndexPacket) MaxRGB-RoundDoubleToQuantum(double_value); + *indexes++=(IndexPacket) MaxRGB-RoundDoubleToQuantumN(double_value); q++; } break; @@ -3265,23 +3261,23 @@ ImportCMYKAQuantumType(const unsigned char *source, ImportFloat24Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetCyanSample(q,RoundDoubleToQuantum(double_value)); + SetCyanSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat24Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetMagentaSample(q,RoundDoubleToQuantum(double_value)); + SetMagentaSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat24Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetYellowSample(q,RoundDoubleToQuantum(double_value)); + SetYellowSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat24Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetBlackSample(q,RoundDoubleToQuantum(double_value)); + SetBlackSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat24Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - *indexes++=(IndexPacket) MaxRGB-RoundDoubleToQuantum(double_value); + *indexes++=(IndexPacket) MaxRGB-RoundDoubleToQuantumN(double_value); q++; } break; @@ -3293,23 +3289,23 @@ ImportCMYKAQuantumType(const unsigned char *source, ImportFloat32Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetCyanSample(q,RoundDoubleToQuantum(double_value)); + SetCyanSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat32Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetMagentaSample(q,RoundDoubleToQuantum(double_value)); + SetMagentaSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat32Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetYellowSample(q,RoundDoubleToQuantum(double_value)); + SetYellowSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat32Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetBlackSample(q,RoundDoubleToQuantum(double_value)); + SetBlackSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat32Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - *indexes++=(IndexPacket) MaxRGB-RoundDoubleToQuantum(double_value); + *indexes++=(IndexPacket) MaxRGB-RoundDoubleToQuantumN(double_value); q++; } break; @@ -3321,23 +3317,23 @@ ImportCMYKAQuantumType(const unsigned char *source, ImportFloat64Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetCyanSample(q,RoundDoubleToQuantum(double_value)); + SetCyanSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat64Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetMagentaSample(q,RoundDoubleToQuantum(double_value)); + SetMagentaSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat64Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetYellowSample(q,RoundDoubleToQuantum(double_value)); + SetYellowSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat64Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - SetBlackSample(q,RoundDoubleToQuantum(double_value)); + SetBlackSample(q,RoundDoubleToQuantumN(double_value)); ImportFloat64Quantum(endian,double_value,p); double_value -= double_minvalue; double_value *= double_scale; - *indexes++=(IndexPacket) MaxRGB-RoundDoubleToQuantum(double_value); + *indexes++=(IndexPacket) MaxRGB-RoundDoubleToQuantumN(double_value); q++; } break; @@ -3610,11 +3606,13 @@ ImportViewPixelArea(ViewInfo *view, /* Multiply to scale up */ unsigned_scale=(MaxRGB / (MaxRGB >> (QuantumDepth-sample_bits))); } +#if QuantumDepth < 32 else if (QuantumDepth < sample_bits) { /* Divide to scale down */ unsigned_scale=(unsigned_maxvalue/MaxRGB); } +#endif } image=GetCacheViewImage(view); diff --git a/magick/list.c b/magick/list.c index 1ce2b64..481b7a4 100644 --- a/magick/list.c +++ b/magick/list.c @@ -51,7 +51,9 @@ % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% AppendImageToList() appends an image to the end of the list. +% AppendImageToList() appends an image to the end of the list. Please +% note that this API allows the list pointer to be updated and in fact +% it now updates the list pointer to be the image which was just added. % % The format of the AppendImageToList method is: % @@ -83,6 +85,7 @@ MagickExport void AppendImageToList(Image **images,Image *image) for (p=(*images); p->next != (Image *) NULL; p=p->next); p->next=image; image->previous=p; + *images=image; } /* diff --git a/magick/locale.c b/magick/locale.c index 6037e43..73bd6a0 100644 --- a/magick/locale.c +++ b/magick/locale.c @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003, 2004 GraphicsMagick Group +% Copyright (C) 2003 - 2022 GraphicsMagick Group % % This program is covered by multiple licenses, which are described in % Copyright.txt. You should have received a copy of Copyright.txt with this @@ -198,7 +198,7 @@ GetLocaleMessageFromTag(const char *tag) (void) strlcpy(category,tag,MaxTextExtent); ChopLocaleComponents(category,2); - for (k=0; k < ArraySize(category_map); k++) + for (k=0; k < ArraySize(category_map)-1; k++) { if (LocaleCompare(category,category_map[k].name) == 0) { diff --git a/magick/locale_c.h b/magick/locale_c.h index f4ea804..2f84bd5 100644 --- a/magick/locale_c.h +++ b/magick/locale_c.h @@ -3,7 +3,7 @@ extern MagickExport const char *GetLocaleMessageFromID(const int) MAGICK_FUNC_CONST; -#define MAX_LOCALE_MSGS 588 +#define MAX_LOCALE_MSGS 589 #define MGK_BlobErrorUnableToCreateBlob 1 #define MGK_BlobErrorUnableToDeduceImageFormat 2 @@ -346,253 +346,254 @@ extern MagickExport const char *GetLocaleMessageFromID(const int) MAGICK_FUNC_CO #define MGK_OptionErrorUnableToPaintImage 339 #define MGK_OptionErrorUnableToRaiseImage 340 #define MGK_OptionErrorUnableToSharpenImage 341 -#define MGK_OptionErrorUnableToThresholdImage 342 -#define MGK_OptionErrorUnableToWaveImage 343 -#define MGK_OptionErrorUnrecognizedAttribute 344 -#define MGK_OptionErrorUnrecognizedChannelType 345 -#define MGK_OptionErrorUnrecognizedColor 346 -#define MGK_OptionErrorUnrecognizedColormapType 347 -#define MGK_OptionErrorUnrecognizedColorspace 348 -#define MGK_OptionErrorUnrecognizedCommand 349 -#define MGK_OptionErrorUnrecognizedComposeOperator 350 -#define MGK_OptionErrorUnrecognizedDisposeMethod 351 -#define MGK_OptionErrorUnrecognizedElement 352 -#define MGK_OptionErrorUnrecognizedEndianType 353 -#define MGK_OptionErrorUnrecognizedGravityType 354 -#define MGK_OptionErrorUnrecognizedHighlightStyle 355 -#define MGK_OptionErrorUnrecognizedImageCompression 356 -#define MGK_OptionErrorUnrecognizedImageFilter 357 -#define MGK_OptionErrorUnrecognizedImageFormat 358 -#define MGK_OptionErrorUnrecognizedImageMode 359 -#define MGK_OptionErrorUnrecognizedImageType 360 -#define MGK_OptionErrorUnrecognizedIntentType 361 -#define MGK_OptionErrorUnrecognizedInterlaceType 362 -#define MGK_OptionErrorUnrecognizedListType 363 -#define MGK_OptionErrorUnrecognizedMetric 364 -#define MGK_OptionErrorUnrecognizedModeType 365 -#define MGK_OptionErrorUnrecognizedNoiseType 366 -#define MGK_OptionErrorUnrecognizedOperator 367 -#define MGK_OptionErrorUnrecognizedOption 368 -#define MGK_OptionErrorUnrecognizedPerlMagickMethod 369 -#define MGK_OptionErrorUnrecognizedPixelMap 370 -#define MGK_OptionErrorUnrecognizedPreviewType 371 -#define MGK_OptionErrorUnrecognizedResourceType 372 -#define MGK_OptionErrorUnrecognizedType 373 -#define MGK_OptionErrorUnrecognizedUnitsType 374 -#define MGK_OptionErrorUnrecognizedVirtualPixelMethod 375 -#define MGK_OptionErrorUnsupportedSamplingFactor 376 -#define MGK_OptionErrorUsageError 377 -#define MGK_OptionFatalErrorInvalidColorspaceType 378 -#define MGK_OptionFatalErrorInvalidEndianType 379 -#define MGK_OptionFatalErrorInvalidImageType 380 -#define MGK_OptionFatalErrorInvalidInterlaceType 381 -#define MGK_OptionFatalErrorMissingAnImageFilename 382 -#define MGK_OptionFatalErrorMissingArgument 383 -#define MGK_OptionFatalErrorNoImagesWereLoaded 384 -#define MGK_OptionFatalErrorOptionLengthExceedsLimit 385 -#define MGK_OptionFatalErrorRequestDidNotReturnAnImage 386 -#define MGK_OptionFatalErrorUnableToOpenXServer 387 -#define MGK_OptionFatalErrorUnableToPersistKey 388 -#define MGK_OptionFatalErrorUnrecognizedColormapType 389 -#define MGK_OptionFatalErrorUnrecognizedColorspaceType 390 -#define MGK_OptionFatalErrorUnrecognizedDisposeMethod 391 -#define MGK_OptionFatalErrorUnrecognizedEndianType 392 -#define MGK_OptionFatalErrorUnrecognizedFilterType 393 -#define MGK_OptionFatalErrorUnrecognizedImageCompressionType 394 -#define MGK_OptionFatalErrorUnrecognizedImageType 395 -#define MGK_OptionFatalErrorUnrecognizedInterlaceType 396 -#define MGK_OptionFatalErrorUnrecognizedOption 397 -#define MGK_OptionFatalErrorUnrecognizedResourceType 398 -#define MGK_OptionFatalErrorUnrecognizedVirtualPixelMethod 399 -#define MGK_OptionWarningUnrecognizedColor 400 -#define MGK_RegistryErrorImageExpected 401 -#define MGK_RegistryErrorImageInfoExpected 402 -#define MGK_RegistryErrorStructureSizeMismatch 403 -#define MGK_RegistryErrorUnableToGetRegistryID 404 -#define MGK_RegistryErrorUnableToLocateImage 405 -#define MGK_RegistryErrorUnableToSetRegistry 406 -#define MGK_RegistryFatalErrorDefault 407 -#define MGK_RegistryWarningDefault 408 -#define MGK_ResourceLimitErrorCacheResourcesExhausted 409 -#define MGK_ResourceLimitErrorImagePixelHeightLimitExceeded 410 -#define MGK_ResourceLimitErrorImagePixelLimitExceeded 411 -#define MGK_ResourceLimitErrorImagePixelWidthLimitExceeded 412 -#define MGK_ResourceLimitErrorMemoryAllocationFailed 413 -#define MGK_ResourceLimitErrorNexusPixelHeightLimitExceeded 414 -#define MGK_ResourceLimitErrorNexusPixelLimitExceeded 415 -#define MGK_ResourceLimitErrorNexusPixelWidthLimitExceeded 416 -#define MGK_ResourceLimitErrorNoPixelsDefinedInCache 417 -#define MGK_ResourceLimitErrorPixelCacheAllocationFailed 418 -#define MGK_ResourceLimitErrorReadLimitExceeded 419 -#define MGK_ResourceLimitErrorUnableToAddColorProfile 420 -#define MGK_ResourceLimitErrorUnableToAddGenericProfile 421 -#define MGK_ResourceLimitErrorUnableToAddIPTCProfile 422 -#define MGK_ResourceLimitErrorUnableToAddOrRemoveProfile 423 -#define MGK_ResourceLimitErrorUnableToAllocateCoefficients 424 -#define MGK_ResourceLimitErrorUnableToAllocateColormap 425 -#define MGK_ResourceLimitErrorUnableToAllocateICCProfile 426 -#define MGK_ResourceLimitErrorUnableToAllocateImage 427 -#define MGK_ResourceLimitErrorUnableToAllocateString 428 -#define MGK_ResourceLimitErrorUnableToAnnotateImage 429 -#define MGK_ResourceLimitErrorUnableToAverageImageSequence 430 -#define MGK_ResourceLimitErrorUnableToCloneDrawingWand 431 -#define MGK_ResourceLimitErrorUnableToCloneImage 432 -#define MGK_ResourceLimitErrorUnableToComputeImageSignature 433 -#define MGK_ResourceLimitErrorUnableToConstituteImage 434 -#define MGK_ResourceLimitErrorUnableToConvertFont 435 -#define MGK_ResourceLimitErrorUnableToConvertStringToTokens 436 -#define MGK_ResourceLimitErrorUnableToCreateColormap 437 -#define MGK_ResourceLimitErrorUnableToCreateColorTransform 438 -#define MGK_ResourceLimitErrorUnableToCreateCommandWidget 439 -#define MGK_ResourceLimitErrorUnableToCreateImageGroup 440 -#define MGK_ResourceLimitErrorUnableToCreateImageMontage 441 -#define MGK_ResourceLimitErrorUnableToCreateXWindow 442 -#define MGK_ResourceLimitErrorUnableToCropImage 443 -#define MGK_ResourceLimitErrorUnableToDespeckleImage 444 -#define MGK_ResourceLimitErrorUnableToDetermineImageClass 445 -#define MGK_ResourceLimitErrorUnableToDetermineTheNumberOfImageColors 446 -#define MGK_ResourceLimitErrorUnableToDitherImage 447 -#define MGK_ResourceLimitErrorUnableToDrawOnImage 448 -#define MGK_ResourceLimitErrorUnableToEdgeImage 449 -#define MGK_ResourceLimitErrorUnableToEmbossImage 450 -#define MGK_ResourceLimitErrorUnableToEnhanceImage 451 -#define MGK_ResourceLimitErrorUnableToFloodfillImage 452 -#define MGK_ResourceLimitErrorUnableToGammaCorrectImage 453 -#define MGK_ResourceLimitErrorUnableToGetBestIconSize 454 -#define MGK_ResourceLimitErrorUnableToGetFromRegistry 455 -#define MGK_ResourceLimitErrorUnableToGetPackageInfo 456 -#define MGK_ResourceLimitErrorUnableToInterpretMSLImage 457 -#define MGK_ResourceLimitErrorUnableToLevelImage 458 -#define MGK_ResourceLimitErrorUnableToMagnifyImage 459 -#define MGK_ResourceLimitErrorUnableToManageColor 460 -#define MGK_ResourceLimitErrorUnableToMapImage 461 -#define MGK_ResourceLimitErrorUnableToMapImageSequence 462 -#define MGK_ResourceLimitErrorUnableToMedianFilterImage 463 -#define MGK_ResourceLimitErrorUnableToMotionBlurImage 464 -#define MGK_ResourceLimitErrorUnableToNoiseFilterImage 465 -#define MGK_ResourceLimitErrorUnableToNormalizeImage 466 -#define MGK_ResourceLimitErrorUnableToOpenColorProfile 467 -#define MGK_ResourceLimitErrorUnableToQuantizeImage 468 -#define MGK_ResourceLimitErrorUnableToQuantizeImageSequence 469 -#define MGK_ResourceLimitErrorUnableToReadTextChunk 470 -#define MGK_ResourceLimitErrorUnableToReadXImage 471 -#define MGK_ResourceLimitErrorUnableToReadXServerColormap 472 -#define MGK_ResourceLimitErrorUnableToResizeImage 473 -#define MGK_ResourceLimitErrorUnableToRotateImage 474 -#define MGK_ResourceLimitErrorUnableToSampleImage 475 -#define MGK_ResourceLimitErrorUnableToScaleImage 476 -#define MGK_ResourceLimitErrorUnableToSelectImage 477 -#define MGK_ResourceLimitErrorUnableToSharpenImage 478 -#define MGK_ResourceLimitErrorUnableToShaveImage 479 -#define MGK_ResourceLimitErrorUnableToShearImage 480 -#define MGK_ResourceLimitErrorUnableToSortImageColormap 481 -#define MGK_ResourceLimitErrorUnableToThresholdImage 482 -#define MGK_ResourceLimitErrorUnableToTransformColorspace 483 -#define MGK_ResourceLimitFatalErrorMemoryAllocationFailed 484 -#define MGK_ResourceLimitFatalErrorSemaporeOperationFailed 485 -#define MGK_ResourceLimitFatalErrorUnableToAllocateAscii85Info 486 -#define MGK_ResourceLimitFatalErrorUnableToAllocateCacheInfo 487 -#define MGK_ResourceLimitFatalErrorUnableToAllocateCacheView 488 -#define MGK_ResourceLimitFatalErrorUnableToAllocateColorInfo 489 -#define MGK_ResourceLimitFatalErrorUnableToAllocateDashPattern 490 -#define MGK_ResourceLimitFatalErrorUnableToAllocateDelegateInfo 491 -#define MGK_ResourceLimitFatalErrorUnableToAllocateDerivatives 492 -#define MGK_ResourceLimitFatalErrorUnableToAllocateDrawContext 493 -#define MGK_ResourceLimitFatalErrorUnableToAllocateDrawInfo 494 -#define MGK_ResourceLimitFatalErrorUnableToAllocateDrawingWand 495 -#define MGK_ResourceLimitFatalErrorUnableToAllocateGammaMap 496 -#define MGK_ResourceLimitFatalErrorUnableToAllocateImage 497 -#define MGK_ResourceLimitFatalErrorUnableToAllocateImagePixels 498 -#define MGK_ResourceLimitFatalErrorUnableToAllocateLogInfo 499 -#define MGK_ResourceLimitFatalErrorUnableToAllocateMagicInfo 500 -#define MGK_ResourceLimitFatalErrorUnableToAllocateMagickInfo 501 -#define MGK_ResourceLimitFatalErrorUnableToAllocateMagickMap 502 -#define MGK_ResourceLimitFatalErrorUnableToAllocateModuleInfo 503 -#define MGK_ResourceLimitFatalErrorUnableToAllocateMontageInfo 504 -#define MGK_ResourceLimitFatalErrorUnableToAllocateQuantizeInfo 505 -#define MGK_ResourceLimitFatalErrorUnableToAllocateRandomKernel 506 -#define MGK_ResourceLimitFatalErrorUnableToAllocateRegistryInfo 507 -#define MGK_ResourceLimitFatalErrorUnableToAllocateSemaphoreInfo 508 -#define MGK_ResourceLimitFatalErrorUnableToAllocateString 509 -#define MGK_ResourceLimitFatalErrorUnableToAllocateTypeInfo 510 -#define MGK_ResourceLimitFatalErrorUnableToAllocateWand 511 -#define MGK_ResourceLimitFatalErrorUnableToAnimateImageSequence 512 -#define MGK_ResourceLimitFatalErrorUnableToCloneBlobInfo 513 -#define MGK_ResourceLimitFatalErrorUnableToCloneCacheInfo 514 -#define MGK_ResourceLimitFatalErrorUnableToCloneImage 515 -#define MGK_ResourceLimitFatalErrorUnableToCloneImageInfo 516 -#define MGK_ResourceLimitFatalErrorUnableToConcatenateString 517 -#define MGK_ResourceLimitFatalErrorUnableToConvertText 518 -#define MGK_ResourceLimitFatalErrorUnableToCreateColormap 519 -#define MGK_ResourceLimitFatalErrorUnableToDestroySemaphore 520 -#define MGK_ResourceLimitFatalErrorUnableToDisplayImage 521 -#define MGK_ResourceLimitFatalErrorUnableToEscapeString 522 -#define MGK_ResourceLimitFatalErrorUnableToInitializeSemaphore 523 -#define MGK_ResourceLimitFatalErrorUnableToInterpretMSLImage 524 -#define MGK_ResourceLimitFatalErrorUnableToLockSemaphore 525 -#define MGK_ResourceLimitFatalErrorUnableToObtainRandomEntropy 526 -#define MGK_ResourceLimitFatalErrorUnableToUnlockSemaphore 527 -#define MGK_ResourceLimitWarningMemoryAllocationFailed 528 -#define MGK_StreamErrorImageDoesNotContainTheStreamGeometry 529 -#define MGK_StreamErrorNoStreamHandlerIsDefined 530 -#define MGK_StreamErrorPixelCacheIsNotOpen 531 -#define MGK_StreamErrorUnableToAcquirePixelStream 532 -#define MGK_StreamErrorUnableToSetPixelStream 533 -#define MGK_StreamErrorUnableToSyncPixelStream 534 -#define MGK_StreamFatalErrorDefault 535 -#define MGK_StreamWarningDefault 536 -#define MGK_TypeErrorFontNotSpecified 537 -#define MGK_TypeErrorFontSubstitutionRequired 538 -#define MGK_TypeErrorUnableToGetTypeMetrics 539 -#define MGK_TypeErrorUnableToInitializeFreetypeLibrary 540 -#define MGK_TypeErrorUnableToReadFont 541 -#define MGK_TypeErrorUnrecognizedFontEncoding 542 -#define MGK_TypeFatalErrorDefault 543 -#define MGK_TypeWarningDefault 544 -#define MGK_WandErrorInvalidColormapIndex 545 -#define MGK_WandErrorWandAPINotImplemented 546 -#define MGK_WandErrorWandContainsNoImageIndexs 547 -#define MGK_WandErrorWandContainsNoImages 548 -#define MGK_XServerErrorColorIsNotKnownToServer 549 -#define MGK_XServerErrorNoWindowWithSpecifiedIDExists 550 -#define MGK_XServerErrorStandardColormapIsNotInitialized 551 -#define MGK_XServerErrorUnableToConnectToRemoteDisplay 552 -#define MGK_XServerErrorUnableToCreateBitmap 553 -#define MGK_XServerErrorUnableToCreateColormap 554 -#define MGK_XServerErrorUnableToCreatePixmap 555 -#define MGK_XServerErrorUnableToCreateProperty 556 -#define MGK_XServerErrorUnableToCreateStandardColormap 557 -#define MGK_XServerErrorUnableToDisplayImageInfo 558 -#define MGK_XServerErrorUnableToGetProperty 559 -#define MGK_XServerErrorUnableToGetStandardColormap 560 -#define MGK_XServerErrorUnableToGetVisual 561 -#define MGK_XServerErrorUnableToGrabMouse 562 -#define MGK_XServerErrorUnableToLoadFont 563 -#define MGK_XServerErrorUnableToMatchVisualToStandardColormap 564 -#define MGK_XServerErrorUnableToOpenXServer 565 -#define MGK_XServerErrorUnableToReadXAttributes 566 -#define MGK_XServerErrorUnableToReadXWindowImage 567 -#define MGK_XServerErrorUnrecognizedColormapType 568 -#define MGK_XServerErrorUnrecognizedGravityType 569 -#define MGK_XServerErrorUnrecognizedVisualSpecifier 570 -#define MGK_XServerFatalErrorUnableToAllocateXHints 571 -#define MGK_XServerFatalErrorUnableToCreateCursor 572 -#define MGK_XServerFatalErrorUnableToCreateGraphicContext 573 -#define MGK_XServerFatalErrorUnableToCreateStandardColormap 574 -#define MGK_XServerFatalErrorUnableToCreateTextProperty 575 -#define MGK_XServerFatalErrorUnableToCreateXImage 576 -#define MGK_XServerFatalErrorUnableToCreateXPixmap 577 -#define MGK_XServerFatalErrorUnableToCreateXWindow 578 -#define MGK_XServerFatalErrorUnableToDisplayImage 579 -#define MGK_XServerFatalErrorUnableToDitherImage 580 -#define MGK_XServerFatalErrorUnableToGetPixelInfo 581 -#define MGK_XServerFatalErrorUnableToGetVisual 582 -#define MGK_XServerFatalErrorUnableToLoadFont 583 -#define MGK_XServerFatalErrorUnableToMakeXWindow 584 -#define MGK_XServerFatalErrorUnableToOpenXServer 585 -#define MGK_XServerFatalErrorUnableToViewFonts 586 -#define MGK_XServerWarningUnableToGetVisual 587 -#define MGK_XServerWarningUsingDefaultVisual 588 +#define MGK_OptionErrorUnableToSpreadImage 342 +#define MGK_OptionErrorUnableToThresholdImage 343 +#define MGK_OptionErrorUnableToWaveImage 344 +#define MGK_OptionErrorUnrecognizedAttribute 345 +#define MGK_OptionErrorUnrecognizedChannelType 346 +#define MGK_OptionErrorUnrecognizedColor 347 +#define MGK_OptionErrorUnrecognizedColormapType 348 +#define MGK_OptionErrorUnrecognizedColorspace 349 +#define MGK_OptionErrorUnrecognizedCommand 350 +#define MGK_OptionErrorUnrecognizedComposeOperator 351 +#define MGK_OptionErrorUnrecognizedDisposeMethod 352 +#define MGK_OptionErrorUnrecognizedElement 353 +#define MGK_OptionErrorUnrecognizedEndianType 354 +#define MGK_OptionErrorUnrecognizedGravityType 355 +#define MGK_OptionErrorUnrecognizedHighlightStyle 356 +#define MGK_OptionErrorUnrecognizedImageCompression 357 +#define MGK_OptionErrorUnrecognizedImageFilter 358 +#define MGK_OptionErrorUnrecognizedImageFormat 359 +#define MGK_OptionErrorUnrecognizedImageMode 360 +#define MGK_OptionErrorUnrecognizedImageType 361 +#define MGK_OptionErrorUnrecognizedIntentType 362 +#define MGK_OptionErrorUnrecognizedInterlaceType 363 +#define MGK_OptionErrorUnrecognizedListType 364 +#define MGK_OptionErrorUnrecognizedMetric 365 +#define MGK_OptionErrorUnrecognizedModeType 366 +#define MGK_OptionErrorUnrecognizedNoiseType 367 +#define MGK_OptionErrorUnrecognizedOperator 368 +#define MGK_OptionErrorUnrecognizedOption 369 +#define MGK_OptionErrorUnrecognizedPerlMagickMethod 370 +#define MGK_OptionErrorUnrecognizedPixelMap 371 +#define MGK_OptionErrorUnrecognizedPreviewType 372 +#define MGK_OptionErrorUnrecognizedResourceType 373 +#define MGK_OptionErrorUnrecognizedType 374 +#define MGK_OptionErrorUnrecognizedUnitsType 375 +#define MGK_OptionErrorUnrecognizedVirtualPixelMethod 376 +#define MGK_OptionErrorUnsupportedSamplingFactor 377 +#define MGK_OptionErrorUsageError 378 +#define MGK_OptionFatalErrorInvalidColorspaceType 379 +#define MGK_OptionFatalErrorInvalidEndianType 380 +#define MGK_OptionFatalErrorInvalidImageType 381 +#define MGK_OptionFatalErrorInvalidInterlaceType 382 +#define MGK_OptionFatalErrorMissingAnImageFilename 383 +#define MGK_OptionFatalErrorMissingArgument 384 +#define MGK_OptionFatalErrorNoImagesWereLoaded 385 +#define MGK_OptionFatalErrorOptionLengthExceedsLimit 386 +#define MGK_OptionFatalErrorRequestDidNotReturnAnImage 387 +#define MGK_OptionFatalErrorUnableToOpenXServer 388 +#define MGK_OptionFatalErrorUnableToPersistKey 389 +#define MGK_OptionFatalErrorUnrecognizedColormapType 390 +#define MGK_OptionFatalErrorUnrecognizedColorspaceType 391 +#define MGK_OptionFatalErrorUnrecognizedDisposeMethod 392 +#define MGK_OptionFatalErrorUnrecognizedEndianType 393 +#define MGK_OptionFatalErrorUnrecognizedFilterType 394 +#define MGK_OptionFatalErrorUnrecognizedImageCompressionType 395 +#define MGK_OptionFatalErrorUnrecognizedImageType 396 +#define MGK_OptionFatalErrorUnrecognizedInterlaceType 397 +#define MGK_OptionFatalErrorUnrecognizedOption 398 +#define MGK_OptionFatalErrorUnrecognizedResourceType 399 +#define MGK_OptionFatalErrorUnrecognizedVirtualPixelMethod 400 +#define MGK_OptionWarningUnrecognizedColor 401 +#define MGK_RegistryErrorImageExpected 402 +#define MGK_RegistryErrorImageInfoExpected 403 +#define MGK_RegistryErrorStructureSizeMismatch 404 +#define MGK_RegistryErrorUnableToGetRegistryID 405 +#define MGK_RegistryErrorUnableToLocateImage 406 +#define MGK_RegistryErrorUnableToSetRegistry 407 +#define MGK_RegistryFatalErrorDefault 408 +#define MGK_RegistryWarningDefault 409 +#define MGK_ResourceLimitErrorCacheResourcesExhausted 410 +#define MGK_ResourceLimitErrorImagePixelHeightLimitExceeded 411 +#define MGK_ResourceLimitErrorImagePixelLimitExceeded 412 +#define MGK_ResourceLimitErrorImagePixelWidthLimitExceeded 413 +#define MGK_ResourceLimitErrorMemoryAllocationFailed 414 +#define MGK_ResourceLimitErrorNexusPixelHeightLimitExceeded 415 +#define MGK_ResourceLimitErrorNexusPixelLimitExceeded 416 +#define MGK_ResourceLimitErrorNexusPixelWidthLimitExceeded 417 +#define MGK_ResourceLimitErrorNoPixelsDefinedInCache 418 +#define MGK_ResourceLimitErrorPixelCacheAllocationFailed 419 +#define MGK_ResourceLimitErrorReadLimitExceeded 420 +#define MGK_ResourceLimitErrorUnableToAddColorProfile 421 +#define MGK_ResourceLimitErrorUnableToAddGenericProfile 422 +#define MGK_ResourceLimitErrorUnableToAddIPTCProfile 423 +#define MGK_ResourceLimitErrorUnableToAddOrRemoveProfile 424 +#define MGK_ResourceLimitErrorUnableToAllocateCoefficients 425 +#define MGK_ResourceLimitErrorUnableToAllocateColormap 426 +#define MGK_ResourceLimitErrorUnableToAllocateICCProfile 427 +#define MGK_ResourceLimitErrorUnableToAllocateImage 428 +#define MGK_ResourceLimitErrorUnableToAllocateString 429 +#define MGK_ResourceLimitErrorUnableToAnnotateImage 430 +#define MGK_ResourceLimitErrorUnableToAverageImageSequence 431 +#define MGK_ResourceLimitErrorUnableToCloneDrawingWand 432 +#define MGK_ResourceLimitErrorUnableToCloneImage 433 +#define MGK_ResourceLimitErrorUnableToComputeImageSignature 434 +#define MGK_ResourceLimitErrorUnableToConstituteImage 435 +#define MGK_ResourceLimitErrorUnableToConvertFont 436 +#define MGK_ResourceLimitErrorUnableToConvertStringToTokens 437 +#define MGK_ResourceLimitErrorUnableToCreateColormap 438 +#define MGK_ResourceLimitErrorUnableToCreateColorTransform 439 +#define MGK_ResourceLimitErrorUnableToCreateCommandWidget 440 +#define MGK_ResourceLimitErrorUnableToCreateImageGroup 441 +#define MGK_ResourceLimitErrorUnableToCreateImageMontage 442 +#define MGK_ResourceLimitErrorUnableToCreateXWindow 443 +#define MGK_ResourceLimitErrorUnableToCropImage 444 +#define MGK_ResourceLimitErrorUnableToDespeckleImage 445 +#define MGK_ResourceLimitErrorUnableToDetermineImageClass 446 +#define MGK_ResourceLimitErrorUnableToDetermineTheNumberOfImageColors 447 +#define MGK_ResourceLimitErrorUnableToDitherImage 448 +#define MGK_ResourceLimitErrorUnableToDrawOnImage 449 +#define MGK_ResourceLimitErrorUnableToEdgeImage 450 +#define MGK_ResourceLimitErrorUnableToEmbossImage 451 +#define MGK_ResourceLimitErrorUnableToEnhanceImage 452 +#define MGK_ResourceLimitErrorUnableToFloodfillImage 453 +#define MGK_ResourceLimitErrorUnableToGammaCorrectImage 454 +#define MGK_ResourceLimitErrorUnableToGetBestIconSize 455 +#define MGK_ResourceLimitErrorUnableToGetFromRegistry 456 +#define MGK_ResourceLimitErrorUnableToGetPackageInfo 457 +#define MGK_ResourceLimitErrorUnableToInterpretMSLImage 458 +#define MGK_ResourceLimitErrorUnableToLevelImage 459 +#define MGK_ResourceLimitErrorUnableToMagnifyImage 460 +#define MGK_ResourceLimitErrorUnableToManageColor 461 +#define MGK_ResourceLimitErrorUnableToMapImage 462 +#define MGK_ResourceLimitErrorUnableToMapImageSequence 463 +#define MGK_ResourceLimitErrorUnableToMedianFilterImage 464 +#define MGK_ResourceLimitErrorUnableToMotionBlurImage 465 +#define MGK_ResourceLimitErrorUnableToNoiseFilterImage 466 +#define MGK_ResourceLimitErrorUnableToNormalizeImage 467 +#define MGK_ResourceLimitErrorUnableToOpenColorProfile 468 +#define MGK_ResourceLimitErrorUnableToQuantizeImage 469 +#define MGK_ResourceLimitErrorUnableToQuantizeImageSequence 470 +#define MGK_ResourceLimitErrorUnableToReadTextChunk 471 +#define MGK_ResourceLimitErrorUnableToReadXImage 472 +#define MGK_ResourceLimitErrorUnableToReadXServerColormap 473 +#define MGK_ResourceLimitErrorUnableToResizeImage 474 +#define MGK_ResourceLimitErrorUnableToRotateImage 475 +#define MGK_ResourceLimitErrorUnableToSampleImage 476 +#define MGK_ResourceLimitErrorUnableToScaleImage 477 +#define MGK_ResourceLimitErrorUnableToSelectImage 478 +#define MGK_ResourceLimitErrorUnableToSharpenImage 479 +#define MGK_ResourceLimitErrorUnableToShaveImage 480 +#define MGK_ResourceLimitErrorUnableToShearImage 481 +#define MGK_ResourceLimitErrorUnableToSortImageColormap 482 +#define MGK_ResourceLimitErrorUnableToThresholdImage 483 +#define MGK_ResourceLimitErrorUnableToTransformColorspace 484 +#define MGK_ResourceLimitFatalErrorMemoryAllocationFailed 485 +#define MGK_ResourceLimitFatalErrorSemaporeOperationFailed 486 +#define MGK_ResourceLimitFatalErrorUnableToAllocateAscii85Info 487 +#define MGK_ResourceLimitFatalErrorUnableToAllocateCacheInfo 488 +#define MGK_ResourceLimitFatalErrorUnableToAllocateCacheView 489 +#define MGK_ResourceLimitFatalErrorUnableToAllocateColorInfo 490 +#define MGK_ResourceLimitFatalErrorUnableToAllocateDashPattern 491 +#define MGK_ResourceLimitFatalErrorUnableToAllocateDelegateInfo 492 +#define MGK_ResourceLimitFatalErrorUnableToAllocateDerivatives 493 +#define MGK_ResourceLimitFatalErrorUnableToAllocateDrawContext 494 +#define MGK_ResourceLimitFatalErrorUnableToAllocateDrawInfo 495 +#define MGK_ResourceLimitFatalErrorUnableToAllocateDrawingWand 496 +#define MGK_ResourceLimitFatalErrorUnableToAllocateGammaMap 497 +#define MGK_ResourceLimitFatalErrorUnableToAllocateImage 498 +#define MGK_ResourceLimitFatalErrorUnableToAllocateImagePixels 499 +#define MGK_ResourceLimitFatalErrorUnableToAllocateLogInfo 500 +#define MGK_ResourceLimitFatalErrorUnableToAllocateMagicInfo 501 +#define MGK_ResourceLimitFatalErrorUnableToAllocateMagickInfo 502 +#define MGK_ResourceLimitFatalErrorUnableToAllocateMagickMap 503 +#define MGK_ResourceLimitFatalErrorUnableToAllocateModuleInfo 504 +#define MGK_ResourceLimitFatalErrorUnableToAllocateMontageInfo 505 +#define MGK_ResourceLimitFatalErrorUnableToAllocateQuantizeInfo 506 +#define MGK_ResourceLimitFatalErrorUnableToAllocateRandomKernel 507 +#define MGK_ResourceLimitFatalErrorUnableToAllocateRegistryInfo 508 +#define MGK_ResourceLimitFatalErrorUnableToAllocateSemaphoreInfo 509 +#define MGK_ResourceLimitFatalErrorUnableToAllocateString 510 +#define MGK_ResourceLimitFatalErrorUnableToAllocateTypeInfo 511 +#define MGK_ResourceLimitFatalErrorUnableToAllocateWand 512 +#define MGK_ResourceLimitFatalErrorUnableToAnimateImageSequence 513 +#define MGK_ResourceLimitFatalErrorUnableToCloneBlobInfo 514 +#define MGK_ResourceLimitFatalErrorUnableToCloneCacheInfo 515 +#define MGK_ResourceLimitFatalErrorUnableToCloneImage 516 +#define MGK_ResourceLimitFatalErrorUnableToCloneImageInfo 517 +#define MGK_ResourceLimitFatalErrorUnableToConcatenateString 518 +#define MGK_ResourceLimitFatalErrorUnableToConvertText 519 +#define MGK_ResourceLimitFatalErrorUnableToCreateColormap 520 +#define MGK_ResourceLimitFatalErrorUnableToDestroySemaphore 521 +#define MGK_ResourceLimitFatalErrorUnableToDisplayImage 522 +#define MGK_ResourceLimitFatalErrorUnableToEscapeString 523 +#define MGK_ResourceLimitFatalErrorUnableToInitializeSemaphore 524 +#define MGK_ResourceLimitFatalErrorUnableToInterpretMSLImage 525 +#define MGK_ResourceLimitFatalErrorUnableToLockSemaphore 526 +#define MGK_ResourceLimitFatalErrorUnableToObtainRandomEntropy 527 +#define MGK_ResourceLimitFatalErrorUnableToUnlockSemaphore 528 +#define MGK_ResourceLimitWarningMemoryAllocationFailed 529 +#define MGK_StreamErrorImageDoesNotContainTheStreamGeometry 530 +#define MGK_StreamErrorNoStreamHandlerIsDefined 531 +#define MGK_StreamErrorPixelCacheIsNotOpen 532 +#define MGK_StreamErrorUnableToAcquirePixelStream 533 +#define MGK_StreamErrorUnableToSetPixelStream 534 +#define MGK_StreamErrorUnableToSyncPixelStream 535 +#define MGK_StreamFatalErrorDefault 536 +#define MGK_StreamWarningDefault 537 +#define MGK_TypeErrorFontNotSpecified 538 +#define MGK_TypeErrorFontSubstitutionRequired 539 +#define MGK_TypeErrorUnableToGetTypeMetrics 540 +#define MGK_TypeErrorUnableToInitializeFreetypeLibrary 541 +#define MGK_TypeErrorUnableToReadFont 542 +#define MGK_TypeErrorUnrecognizedFontEncoding 543 +#define MGK_TypeFatalErrorDefault 544 +#define MGK_TypeWarningDefault 545 +#define MGK_WandErrorInvalidColormapIndex 546 +#define MGK_WandErrorWandAPINotImplemented 547 +#define MGK_WandErrorWandContainsNoImageIndexs 548 +#define MGK_WandErrorWandContainsNoImages 549 +#define MGK_XServerErrorColorIsNotKnownToServer 550 +#define MGK_XServerErrorNoWindowWithSpecifiedIDExists 551 +#define MGK_XServerErrorStandardColormapIsNotInitialized 552 +#define MGK_XServerErrorUnableToConnectToRemoteDisplay 553 +#define MGK_XServerErrorUnableToCreateBitmap 554 +#define MGK_XServerErrorUnableToCreateColormap 555 +#define MGK_XServerErrorUnableToCreatePixmap 556 +#define MGK_XServerErrorUnableToCreateProperty 557 +#define MGK_XServerErrorUnableToCreateStandardColormap 558 +#define MGK_XServerErrorUnableToDisplayImageInfo 559 +#define MGK_XServerErrorUnableToGetProperty 560 +#define MGK_XServerErrorUnableToGetStandardColormap 561 +#define MGK_XServerErrorUnableToGetVisual 562 +#define MGK_XServerErrorUnableToGrabMouse 563 +#define MGK_XServerErrorUnableToLoadFont 564 +#define MGK_XServerErrorUnableToMatchVisualToStandardColormap 565 +#define MGK_XServerErrorUnableToOpenXServer 566 +#define MGK_XServerErrorUnableToReadXAttributes 567 +#define MGK_XServerErrorUnableToReadXWindowImage 568 +#define MGK_XServerErrorUnrecognizedColormapType 569 +#define MGK_XServerErrorUnrecognizedGravityType 570 +#define MGK_XServerErrorUnrecognizedVisualSpecifier 571 +#define MGK_XServerFatalErrorUnableToAllocateXHints 572 +#define MGK_XServerFatalErrorUnableToCreateCursor 573 +#define MGK_XServerFatalErrorUnableToCreateGraphicContext 574 +#define MGK_XServerFatalErrorUnableToCreateStandardColormap 575 +#define MGK_XServerFatalErrorUnableToCreateTextProperty 576 +#define MGK_XServerFatalErrorUnableToCreateXImage 577 +#define MGK_XServerFatalErrorUnableToCreateXPixmap 578 +#define MGK_XServerFatalErrorUnableToCreateXWindow 579 +#define MGK_XServerFatalErrorUnableToDisplayImage 580 +#define MGK_XServerFatalErrorUnableToDitherImage 581 +#define MGK_XServerFatalErrorUnableToGetPixelInfo 582 +#define MGK_XServerFatalErrorUnableToGetVisual 583 +#define MGK_XServerFatalErrorUnableToLoadFont 584 +#define MGK_XServerFatalErrorUnableToMakeXWindow 585 +#define MGK_XServerFatalErrorUnableToOpenXServer 586 +#define MGK_XServerFatalErrorUnableToViewFonts 587 +#define MGK_XServerWarningUnableToGetVisual 588 +#define MGK_XServerWarningUsingDefaultVisual 589 #endif @@ -673,25 +674,25 @@ static const SeverityInfo severity_map[] = { "Monitor/FatalError", 288, MonitorFatalError }, { "Monitor/Warning", 290, MonitorWarning }, { "Option/Error", 291, OptionError }, - { "Option/FatalError", 377, OptionFatalError }, - { "Option/Warning", 399, OptionWarning }, - { "Registry/Error", 400, RegistryError }, - { "Registry/FatalError", 406, RegistryFatalError }, - { "Registry/Warning", 407, RegistryWarning }, - { "Resource/Limit/Error", 408, ResourceLimitError }, - { "Resource/Limit/FatalError", 483, ResourceLimitFatalError }, - { "Resource/Limit/Warning", 527, ResourceLimitWarning }, - { "Stream/Error", 528, StreamError }, - { "Stream/FatalError", 534, StreamFatalError }, - { "Stream/Warning", 535, StreamWarning }, - { "Type/Error", 536, TypeError }, - { "Type/FatalError", 542, TypeFatalError }, - { "Type/Warning", 543, TypeWarning }, - { "Wand/Error", 544, WandError }, - { "XServer/Error", 548, XServerError }, - { "XServer/FatalError", 570, XServerFatalError }, - { "XServer/Warning", 586, XServerWarning }, - { "", 588, UndefinedException } + { "Option/FatalError", 378, OptionFatalError }, + { "Option/Warning", 400, OptionWarning }, + { "Registry/Error", 401, RegistryError }, + { "Registry/FatalError", 407, RegistryFatalError }, + { "Registry/Warning", 408, RegistryWarning }, + { "Resource/Limit/Error", 409, ResourceLimitError }, + { "Resource/Limit/FatalError", 484, ResourceLimitFatalError }, + { "Resource/Limit/Warning", 528, ResourceLimitWarning }, + { "Stream/Error", 529, StreamError }, + { "Stream/FatalError", 535, StreamFatalError }, + { "Stream/Warning", 536, StreamWarning }, + { "Type/Error", 537, TypeError }, + { "Type/FatalError", 543, TypeFatalError }, + { "Type/Warning", 544, TypeWarning }, + { "Wand/Error", 545, WandError }, + { "XServer/Error", 549, XServerError }, + { "XServer/FatalError", 571, XServerFatalError }, + { "XServer/Warning", 587, XServerWarning }, + { "", 589, UndefinedException } }; #endif @@ -1045,6 +1046,7 @@ static const MessageInfo message_map[] = { "UnableToPaintImage", MGK_OptionErrorUnableToPaintImage }, { "UnableToRaiseImage", MGK_OptionErrorUnableToRaiseImage }, { "UnableToSharpenImage", MGK_OptionErrorUnableToSharpenImage }, + { "UnableToSpreadImage", MGK_OptionErrorUnableToSpreadImage }, { "UnableToThresholdImage", MGK_OptionErrorUnableToThresholdImage }, { "UnableToWaveImage", MGK_OptionErrorUnableToWaveImage }, { "UnrecognizedAttribute", MGK_OptionErrorUnrecognizedAttribute }, @@ -1640,6 +1642,7 @@ static const char message_dat[] = "Unable to paint image\0" "Unable to raise image\0" "Unable to sharpen image\0" + "Unable to spread image\0" "Unable to threshold image\0" "Unable to wave image\0" "Unrecognized attribute\0" @@ -2234,253 +2237,254 @@ static const unsigned short message_dat_offsets[] = 9932, 9954, 9978, - 10004, - 10025, + 10001, + 10027, 10048, - 10074, - 10093, - 10120, - 10150, - 10222, - 10252, - 10280, - 10301, - 10326, - 10352, - 10381, - 10412, - 10438, - 10464, - 10488, - 10512, - 10537, - 10565, + 10071, + 10097, + 10116, + 10143, + 10173, + 10245, + 10275, + 10303, + 10324, + 10349, + 10375, + 10404, + 10435, + 10461, + 10487, + 10511, + 10535, + 10560, 10588, - 10614, + 10611, 10637, - 10661, - 10683, - 10703, - 10734, + 10660, + 10684, + 10706, + 10726, 10757, - 10783, - 10810, - 10828, - 10852, - 10886, - 10914, - 10961, - 10985, - 11005, - 11024, + 10780, + 10806, + 10833, + 10851, + 10875, + 10909, + 10937, + 10984, + 11008, + 11028, 11047, - 11073, - 11131, - 11153, - 11181, - 11213, + 11070, + 11096, + 11154, + 11176, + 11204, 11236, - 11258, - 11285, - 11314, - 11342, - 11367, - 11392, - 11422, - 11446, - 11474, - 11494, - 11521, - 11555, - 11574, - 11589, - 11609, - 11633, - 11659, + 11259, + 11281, + 11308, + 11337, + 11365, + 11390, + 11415, + 11445, + 11469, + 11497, + 11517, + 11544, + 11578, + 11597, + 11612, + 11632, + 11656, 11682, 11705, - 11719, - 11735, - 11779, - 11833, - 11880, - 11932, - 11957, - 12011, - 12058, - 12110, - 12137, - 12167, - 12205, - 12237, - 12267, - 12294, - 12326, - 12358, - 12386, - 12417, - 12442, - 12468, - 12493, - 12526, - 12555, - 12577, - 12611, - 12638, + 11728, + 11742, + 11758, + 11802, + 11856, + 11903, + 11955, + 11980, + 12034, + 12081, + 12133, + 12160, + 12190, + 12228, + 12260, + 12290, + 12317, + 12349, + 12381, + 12409, + 12440, + 12465, + 12491, + 12516, + 12549, + 12578, + 12600, + 12634, 12661, - 12697, - 12723, - 12756, - 12788, - 12817, - 12848, - 12874, - 12895, - 12921, - 12953, - 13000, + 12684, + 12720, + 12746, + 12779, + 12811, + 12840, + 12871, + 12897, + 12918, + 12944, + 12976, 13023, - 13047, - 13068, + 13046, + 13070, 13091, - 13115, - 13141, - 13171, - 13200, - 13228, - 13255, - 13285, - 13307, - 13331, + 13114, + 13138, + 13164, + 13194, + 13223, + 13251, + 13278, + 13308, + 13330, 13354, - 13374, - 13403, - 13433, - 13461, - 13490, - 13516, - 13545, - 13570, - 13604, - 13630, + 13377, + 13397, + 13426, + 13456, + 13484, + 13513, + 13539, + 13568, + 13593, + 13627, 13653, - 13686, + 13676, 13709, 13732, 13755, - 13777, + 13778, 13800, - 13824, - 13846, - 13868, - 13898, - 13924, - 13955, - 13980, - 14007, - 14039, - 14069, - 14099, - 14129, - 14161, - 14194, - 14223, - 14255, - 14284, - 14316, - 14345, - 14370, - 14402, - 14430, - 14460, - 14491, - 14521, - 14552, - 14584, - 14617, - 14650, - 14683, - 14717, - 14743, - 14772, - 14796, - 14829, - 14855, - 14882, - 14904, - 14931, - 14960, + 13823, + 13847, + 13869, + 13891, + 13921, + 13947, + 13978, + 14003, + 14030, + 14062, + 14092, + 14122, + 14152, + 14184, + 14217, + 14246, + 14278, + 14307, + 14339, + 14368, + 14393, + 14425, + 14453, + 14483, + 14514, + 14544, + 14575, + 14607, + 14640, + 14673, + 14706, + 14740, + 14766, + 14795, + 14819, + 14852, + 14878, + 14905, + 14927, + 14954, 14983, - 15009, - 15037, - 15061, - 15085, - 15116, - 15146, - 15171, - 15223, - 15250, - 15275, - 15318, - 15347, - 15371, - 15402, - 15429, - 15457, - 15471, - 15487, - 15511, - 15538, - 15565, - 15603, - 15623, - 15650, - 15664, - 15680, - 15712, - 15746, - 15786, - 15819, - 15848, - 15883, - 15920, - 15956, - 15980, - 16006, - 16030, - 16056, - 16091, - 16120, + 15006, + 15032, + 15060, + 15084, + 15108, + 15139, + 15169, + 15194, + 15246, + 15273, + 15298, + 15341, + 15370, + 15394, + 15425, + 15452, + 15480, + 15494, + 15510, + 15534, + 15561, + 15588, + 15626, + 15646, + 15673, + 15687, + 15703, + 15735, + 15769, + 15809, + 15842, + 15871, + 15906, + 15943, + 15979, + 16003, + 16029, + 16053, + 16079, + 16114, 16143, - 16175, - 16196, - 16217, - 16237, - 16281, - 16305, - 16333, - 16363, - 16390, - 16416, - 16446, - 16473, - 16499, - 16532, - 16567, - 16598, - 16623, - 16649, - 16675, - 16699, + 16166, + 16198, + 16219, + 16240, + 16260, + 16304, + 16328, + 16356, + 16386, + 16413, + 16439, + 16469, + 16496, + 16522, + 16555, + 16590, + 16621, + 16646, + 16672, + 16698, 16722, - 16747, - 16768, - 16788, - 16812, - 16836, - 16857, - 16878, - 16897, + 16745, + 16770, + 16791, + 16811, + 16835, + 16859, + 16880, + 16901, + 16920, 0 }; #endif /* if defined(_INCLUDE_MESSAGE_TABLE_) */ diff --git a/magick/log.c b/magick/log.c index 3e67ea0..d894c0b 100644 --- a/magick/log.c +++ b/magick/log.c @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003 - 2020 GraphicsMagick Group +% Copyright (C) 2003 - 2022 GraphicsMagick Group % Copyright (C) 2002 ImageMagick Studio % % This program is covered by multiple licenses, which are described in @@ -467,9 +467,9 @@ InitializeLogInfoPost(void) % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% IsEventLogging() returns MagickTrue if logging of events is enabled otherwise -% MagickFalse. This can be used to enable logging code which is otherwise -% not needed. +% IsEventLogging() returns MagickTrue if logging of events is enabled, +% otherwise MagickFalse. This can be used to enable logging code which +% is otherwise not needed. % % The format of the IsEventLogging method is: % @@ -487,6 +487,83 @@ MagickExport MagickBool IsEventLogging(void) % % % % % % +% I s E v e n t L o g g e d % +% % +% % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% IsEventLogged() returns MagickTrue if logging of events for the specified +% exception type is enabled, otherwise MagickFalse. This can be used to +% enable logging code which is otherwise not needed. +% +% The format of the IsEventLogging method is: +% +% MagickBool IsEventLogged(const ExceptionType type) +% +% +*/ +MagickExport MagickBool IsEventLogged(const ExceptionType type) +{ + unsigned int + i; + + MagickBool + enabled = MagickFalse; + + /* Short-circuit for when not logging at all */ + if (log_info->events == NoEventsMask) + return MagickFalse; + + if (log_info->events == AllEventsMask) + return MagickTrue; + + /* first translate the base type of the event to a mask */ + for (i=0; i < ArraySize(eventmask_map); i++) + { + /* if the range in the table is above 100 it represents raw + event id's. These entry types are to look for specific + severity codes. + */ + if (eventmask_map[i].start_type > 99) + { + if (((int) type >= eventmask_map[i].start_type) && + ((int) type <= eventmask_map[i].end_type)) + { + if (((unsigned int) log_info->events) & + ((unsigned int) eventmask_map[i].mask)) + { + enabled=MagickTrue; + break; + } + } + } + else + { + /* these ranges are for id's with the severity stripped + off and represent a category instead. + */ + if ((((int) type % 100) >= eventmask_map[i].start_type) && + (((int) type % 100) <= eventmask_map[i].end_type)) + { + if (((unsigned int) log_info->events) & + ((unsigned int) eventmask_map[i].mask)) + { + enabled=MagickTrue; + break; + } + } + } + } + + return enabled; +} + +/* +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% % +% % % L o g M a g i c k E v e n t % % % % % @@ -553,58 +630,8 @@ LogMagickEventList(const ExceptionType type, time_t seconds; - if (!IsEventLogging()) - return(False); - - if (log_info->events != AllEventsMask) - { - unsigned int - i; - - unsigned int - enabled; - - /* first translate the base type of the event to a mask */ - enabled=False; - for (i=0; i < ArraySize(eventmask_map); i++) - { - /* if the range in the table is above 100 it represents raw - event id's. These entry types are to look for specific - severity codes. - */ - if (eventmask_map[i].start_type > 99) - { - if (((int) type >= eventmask_map[i].start_type) && - ((int) type <= eventmask_map[i].end_type)) - { - if (((unsigned int) log_info->events) & - ((unsigned int) eventmask_map[i].mask)) - { - enabled=True; - break; - } - } - } - else - { - /* these ranges are for id's with the severity stripped - off and represent a category instead. - */ - if ((((int) type % 100) >= eventmask_map[i].start_type) && - (((int) type % 100) <= eventmask_map[i].end_type)) - { - if (((unsigned int) log_info->events) & - ((unsigned int) eventmask_map[i].mask)) - { - enabled=True; - break; - } - } - } - } - if (!enabled) - return(MagickPass); - } + if (!IsEventLogged(type)) + return MagickFalse; event[0]='\0'; message[0]='\0'; diff --git a/magick/log.h b/magick/log.h index 4bff1d6..2c47f11 100644 --- a/magick/log.h +++ b/magick/log.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2003 - 2020 GraphicsMagick Group + Copyright (C) 2003 - 2022 GraphicsMagick Group Copyright (C) 2002 ImageMagick Studio This program is covered by multiple licenses, which are described in @@ -97,6 +97,7 @@ typedef void */ extern MagickExport MagickBool IsEventLogging(void) MAGICK_FUNC_PURE, + IsEventLogged(const ExceptionType type) MAGICK_FUNC_PURE, LogMagickEvent(const ExceptionType type, const char *module,const char *function,const unsigned long line, const char *format,...) MAGICK_ATTRIBUTE((__format__ (__printf__,5,6))), diff --git a/magick/magic.c b/magick/magic.c index bb0594f..f65c281 100644 --- a/magick/magic.c +++ b/magick/magic.c @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003-2019 GraphicsMagick Group +% Copyright (C) 2003-2022 GraphicsMagick Group % Copyright (C) 2002 ImageMagick Studio % % This program is covered by multiple licenses, which are described in @@ -106,6 +106,8 @@ StaticMagic[] = MAGIC("JPEG", 0, "\377\330\377"), MAGIC("JPC", 0, "\377\117"), MAGIC("JP2", 4, "\152\120\040\040\015"), + MAGIC("JXL", 0, "\xff\x0a"), + MAGIC("JXL", 0, "\x00\x00\x00\x0c\x4a\x58\x4c\x20\x0d\x0a\x87\x0a"), MAGIC("MAT", 0, "MATLAB 5.0 MAT-file,"), MAGIC("MIFF", 0, "Id=ImageMagick"), MAGIC("MIFF", 0, "id=ImageMagick"), @@ -148,6 +150,7 @@ StaticMagic[] = MAGIC("SVG", 1, "?xml"), MAGIC("TIFF", 0, "\115\115\000\052"), MAGIC("TIFF", 0, "\111\111\052\000"), + MAGIC("TOPOL", 0, " "), MAGIC("BIGTIFF", 0, "\115\115\000\053\000\010\000\000"), MAGIC("BIGTIFF", 0, "\111\111\053\000\010\000\000\000"), MAGIC("VICAR", 0, "LBLSIZE"), diff --git a/magick/magick.c b/magick/magick.c index 0911a71..2760ef4 100644 --- a/magick/magick.c +++ b/magick/magick.c @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003-2020 GraphicsMagick Group +% Copyright (C) 2003-2023 GraphicsMagick Group % Copyright (C) 2002 ImageMagick Studio % Copyright 1991-1999 E. I. du Pont de Nemours and Company % @@ -146,10 +146,18 @@ MagickSetFileSystemBlockSize(const size_t block_size) % should be invoked in the primary (original) thread of the application's % process while shutting down, and only after any threads which might be % using GraphicsMagick functions have terminated. Since GraphicsMagick -% uses threads internally via OpenMP, it is also necessary for any function -% calls into GraphicsMagick to have already returned so that OpenMP worker -% threads are quiesced and won't be accessing any semaphores or data -% structures which are destroyed by this function. +% may use threads internally via OpenMP, it is also necessary for any +% function calls into GraphicsMagick to have already returned so that +% OpenMP worker threads are quiesced and won't be accessing any semaphores +% or data structures which are destroyed by this function. +% +% The OpenMP implementation (if present) starts/stops any OpenMP worker +% threads and allocates/frees OpenMP resources using its own algorithms. +% This means that OpenMP worker threads and OpenMP resources are likely +% to remain allocated after DestroyMagick() returns. Since OpenMP 5.0, +% invoking omp_pause_resource_all(omp_pause_hard) will assure that any +% resources allocated by OpenMP (threads, thread-specific memory, etc.) +% are freed, and this may be called after DestroyMagick() has returned. % % The format of the DestroyMagick function is: % @@ -1128,7 +1136,8 @@ InitializeMagick(const char *path) % % InitializeMagickEx() initializes the GraphicsMagick environment, % providing a bit more more control and visibility over initialization -% than the original InitializeMagick(). +% than the original InitializeMagick(). Use DestroyMagick() to destroy +% the GraphicsMagick environment when it is not longer needed. % % InitializeMagick() or InitializeMagickEx() MUST be invoked by the using % program before making use of GraphicsMagick functions or else the library @@ -1142,6 +1151,10 @@ InitializeMagick(const char *path) % then that function should be invoked before InitializeMagickEx() since % the memory allocation functions need to be consistent. % +% Available options are: +% +% o MAGICK_OPT_NO_SIGNAL_HANDER - Don't register ANSI/POSIX signal handlers +% % The format of the InitializeMagickEx function is: % % MagickPassFail InitializeMagickEx(const char *path, @@ -1152,7 +1165,7 @@ InitializeMagick(const char *path) % % o path: The execution path of the current GraphicsMagick client (or NULL) % -% o options: Options flags tailoring initializations performed +% o options: Options bit flags tailoring initializations performed % % o exception: Information about initialization failure is reported here. % @@ -1581,6 +1594,9 @@ MagickToMime(const char *magick) MediaTypes[] = { { "avi", "video/avi" }, + { "apng", "image/apng" }, + { "avif", "image/avif" }, + { "bmp", "image/bmp" }, { "cgm", "image/cgm;Version=4;ProfileId=WebCGM" }, /* W3 WebCGM */ { "dcm", "application/dicom" }, /* Incomplete. See RFC 3240 */ { "epdf", "application/pdf" }, @@ -1595,6 +1611,7 @@ MagickToMime(const char *magick) { "g3", "image/g3fax" }, { "gif", "image/gif" }, { "gif87", "image/gif" }, + { "ico", "image/x-icon" }, { "jpeg", "image/jpeg" }, { "jpg", "image/jpeg" }, { "mng", "video/x-mng" }, @@ -1607,7 +1624,8 @@ MagickToMime(const char *magick) { "svg", "image/svg+xml" }, { "tif", "image/tiff" }, { "tiff", "image/tiff" }, - { "wbmp", "image/vnd.wap.wbmp" } + { "wbmp", "image/vnd.wap.wbmp" }, + { "webp", "image/image/webp" } }; for (i=0; i < ArraySize(MediaTypes); i++) diff --git a/magick/magick_config.h.in b/magick/magick_config.h.in index a6f229a..58ea73d 100644 --- a/magick/magick_config.h.in +++ b/magick/magick_config.h.in @@ -149,6 +149,21 @@ /* Define to 1 if you have the `jas_init_library' function. */ #undef HAVE_JAS_INIT_LIBRARY +/* Define to 1 if you have the `jpeg12_read_scanlines' function. */ +#undef HAVE_JPEG12_READ_SCANLINES + +/* Define to 1 if you have the `jpeg12_write_scanlines' function. */ +#undef HAVE_JPEG12_WRITE_SCANLINES + +/* Define to 1 if you have the `jpeg16_read_scanlines' function. */ +#undef HAVE_JPEG16_READ_SCANLINES + +/* Define to 1 if you have the `jpeg16_write_scanlines' function. */ +#undef HAVE_JPEG16_WRITE_SCANLINES + +/* Define to 1 if you have the `jpeg_enable_lossless' function. */ +#undef HAVE_JPEG_ENABLE_LOSSLESS + /* Define if you have the <lcms2.h> header file. */ #undef HAVE_LCMS2_H diff --git a/magick/magick_types.h b/magick/magick_types.h index bb17db8..37c715a 100644 --- a/magick/magick_types.h +++ b/magick/magick_types.h @@ -100,12 +100,16 @@ extern "C" { # define MAGICK_SIZE_T unsigned __int64 # define MAGICK_SSIZE_T_F "I64" # define MAGICK_SSIZE_T signed __int64 + typedef size_t uintptr_t; + typedef signed __int64 ptrdiff_t; # else typedef unsigned long magick_uintptr_t; # define MAGICK_SIZE_T_F "l" # define MAGICK_SIZE_T unsigned long -# define MAGICK_SSIZE_T_F "l" -# define MAGICK_SSIZE_T long +# define MAGICK_SSIZE_T_F "" +# define MAGICK_SSIZE_T int + typedef long magick_ptrdiff_t + typedef unsigned long magick_uintptr_t; # endif // defined(WIN64) #endif /* if defined(MAGICK_IMPLEMENTATION) */ @@ -113,36 +117,50 @@ extern "C" { #else /* The following typedefs are subtituted when using Unixish configure */ - typedef signed char magick_int8_t; - typedef unsigned char magick_uint8_t; + typedef signed char magick_int8_t; /* int8_t */ + typedef unsigned char magick_uint8_t; /* uint8_t */ - typedef signed short magick_int16_t; - typedef unsigned short magick_uint16_t; + typedef signed short magick_int16_t; /* int16_t */ + typedef unsigned short magick_uint16_t; /* uint16_t */ - typedef signed int magick_int32_t; - typedef unsigned int magick_uint32_t; + typedef signed int magick_int32_t; /* int32_t */ + typedef unsigned int magick_uint32_t; /* uint32_t */ - typedef signed long magick_int64_t; - typedef unsigned long magick_uint64_t; + typedef signed long magick_int64_t; /* int64_t */ + typedef unsigned long magick_uint64_t; /* uint64_t */ # if defined(MAGICK_IMPLEMENTATION) -# define MAGICK_INT32_F "" -# define MAGICK_UINT32_F "" -# define MAGICK_INT64_F "l" -# define MAGICK_UINT64_F "l" +# define MAGICK_INT32_F "" /* %PRId32 */ +# define MAGICK_UINT32_F "" /* %PRIu32 */ +# define MAGICK_INT64_F "l" /* %PRId64 */ +# define MAGICK_UINT64_F "l" /* %PRIu64 */ - typedef unsigned long magick_uintmax_t; -# define MAGICK_UINTMAX_F "l" + /* + C99 special size specifiers: - typedef unsigned long magick_uintptr_t; -# define MAGICK_UINTPTR_F "l" + hh - signed char / unsigned char + h - short / unsigned short + ll - long long / unsigned long long + j - intmax_t / uintmax_t + z - signed size_t / size_t + t - ptrdiff_t / unsigned ptrdiff_t + */ -# define MAGICK_SIZE_T_F "l" -# define MAGICK_SIZE_T unsigned long + typedef unsigned long magick_uintmax_t; /* uintmax_t */ +# define MAGICK_UINTMAX_F "l" /* %ju */ + + typedef unsigned long magick_uintptr_t; /* uintptr_t */ +# define MAGICK_UINTPTR_F "l" /* %tu */ + + typedef signed long magick_ptrdiff_t; /* ptrdiff_t */ +# define MAGICK_PTRDIFF_F "l" /* %td */ + +# define MAGICK_SIZE_T_F "l" /* %zu */ +# define MAGICK_SIZE_T unsigned long /* size_t */ -# define MAGICK_SSIZE_T_F "l" -# define MAGICK_SSIZE_T signed long +# define MAGICK_SSIZE_T_F "l" /* %zd */ +# define MAGICK_SSIZE_T signed long /* ssize_t */ #endif /* defined(MAGICK_IMPLEMENTATION) */ diff --git a/magick/magick_types.h.in b/magick/magick_types.h.in index 78e6fa5..7a2cf39 100644 --- a/magick/magick_types.h.in +++ b/magick/magick_types.h.in @@ -100,12 +100,16 @@ extern "C" { # define MAGICK_SIZE_T unsigned __int64 # define MAGICK_SSIZE_T_F "I64" # define MAGICK_SSIZE_T signed __int64 + typedef size_t uintptr_t; + typedef signed __int64 ptrdiff_t; # else typedef unsigned long magick_uintptr_t; # define MAGICK_SIZE_T_F "l" # define MAGICK_SIZE_T unsigned long -# define MAGICK_SSIZE_T_F "l" -# define MAGICK_SSIZE_T long +# define MAGICK_SSIZE_T_F "" +# define MAGICK_SSIZE_T int + typedef long magick_ptrdiff_t + typedef unsigned long magick_uintptr_t; # endif // defined(WIN64) #endif /* if defined(MAGICK_IMPLEMENTATION) */ @@ -113,36 +117,50 @@ extern "C" { #else /* The following typedefs are subtituted when using Unixish configure */ - typedef @INT8_T@ magick_int8_t; - typedef @UINT8_T@ magick_uint8_t; + typedef @INT8_T@ magick_int8_t; /* int8_t */ + typedef @UINT8_T@ magick_uint8_t; /* uint8_t */ - typedef @INT16_T@ magick_int16_t; - typedef @UINT16_T@ magick_uint16_t; + typedef @INT16_T@ magick_int16_t; /* int16_t */ + typedef @UINT16_T@ magick_uint16_t; /* uint16_t */ - typedef @INT32_T@ magick_int32_t; - typedef @UINT32_T@ magick_uint32_t; + typedef @INT32_T@ magick_int32_t; /* int32_t */ + typedef @UINT32_T@ magick_uint32_t; /* uint32_t */ - typedef @INT64_T@ magick_int64_t; - typedef @UINT64_T@ magick_uint64_t; + typedef @INT64_T@ magick_int64_t; /* int64_t */ + typedef @UINT64_T@ magick_uint64_t; /* uint64_t */ # if defined(MAGICK_IMPLEMENTATION) -# define MAGICK_INT32_F @INT32_F@ -# define MAGICK_UINT32_F @UINT32_F@ -# define MAGICK_INT64_F @INT64_F@ -# define MAGICK_UINT64_F @UINT64_F@ +# define MAGICK_INT32_F @INT32_F@ /* %PRId32 */ +# define MAGICK_UINT32_F @UINT32_F@ /* %PRIu32 */ +# define MAGICK_INT64_F @INT64_F@ /* %PRId64 */ +# define MAGICK_UINT64_F @UINT64_F@ /* %PRIu64 */ + + /* + C99 special size specifiers: + + hh - signed char / unsigned char + h - short / unsigned short + ll - long long / unsigned long long + j - intmax_t / uintmax_t + z - signed size_t / size_t + t - ptrdiff_t / unsigned ptrdiff_t + */ + + typedef @UINTMAX_T@ magick_uintmax_t; /* uintmax_t */ +# define MAGICK_UINTMAX_F @UINTMAX_F@ /* %ju */ - typedef @UINTMAX_T@ magick_uintmax_t; -# define MAGICK_UINTMAX_F @UINTMAX_F@ + typedef @UINTPTR_T@ magick_uintptr_t; /* uintptr_t */ +# define MAGICK_UINTPTR_F @UINTPTR_F@ /* %tu */ - typedef @UINTPTR_T@ magick_uintptr_t; -# define MAGICK_UINTPTR_F @UINTPTR_F@ + typedef @PTRDIFF_T@ magick_ptrdiff_t; /* ptrdiff_t */ +# define MAGICK_PTRDIFF_F @PTRDIFF_F@ /* %td */ -# define MAGICK_SIZE_T_F @MAGICK_SIZE_T_F@ -# define MAGICK_SIZE_T @MAGICK_SIZE_T@ +# define MAGICK_SIZE_T_F @MAGICK_SIZE_T_F@ /* %zu */ +# define MAGICK_SIZE_T @MAGICK_SIZE_T@ /* size_t */ -# define MAGICK_SSIZE_T_F @MAGICK_SSIZE_T_F@ -# define MAGICK_SSIZE_T @MAGICK_SSIZE_T@ +# define MAGICK_SSIZE_T_F @MAGICK_SSIZE_T_F@ /* %zd */ +# define MAGICK_SSIZE_T @MAGICK_SSIZE_T@ /* ssize_t */ #endif /* defined(MAGICK_IMPLEMENTATION) */ diff --git a/magick/module.c b/magick/module.c index e8c6eca..7236f24 100644 --- a/magick/module.c +++ b/magick/module.c @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003 - 2019 GraphicsMagick Group +% Copyright (C) 2003 - 2022 GraphicsMagick Group % Copyright (C) 2002 ImageMagick Studio % % This program is covered by multiple licenses, which are described in @@ -589,7 +589,7 @@ FindMagickModule(const char *filename,MagickModuleType module_type, return MagickFail; } - if (IsEventLogging()) + if (IsEventLogged(ConfigureEvent)) { char list_seperator[2], @@ -1029,7 +1029,7 @@ InitializeModuleSearchPath(MagickModuleType module_type, if (skip == MagickFalse) { if (buffer[length-1] != DirectorySeparator[0]) - (void) strcat(buffer,DirectorySeparator); + (void) strlcat(buffer,DirectorySeparator,sizeof(buffer)); AddModulePath(path_map,&path_index,buffer,exception); } start += length+1; @@ -1167,7 +1167,7 @@ InitializeModuleSearchPath(MagickModuleType module_type, /* Search current directory. */ - strcpy(path,""); + strlcpy(path,"",sizeof(path)); AddModulePath(path_map,&path_index,path,exception); return (status); diff --git a/magick/module_aliases.h b/magick/module_aliases.h index 39353b8..fcddfdc 100644 --- a/magick/module_aliases.h +++ b/magick/module_aliases.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2003 - 2019 GraphicsMagick Group + Copyright (C) 2003 - 2023 GraphicsMagick Group This program is covered by multiple licenses, which are described in Copyright.txt. You should have received a copy of Copyright.txt with this @@ -81,6 +81,9 @@ static const struct MODULEALIAS("ICM","META"), MODULEALIAS("ICO","ICON"), MODULEALIAS("ICODIB", "DIB"), + MODULEALIAS("IM1","SUN"), + MODULEALIAS("IM24","SUN"), + MODULEALIAS("IM8","SUN"), MODULEALIAS("IMAGE","LOGO"), MODULEALIAS("IPTC","META"), MODULEALIAS("IPTCTEXT","META"), @@ -122,8 +125,11 @@ static const struct MODULEALIAS("PGX","JP2"), MODULEALIAS("PICON","XPM"), MODULEALIAS("PM","XPM"), + MODULEALIAS("PNG00","PNG"), MODULEALIAS("PNG24","PNG"), MODULEALIAS("PNG32","PNG"), + MODULEALIAS("PNG48","PNG"), + MODULEALIAS("PNG64","PNG"), MODULEALIAS("PNG8","PNG"), MODULEALIAS("PPM","PNM"), MODULEALIAS("PTIF","TIFF"), diff --git a/magick/montage.c b/magick/montage.c index 76c6389..79eb2b6 100644 --- a/magick/montage.c +++ b/magick/montage.c @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003-2017 GraphicsMagick Group +% Copyright (C) 2003-2023 GraphicsMagick Group % Copyright (C) 2002 ImageMagick Studio % Copyright 1991-1999 E. I. du Pont de Nemours and Company % @@ -269,7 +269,7 @@ MagickExport Image *MontageImages(const Image *images, char tile_geometry[MaxTextExtent], - *title = 0; + *title = (char *) NULL; const ImageAttribute *attribute; @@ -418,6 +418,15 @@ MagickExport Image *MontageImages(const Image *images, /* flags= */ (void) GetGeometry(montage_info->tile,&x,&y,&tiles_per_row, &tiles_per_column); } + if ((0 == tiles_per_row) || (0 == tiles_per_column)) + { + for (tile=0; tile < number_images; tile++) + if (image_list[tile]) + DestroyImage(image_list[tile]); + MagickFreeMemory(master_list); + ThrowException(exception,OptionError,GeometryDimensionsAreZero,"tile"); + return((Image *) NULL); + } /* Determine tile sizes. */ @@ -764,7 +773,9 @@ MagickExport Image *MontageImages(const Image *images, break; } DestroyImage(image); +#if !defined(__COVERITY__) /* 384804 Unused value */ image=(Image *) NULL; +#endif /* if !defined(__COVERITY__) */ tiles++; } if ((i+1) < (long) images_per_page) diff --git a/magick/nt_base.c b/magick/nt_base.c index 3184b04..5557597 100644 --- a/magick/nt_base.c +++ b/magick/nt_base.c @@ -2794,4 +2794,62 @@ MagickExport long NTtelldir(DIR *entry) assert(entry != (DIR *) NULL); return(0); } + +/* +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% % +% % +% N T s n p r i n t f % +% % +% % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Method NTsnprintf emulates C'99 snprintf for MSVC older than Visual +% studio 2015 +% +% The format of the NTsnprintf method is: +% +% int NTsnprintf(char* str, size_t size, const char* format, ...) +% +% A description of each parameter follows: +% +% o str: buffer to write into +% +% o size: str buffer size +% +% o format: printf style format string +% +*/ +#if defined(_VISUALC_) && (_MSC_VER < 1900) +static int _NTvsnprintf(char* str, size_t size, const char* format, va_list ap) +{ + int count = -1; + + if (size != 0) +#if _MSC_VER <= 1310 + count = _vsnprintf(str, size, format, ap); +#else + count = _vsnprintf_s(str, size, _TRUNCATE, format, ap); +#endif + if (count == -1) + count = _vscprintf(format, ap); + + return count; +} +#define vsnprintf _NTvsnprintf +MagickExport int NTsnprintf(char* str, size_t size, const char* format, ...) +{ + int count; + va_list ap; + + va_start(ap, format); + count = vsnprintf(str, size, format, ap); + va_end(ap); + + return count; +} +#endif + #endif diff --git a/magick/nt_base.h b/magick/nt_base.h index 63840dc..9646959 100644 --- a/magick/nt_base.h +++ b/magick/nt_base.h @@ -193,6 +193,7 @@ extern "C" { 1900 Visual C++ 2015 1910 Visual C++ 2017 1920 Visual C++ 2019 + 1930 Visual C++ 2022 Should look at __CLR_VER ("Defines the version of the common language runtime used when the application was compiled.") as well. @@ -213,6 +214,19 @@ extern "C" { #endif /* + MSVC does not have snprintf (a C'99 feature) until Visual Studio 2015. + */ +#if defined(_VISUALC_) && (_MSC_VER < 1900) +#undef snprintf +extern MagickExport int NTsnprintf(char* str, size_t size, const char* format, ...); +#if _MSC_VER < 1400 +#define snprintf NTsnprintf +#else +#define snprintf(str,size,format,...) NTsnprintf(str,size,format,__VA_ARGS__) +#endif +#endif + +/* Windows provides Unix-style access() via _access() */ #define HAVE_ACCESS 1 @@ -312,6 +326,10 @@ typedef UINT (CALLBACK *LPFNDLLFUNC1)(DWORD,UINT); Note that under WIN64 read/write appear to still return 'int' and use 'unsigned int' rather than 'size_t' to specify the I/O size. This really sucks! + + The Windows <BaseTsd.h> header defines the type SSIZE_T which may be used to + typedef ssize_t but it is not known how it behaves. + */ #if !defined(ssize_t) && !defined(__MINGW32__) && !defined(__MINGW64__) # if defined(WIN64) diff --git a/magick/operator.c b/magick/operator.c index 5653741..34c88cc 100644 --- a/magick/operator.c +++ b/magick/operator.c @@ -1,5 +1,5 @@ /* -% Copyright (C) 2004 - 2018 GraphicsMagick Group +% Copyright (C) 2004 - 2022 GraphicsMagick Group % % This program is covered by multiple licenses, which are described in % Copyright.txt. You should have received a copy of Copyright.txt with this @@ -520,11 +520,13 @@ QuantumAssignCB(void *mutable_data, return (MagickPass); } +#if 0 #define ApplyChannelDepth(parameter) \ { \ for (i=0; i < npixels; i++) \ parameter=scale*((parameter)/scale); \ } +#endif #if MaxRGB > MaxMap # define CrushChannelDepth(parameter) (scale*((parameter)/scale)) #else @@ -548,7 +550,7 @@ QuantumDepthCB(void *mutable_data, unsigned int depth; - register unsigned int + unsigned int scale; register long @@ -585,16 +587,20 @@ QuantumDepthCB(void *mutable_data, if (mutable_context->channel_lut != (Quantum *) NULL) { - for (i=0; i <= (long) MaxMap; i++) - mutable_context->channel_lut[i] = scale*(i/scale); + unsigned int + li; + + for (li=0; li <= MaxMap; li++) + mutable_context->channel_lut[li] = scale*(li/scale); } } -#else - ARG_NOT_USED(*mutable_context); -#endif if (MagickFail == status) return status; +#else + ARG_NOT_USED(*mutable_context); + ARG_NOT_USED(status); +#endif switch (immutable_context->channel) { @@ -771,11 +777,13 @@ QuantumGammaCB(void *mutable_data, 1.0/immutable_context->double_value)); } } + + if (MagickFail == status) + return status; #else ARG_NOT_USED(*mutable_context); + ARG_NOT_USED(status); #endif - if (MagickFail == status) - return status; switch (immutable_context->channel) { @@ -951,12 +959,12 @@ QuantumLogCB(void *mutable_data, } } } + if (MagickFail == status) + return status; #else ARG_NOT_USED(*mutable_context); + ARG_NOT_USED(status); #endif - if (MagickFail == status) - return status; - switch (immutable_context->channel) { case RedChannel: @@ -1585,11 +1593,13 @@ QuantumPowCB(void *mutable_data, immutable_context->double_value)); } } + + if (MagickFail == status) + return status; #else ARG_NOT_USED(*mutable_context); + ARG_NOT_USED(status); #endif - if (MagickFail == status) - return status; switch (immutable_context->channel) { diff --git a/magick/pixel_cache.c b/magick/pixel_cache.c index bed4180..650a568 100644 --- a/magick/pixel_cache.c +++ b/magick/pixel_cache.c @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003 - 2021 GraphicsMagick Group +% Copyright (C) 2003 - 2022 GraphicsMagick Group % Copyright (C) 2002 ImageMagick Studio % % This program is covered by multiple licenses, which are described in @@ -177,9 +177,12 @@ typedef struct _CacheInfo /* The number of Image structures referencing this cache */ long reference_count; - /* True if cache is read only */ + /* MagickTrue if cache is read only */ MagickBool read_only; + /* MagickTrue if logging cache events */ + MagickBool logging; + /* Lock for updating reference count */ SemaphoreInfo *reference_semaphore; @@ -512,8 +515,7 @@ AllocateThreadViewSet(Image *image,ExceptionInfo *exception) MagickFatalError3(ResourceLimitFatalError,MemoryAllocationFailed, UnableToAllocateCacheView); view_set->nviews=nviews; - view_set->views=MagickAllocateMemory(ViewInfo *, - view_set->nviews*sizeof(ViewInfo *)); + view_set->views=MagickAllocateArray(ViewInfo *,view_set->nviews,sizeof(ViewInfo *)); if (view_set->views == (ViewInfo *) NULL) { ThrowException(exception,CacheError,UnableToAllocateCacheView, @@ -2525,7 +2527,7 @@ OpenCache(Image *image,const MapMode mode,ExceptionInfo *exception) if (cache_info->indexes_valid) cache_info->indexes=(IndexPacket *) (pixels+number_pixels); FormatSize(cache_info->length,format); - if (image->logging) + if (cache_info->logging) (void) LogMagickEvent(CacheEvent,GetMagickModule(), "open %.1024s (%.1024s) storage_class=%s," " colorspace=%s",cache_info->filename, @@ -2641,7 +2643,7 @@ OpenCache(Image *image,const MapMode mode,ExceptionInfo *exception) /* (void) signal(SIGBUS,CacheSignalHandler); */ #endif FormatSize(cache_info->length,format); - if (image->logging) + if (cache_info->logging) (void) LogMagickEvent(CacheEvent,GetMagickModule(), "open %.1024s (%.1024s[%d], %.1024s, %.1024s)" " storage_class=%s, colorspace=%s", @@ -3760,6 +3762,8 @@ GetCacheInfo(Cache *cache) limit=GetMagickResourceLimit(HeightResource); cache_info->limit_height=Min(LONG_MAX,limit); + cache_info->logging=IsEventLogged(CacheEvent); + cache_info->signature=MagickSignature; *cache=cache_info; } @@ -4581,7 +4585,9 @@ ModifyCache(Image *image, ExceptionInfo *exception) if (destroy_cache) { DestroyCacheInfo(cache_info); +#if !defined(__COVERITY__) /* 384801 Unused value */ cache_info=(CacheInfo *) NULL; +#endif /* if !defined(__COVERITY__) */ } if (status != MagickFail) diff --git a/magick/profile-private.h b/magick/profile-private.h new file mode 100644 index 0000000..740e728 --- /dev/null +++ b/magick/profile-private.h @@ -0,0 +1,13 @@ +/* + Copyright (C) 2004 - 2023 GraphicsMagick Group + + This program is covered by multiple licenses, which are described in + Copyright.txt. You should have received a copy of Copyright.txt with this + package; otherwise see http://www.graphicsmagick.org/www/Copyright.html. + + GraphicsMagick Private Methods For Manipulating Embedded Image Profiles. +*/ + +/* Header for JPEG APP1 EXIF profile */ +#define MAGICK_JPEG_APP1_EXIF_HEADER "Exif\0\0" +#define MAGICK_JPEG_APP1_EXIF_HEADER_SIZE (sizeof(MAGICK_JPEG_APP1_EXIF_HEADER)-1) diff --git a/magick/profile.c b/magick/profile.c index 5286298..1f80671 100644 --- a/magick/profile.c +++ b/magick/profile.c @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003-2021 GraphicsMagick Group +% Copyright (C) 2003-2023 GraphicsMagick Group % Copyright (C) 2002 ImageMagick Studio % Copyright 1991-1999 E. I. du Pont de Nemours and Company % @@ -272,8 +272,8 @@ DeleteImageProfile(Image *image,const char *name) % % o image: The image. % -% o name: Profile name. Valid names are "8BIM", "ICM", "IPTC", "XMP" or any -% unique text string. +% o name: Profile name. Valid names are "8BIM", "EXIF", "ICM", "IPTC", +% "XMP" or any unique text string. % % o length: Updated with profile length if profile is present. Set to NULL % if length is not needed. @@ -551,7 +551,7 @@ ProfileImagePixels(void *mutable_data, /* User provided mutable data */ pixels[i].green=ScaleShortToQuantum(beta.green); pixels[i].blue=ScaleShortToQuantum(beta.blue); } - if (image->matte) + if ((image->matte) && (NULL != indexes)) { if ((source_colorspace == CMYKColorspace) && (target_colorspace != CMYKColorspace)) @@ -1202,8 +1202,8 @@ ProfileImage(Image *image,const char *name,unsigned char *profile, % % o image: The image. % -% o name: Profile name. Valid names are "8BIM", "ICM", "IPTC", XMP, or any -% unique text string. +% o name: Profile name. Valid names are "8BIM", EXIF, "ICM", "IPTC", +% XMP, or any unique text string. % % o profile: Address of profile to add. Pass zero to remove an existing % profile. diff --git a/magick/profile.h b/magick/profile.h index 7db18f9..3c34748 100644 --- a/magick/profile.h +++ b/magick/profile.h @@ -75,6 +75,12 @@ extern MagickExport MagickPassFail extern MagickExport void DeallocateImageProfileIterator(ImageProfileIterator profile_iterator); +#if defined(MAGICK_IMPLEMENTATION) + +# include "magick/profile-private.h" + +#endif /* defined(MAGICK_IMPLEMENTATION) */ + #if defined(__cplusplus) || defined(c_plusplus) } #endif /* defined(__cplusplus) || defined(c_plusplus) */ diff --git a/magick/render.c b/magick/render.c index 7900955..42043cb 100644 --- a/magick/render.c +++ b/magick/render.c @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003-2020 GraphicsMagick Group +% Copyright (C) 2003-2022 GraphicsMagick Group % Copyright (C) 2002 ImageMagick Studio % Copyright 1991-1999 E. I. du Pont de Nemours and Company % @@ -687,7 +687,9 @@ ConvertPathToPolygon(const PathInfo *path_info, ExceptionInfo *exception) polygon_info->edges[edge].bounds.y1=points[0].y; polygon_info->edges[edge].bounds.y2=points[n-1].y; points=(PointInfo *) NULL; +#if !defined(__COVERITY__) /* 384800 Unused value */ ghostline=MagickFalse; +#endif /* if !defined(__COVERITY__) */ edge++; polygon_info->number_edges=edge; } @@ -846,7 +848,7 @@ ConvertPathToPolygon(const PathInfo *path_info, ExceptionInfo *exception) polygon_info->number_edges=edge; qsort(polygon_info->edges,polygon_info->number_edges,sizeof(EdgeInfo), CompareEdges); - if (IsEventLogging()) + if (IsEventLogged(RenderEvent)) LogPolygonInfo(polygon_info); return(polygon_info); } @@ -1024,7 +1026,7 @@ ConvertPrimitiveToPath(const DrawInfo *draw_info, path_info[n].code=EndCode; path_info[n].point.x=0.0; path_info[n].point.y=0.0; - if (IsEventLogging()) + if (IsEventLogged(RenderEvent)) LogPathInfo(path_info); return(path_info); } @@ -5907,7 +5909,7 @@ DrawPrimitive(Image *image,const DrawInfo *draw_info, dvalue=ceil(primitive_info->point.x-0.5); if (MAGICK_ISNAN(dvalue) || ((dvalue < DTOLONG_MIN)) || (dvalue > DTOLONG_MAX)) { - char double_str[18]; + char double_str[MaxTextExtent]; FormatString(double_str,"%g",dvalue); ThrowException(&image->exception,DrawError,PrimitiveArithmeticOverflow,double_str); return MagickFail; @@ -5916,7 +5918,7 @@ DrawPrimitive(Image *image,const DrawInfo *draw_info, dvalue=ceil(primitive_info->point.y-0.5); if (MAGICK_ISNAN(dvalue) || ((dvalue < DTOLONG_MIN)) || (dvalue > DTOLONG_MAX)) { - char double_str[18]; + char double_str[MaxTextExtent]; FormatString(double_str,"%g",dvalue); ThrowException(&image->exception,DrawError,PrimitiveArithmeticOverflow,double_str); return MagickFail; @@ -6183,7 +6185,15 @@ DrawPrimitive(Image *image,const DrawInfo *draw_info, status=MagickFail; break; } - if ((primitive_info[1].point.x != composite_image->columns) && + /* + If the requested size is not 0x0 (to be filled in later with + composite image size) and the requested size is different than + the composite image size, then transform to the requested + size. + */ + if ((0 != primitive_info[1].point.x) && + (0 != primitive_info[1].point.y) && + (primitive_info[1].point.x != composite_image->columns) && (primitive_info[1].point.y != composite_image->rows)) { char @@ -6224,7 +6234,7 @@ DrawPrimitive(Image *image,const DrawInfo *draw_info, DrawInfo *clone_info; - if (IsEventLogging()) + if (IsEventLogged(RenderEvent)) LogPrimitiveInfo(primitive_info); scale=ExpandAffine(&draw_info->affine); if ((draw_info->dash_pattern != (double *) NULL) && diff --git a/magick/resize.c b/magick/resize.c index 57f1de2..66c2a84 100644 --- a/magick/resize.c +++ b/magick/resize.c @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003 - 2019 GraphicsMagick Group +% Copyright (C) 2003 - 2022 GraphicsMagick Group % Copyright (C) 2002 ImageMagick Studio % % This program is covered by multiple licenses, which are described in @@ -849,10 +849,13 @@ HorizontalFilter(const Image * restrict source,Image * restrict destination, MagickBool monitor_active; + const MagickBool + matte = ((destination->matte) || (destination->colorspace == CMYKColorspace)); + MagickPassFail status=MagickPass; - if (IsEventLogging()) + if (IsEventLogged(TransformEvent)) (void) LogMagickEvent(TransformEvent,GetMagickModule(), "Horizontal Filter: %lux%lu => %lux%lu " "(x_factor %g, blur %g, span %"MAGICK_SIZE_T_F"u) ...", @@ -966,27 +969,25 @@ HorizontalFilter(const Image * restrict source,Image * restrict destination, { source_indexes=AccessImmutableIndexes(source); indexes=AccessMutableIndexes(destination); - for (y=0; y < (long) destination->rows; y++) + if (matte) { - double - weight; - - DoublePixelPacket - pixel; - - long - j; - - register long - i; - - pixel=zero; - if ((destination->matte) || (destination->colorspace == CMYKColorspace)) + for (y=0; y < (long) destination->rows; y++) { double transparency_coeff, - normalize; + normalize, + weight; + + DoublePixelPacket + pixel; + + long + j; + register long + i; + + pixel=zero; normalize=0.0; for (i=0; i < n; i++) { @@ -1008,9 +1009,33 @@ HorizontalFilter(const Image * restrict source,Image * restrict destination, q[y].green=RoundDoubleToQuantum(pixel.green); q[y].blue=RoundDoubleToQuantum(pixel.blue); q[y].opacity=RoundDoubleToQuantum(pixel.opacity); + + if ((indexes != (IndexPacket *) NULL) && + (source_indexes != (IndexPacket *) NULL)) + { + i=Min(Max((long) (center+0.5),start),stop-1); + j=y*(contribution[n-1].pixel-contribution[0].pixel+1)+ + (contribution[i-start].pixel-contribution[0].pixel); + indexes[y]=source_indexes[j]; + } } - else + } + else + { + for (y=0; y < (long) destination->rows; y++) { + double + weight; + + DoublePixelPacket + pixel=zero; + + long + j; + + register long + i; + for (i=0; i < n; i++) { j=(long) (y*(contribution[n-1].pixel-contribution[0].pixel+1)+ @@ -1024,15 +1049,15 @@ HorizontalFilter(const Image * restrict source,Image * restrict destination, q[y].green=RoundDoubleToQuantum(pixel.green); q[y].blue=RoundDoubleToQuantum(pixel.blue); q[y].opacity=OpaqueOpacity; - } - if ((indexes != (IndexPacket *) NULL) && - (source_indexes != (IndexPacket *) NULL)) - { - i=Min(Max((long) (center+0.5),start),stop-1); - j=y*(contribution[n-1].pixel-contribution[0].pixel+1)+ - (contribution[i-start].pixel-contribution[0].pixel); - indexes[y]=source_indexes[j]; + if ((indexes != (IndexPacket *) NULL) && + (source_indexes != (IndexPacket *) NULL)) + { + i=Min(Max((long) (center+0.5),start),stop-1); + j=y*(contribution[n-1].pixel-contribution[0].pixel+1)+ + (contribution[i-start].pixel-contribution[0].pixel); + indexes[y]=source_indexes[j]; + } } } if (!SyncImagePixelsEx(destination,exception)) @@ -1068,7 +1093,7 @@ HorizontalFilter(const Image * restrict source,Image * restrict destination, } } - if (IsEventLogging()) + if (IsEventLogged(TransformEvent)) (void) LogMagickEvent(TransformEvent,GetMagickModule(), "%s exit Horizontal Filter", (status == MagickFail ? "Error" : "Normal")); @@ -1101,10 +1126,13 @@ VerticalFilter(const Image * restrict source,Image * restrict destination, MagickBool monitor_active; + const MagickBool + matte = ((destination->matte) || (destination->colorspace == CMYKColorspace)); + MagickPassFail status=MagickPass; - if (IsEventLogging()) + if (IsEventLogged(TransformEvent)) (void) LogMagickEvent(TransformEvent,GetMagickModule(), "Vertical Filter: %lux%lu => %lux%lu " "(y_factor %g, blur %g, span %"MAGICK_SIZE_T_F"u) ...", @@ -1220,26 +1248,23 @@ VerticalFilter(const Image * restrict source,Image * restrict destination, { source_indexes=AccessImmutableIndexes(source); indexes=AccessMutableIndexes(destination); - for (x=0; x < (long) destination->columns; x++) + if (matte) { - double - weight; - - DoublePixelPacket - pixel; - - long - j; - - register long - i; - - pixel=zero; - if ((source->matte) || (source->colorspace == CMYKColorspace)) + for (x=0; x < (long) destination->columns; x++) { double transparency_coeff, - normalize; + normalize, + weight; + + DoublePixelPacket + pixel=zero; + + long + j; + + register long + i; normalize=0.0; for (i=0; i < n; i++) @@ -1263,9 +1288,34 @@ VerticalFilter(const Image * restrict source,Image * restrict destination, q[x].green=RoundDoubleToQuantum(pixel.green); q[x].blue=RoundDoubleToQuantum(pixel.blue); q[x].opacity=RoundDoubleToQuantum(pixel.opacity); + + if ((indexes != (IndexPacket *) NULL) && + (source_indexes != (IndexPacket *) NULL)) + { + i=Min(Max((long) (center+0.5),start),stop-1); + j=(long) ((contribution[i-start].pixel-contribution[0].pixel)* + source->columns+x); + indexes[x]=source_indexes[j]; + } } - else + } + else + { + for (x=0; x < (long) destination->columns; x++) { + double + weight; + + DoublePixelPacket + pixel; + + long + j; + + register long + i; + + pixel=zero; for (i=0; i < n; i++) { j=(long) ((contribution[i].pixel-contribution[0].pixel)* @@ -1279,15 +1329,15 @@ VerticalFilter(const Image * restrict source,Image * restrict destination, q[x].green=RoundDoubleToQuantum(pixel.green); q[x].blue=RoundDoubleToQuantum(pixel.blue); q[x].opacity=OpaqueOpacity; - } - if ((indexes != (IndexPacket *) NULL) && - (source_indexes != (IndexPacket *) NULL)) - { - i=Min(Max((long) (center+0.5),start),stop-1); - j=(long) ((contribution[i-start].pixel-contribution[0].pixel)* - source->columns+x); - indexes[x]=source_indexes[j]; + if ((indexes != (IndexPacket *) NULL) && + (source_indexes != (IndexPacket *) NULL)) + { + i=Min(Max((long) (center+0.5),start),stop-1); + j=(long) ((contribution[i-start].pixel-contribution[0].pixel)* + source->columns+x); + indexes[x]=source_indexes[j]; + } } } if (!SyncImagePixelsEx(destination,exception)) @@ -1324,7 +1374,7 @@ VerticalFilter(const Image * restrict source,Image * restrict destination, } } - if (IsEventLogging()) + if (IsEventLogged(TransformEvent)) (void) LogMagickEvent(TransformEvent,GetMagickModule(), "%s exit Vertical Filter", (status == MagickFail ? "Error" : "Normal")); @@ -1435,7 +1485,7 @@ MagickExport Image *ResizeImage(const Image *image,const unsigned long columns, ((x_factor*y_factor) > 1.0)) i=(long) MitchellFilter; - if (IsEventLogging()) + if (IsEventLogged(TransformEvent)) (void) LogMagickEvent(TransformEvent,GetMagickModule(), "Resizing image of size %lux%lu to %lux%lu using %s filter", image->columns,image->rows,columns,rows, @@ -1464,7 +1514,7 @@ MagickExport Image *ResizeImage(const Image *image,const unsigned long columns, */ status=MagickPass; quantum=0; - if (IsEventLogging()) + if (IsEventLogged(TransformEvent)) (void) LogMagickEvent(TransformEvent,GetMagickModule(), "Resize filter order: %s", order ? "Horizontal/Vertical" : "Vertical/Horizontal"); @@ -1805,6 +1855,7 @@ MagickExport Image *ScaleImage(const Image *image,const unsigned long columns, MagickFreeMemory(scale_scanline); MagickFreeMemory(x_vector); MagickFreeMemory(y_vector); + MagickFreeMemory(y_volumes); DestroyImage(scale_image); ThrowImageException3(ResourceLimitError,MemoryAllocationFailed, UnableToScaleImage); diff --git a/magick/resource.c b/magick/resource.c index 2e4a453..c9fc6f7 100644 --- a/magick/resource.c +++ b/magick/resource.c @@ -203,7 +203,7 @@ AcquireMagickResource(const ResourceType type, break; } } - if (IsEventLogging()) + if (IsEventLogged(ResourceEvent)) { char f_limit[MaxTextExtent], @@ -785,7 +785,7 @@ MagickExport void LiberateMagickResource(const ResourceType type, } } - if (IsEventLogging()) + if (IsEventLogged(ResourceEvent)) { char f_limit[MaxTextExtent], diff --git a/magick/segment.c b/magick/segment.c index 09c94d5..8356ac6 100644 --- a/magick/segment.c +++ b/magick/segment.c @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003 - 2019 GraphicsMagick Group +% Copyright (C) 2003 - 2022 GraphicsMagick Group % Copyright (C) 2002 ImageMagick Studio % Copyright 1991-1999 E. I. du Pont de Nemours and Company % @@ -503,7 +503,7 @@ Classify(Image * restrict image,short **extrema, else last_cluster->next=next_cluster; - if (image->logging) + if (IsEventLogged(TransformEvent)) (void) LogMagickEvent (TransformEvent,GetMagickModule(), "Removing Cluster (usage count %lu, %.5f%%) %d-%d %d-%d %d-%d", diff --git a/magick/static.c b/magick/static.c index ba2da66..7881a26 100644 --- a/magick/static.c +++ b/magick/static.c @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003-2019 GraphicsMagick Group +% Copyright (C) 2003-2023 GraphicsMagick Group % Copyright (C) 2002 ImageMagick Studio % % This program is covered by multiple licenses, which are described in @@ -194,7 +194,9 @@ static const struct STATICM("XCF",RegisterXCFImage,UnregisterXCFImage), STATICM("XPM",RegisterXPMImage,UnregisterXPMImage), #if defined(_VISUALC_) +#if defined(EnableXTRNCoder) STATICM("XTRN",RegisterXTRNImage,UnregisterXTRNImage), +#endif /* if defined(EnableXTRNCoder) */ #endif /* defined(_VISUALC_) */ #if defined(HasX11) STATICM("XWD",RegisterXWDImage,UnregisterXWDImage), diff --git a/magick/studio.h b/magick/studio.h index 66c43e8..84ad5b5 100644 --- a/magick/studio.h +++ b/magick/studio.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2003 - 2020 GraphicsMagick Group + Copyright (C) 2003 - 2022 GraphicsMagick Group Copyright (C) 2002 ImageMagick Studio This program is covered by multiple licenses, which are described in @@ -535,14 +535,9 @@ extern int vsnprintf(char *s, size_t n, const char *format, va_list ap); /* Common const definitions */ -#define BackgroundColor "#ffffffffffff" /* white */ -#define BorderColor "#dfdfdfdfdfdf" /* gray */ #define DefaultTileFrame "15x15+3+3" #define DefaultTileGeometry "120x120+4+3>" #define DefaultTileLabel "%f\n%wx%h\n%b" -#define ForegroundColor "#000000000000" /* black */ -#define HighlightColor "#f1f100001e1e" /* light red */ -#define MatteColor "#bdbdbdbdbdbd" /* gray */ #define PSDensityGeometry "72.0x72.0" #define PSPageGeometry "612x792>" @@ -553,6 +548,17 @@ extern int vsnprintf(char *s, size_t n, const char *format, va_list ap); #define DefaultCompressionQuality 75U +#if 0 /* Enable deprecation warnings */ +extern char *strcpy (char *restrict dest, const char *restrict src) + MAGICK_FUNC_DEPRECATED; + +extern char *strcat (char *restrict dest, const char *restrict src) + MAGICK_FUNC_DEPRECATED; + +extern int sprintf (char *restrict s, + const char *restrict format, ...) + MAGICK_FUNC_DEPRECATED; +#endif #if defined(__cplusplus) || defined(c_plusplus) } diff --git a/magick/symbols.h b/magick/symbols.h index a1e464d..32feb12 100644 --- a/magick/symbols.h +++ b/magick/symbols.h @@ -489,6 +489,7 @@ #define IsAccessibleAndNotEmpty GmIsAccessibleAndNotEmpty #define IsAccessible GmIsAccessible #define IsAccessibleNoLogging GmIsAccessibleNoLogging +#define IsEventLogged GmIsEventLogged #define IsEventLogging GmIsEventLogging #define IsGeometry GmIsGeometry #define IsGlob GmIsGlob diff --git a/magick/tempfile.h b/magick/tempfile.h index 2a8c61a..52c5c10 100644 --- a/magick/tempfile.h +++ b/magick/tempfile.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2003-2020 GraphicsMagick Group + Copyright (C) 2003-2022 GraphicsMagick Group This program is covered by multiple licenses, which are described in Copyright.txt. You should have received a copy of Copyright.txt with this @@ -29,7 +29,7 @@ MagickExport int AcquireTemporaryFileDescriptor(char *filename); MagickExport FILE * - AcquireTemporaryFileStream(char *filename,FileIOMode mode); + AcquireTemporaryFileStream(char *filename,FileIOMode mode) MAGICK_FUNC_MALLOC_2ARG(fclose, 1); #if defined(MAGICK_IMPLEMENTATION) # include "magick/tempfile-private.h" diff --git a/magick/transform.c b/magick/transform.c index 26fa921..88d3f58 100644 --- a/magick/transform.c +++ b/magick/transform.c @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003 - 2021 GraphicsMagick Group +% Copyright (C) 2003 - 2022 GraphicsMagick Group % Copyright (C) 2002 ImageMagick Studio % Copyright 1991-1999 E. I. du Pont de Nemours and Company % @@ -130,6 +130,10 @@ MagickExport Image *ChopImage(const Image *image,const RectangleInfo *chop_info, clone_info.height-=(unsigned long) (-clone_info.y); clone_info.y=0; } + if ((clone_info.width >= image->columns) || + (clone_info.height >= image->rows)) + ThrowImageException3(OptionError,GeometryDoesNotContainImage, + UnableToChopImage); /* Initialize chop image attributes. */ @@ -497,6 +501,9 @@ MagickExport Image *CropImage(const Image *image,const RectangleInfo *geometry, MagickPassFail status=MagickPass; + MagickBool + transform_logging; + /* Check crop geometry. */ @@ -505,7 +512,8 @@ MagickExport Image *CropImage(const Image *image,const RectangleInfo *geometry, assert(geometry != (const RectangleInfo *) NULL); assert(exception != (ExceptionInfo *) NULL); assert(exception->signature == MagickSignature); - if (image->logging) + transform_logging=IsEventLogged(TransformEvent); + if (transform_logging) (void) LogMagickEvent(TransformEvent,GetMagickModule(), "Crop Geometry: %lux%lu%+ld%+ld", geometry->width, geometry->height, @@ -551,7 +559,7 @@ MagickExport Image *CropImage(const Image *image,const RectangleInfo *geometry, page.y-=geometry->y; if (page.y < 0) page.y=0; - if (image->logging) + if (transform_logging) (void) LogMagickEvent(TransformEvent,GetMagickModule(), "Bounding Page: %lux%lu%+ld%+ld", page.width, page.height, page.x, page.y); @@ -1674,8 +1682,13 @@ MagickExport MagickPassFail TransformImage(Image **image,const char *crop_geomet MagickPassFail status = MagickPass; + MagickBool + transform_logging; + assert(image != (Image **) NULL); assert((*image)->signature == MagickSignature); + + transform_logging=IsEventLogged(TransformEvent); transform_image=(*image); if (crop_geometry != (const char *) NULL) { @@ -1687,7 +1700,7 @@ MagickExport MagickPassFail TransformImage(Image **image,const char *crop_geomet */ crop_image=(Image *) NULL; flags=GetImageGeometry(transform_image,crop_geometry,False,&geometry); - if (transform_image->logging) + if (transform_logging) (void) LogMagickEvent(TransformEvent,GetMagickModule(), "Crop Geometry: %lux%lu%+ld%+ld", geometry.width, geometry.height, @@ -1770,7 +1783,7 @@ MagickExport MagickPassFail TransformImage(Image **image,const char *crop_geomet SetGeometry(transform_image,&geometry); flags=GetMagickGeometry(image_geometry,&geometry.x,&geometry.y, &geometry.width,&geometry.height); - if (transform_image->logging) + if (transform_logging) (void) LogMagickEvent(TransformEvent,GetMagickModule(), "Transform Geometry: %lux%lu%+ld%+ld", geometry.width, geometry.height, diff --git a/magick/utility-private.h b/magick/utility-private.h index 66ee934..17a170b 100644 --- a/magick/utility-private.h +++ b/magick/utility-private.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2003 - 2020 GraphicsMagick Group + Copyright (C) 2003 - 2023 GraphicsMagick Group Copyright (C) 2002 ImageMagick Studio Copyright 1991-1999 E. I. du Pont de Nemours and Company @@ -31,7 +31,12 @@ extern MagickExport MagickPassFail MagickAtoIChk(const char *str, int *value); extern MagickExport MagickPassFail MagickAtoUIChk(const char *str, unsigned int *value); extern MagickExport MagickPassFail MagickAtoLChk(const char *str, long *value); extern MagickExport MagickPassFail MagickAtoULChk(const char *str, unsigned long *value); +extern MagickExport unsigned long MagickDoubleToULong(const double dval/*, ExceptionInfo *exception*/) MAGICK_FUNC_CONST; +extern MagickExport unsigned int MagickDoubleToUInt(const double dval/*, ExceptionInfo *exception*/) MAGICK_FUNC_CONST; extern MagickExport long MagickDoubleToLong(const double dval/*, ExceptionInfo *exception*/) MAGICK_FUNC_CONST; +extern MagickExport int MagickDoubleToInt(const double dval/*, ExceptionInfo *exception*/) MAGICK_FUNC_CONST; +extern MagickExport unsigned short int MagickDoubleToUShort(const double dval/*, ExceptionInfo *exception*/) MAGICK_FUNC_CONST; +extern MagickExport short int MagickDoubleToShort(const double dval/*, ExceptionInfo *exception*/) MAGICK_FUNC_CONST; extern MagickExport size_t MagickStripSpacesFromString(char *string), diff --git a/magick/utility.c b/magick/utility.c index 3a64b4e..179fe16 100644 --- a/magick/utility.c +++ b/magick/utility.c @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003-2021 GraphicsMagick Group +% Copyright (C) 2003-2023 GraphicsMagick Group % Copyright (c) 2000 Markus Friedl. All rights reserved. % Copyright (C) 2002 ImageMagick Studio % Copyright 1991-1999 E. I. du Pont de Nemours and Company @@ -831,11 +831,14 @@ MagickExport void ExpandFilename(char *filename) struct passwd pwd; + long + pwnam_buf_len_s; + size_t pwnam_buf_len; char - *pwnam_buf; + *pwnam_buf = (char *) NULL; # endif /* if defined(HAVE_GETPWNAM_R) */ struct passwd @@ -851,7 +854,11 @@ MagickExport void ExpandFilename(char *filename) # if defined(HAVE_GETPWNAM_R) entry=(struct passwd *) NULL; - pwnam_buf_len = sysconf(_SC_GETPW_R_SIZE_MAX); + errno = 0; + pwnam_buf_len_s = sysconf(_SC_GETPW_R_SIZE_MAX); + if (pwnam_buf_len_s <= 0) + return; + pwnam_buf_len = (size_t) pwnam_buf_len_s; pwnam_buf=MagickAllocateMemory(char *,pwnam_buf_len); if (pwnam_buf != (char *) NULL) (void) getpwnam_r(username,&pwd,pwnam_buf,pwnam_buf_len,&entry); @@ -863,8 +870,8 @@ MagickExport void ExpandFilename(char *filename) (void) strncpy(expanded_filename,entry->pw_dir,MaxTextExtent-1); if (p != (char *) NULL) { - (void) strcat(expanded_filename,"/"); - (void) strlcat(expanded_filename,p+1,MaxTextExtent); + (void) strlcat(expanded_filename,"/",sizeof(expanded_filename)); + (void) strlcat(expanded_filename,p+1,sizeof(expanded_filename)); } } # if defined(HAVE_GETPWNAM_R) @@ -1216,12 +1223,12 @@ MagickExport void FormatSize(const magick_int64_t size,char *format) { default: break; case 0: break; - case 1: (void) strcat(format,"Ki"); break; /* kilo, 10^3 */ - case 2: (void) strcat(format,"Mi"); break; /* mega, 10^6 */ - case 3: (void) strcat(format,"Gi"); break; /* giga, 10^9 */ - case 4: (void) strcat(format,"Ti"); break; /* tera, 10^12 */ - case 5: (void) strcat(format,"Pi"); break; /* peta, 10^15 */ - case 6: (void) strcat(format,"Ei"); break; /* exa, 10^18 */ + case 1: (void) strlcat(format,"Ki",MaxTextExtent); break; /* kilo, 10^3 */ + case 2: (void) strlcat(format,"Mi",MaxTextExtent); break; /* mega, 10^6 */ + case 3: (void) strlcat(format,"Gi",MaxTextExtent); break; /* giga, 10^9 */ + case 4: (void) strlcat(format,"Ti",MaxTextExtent); break; /* tera, 10^12 */ + case 5: (void) strlcat(format,"Pi",MaxTextExtent); break; /* peta, 10^15 */ + case 6: (void) strlcat(format,"Ei",MaxTextExtent); break; /* exa, 10^18 */ } } @@ -1589,7 +1596,10 @@ MagickExport MagickPassFail GetExecutionPathUsingName(char *path) % A description of each parameter follows: % % o flags: Method GetGeometry returns a bitmask that indicates -% which of the four values were located in the geometry string. +% which of the values from GeometryFlags (XValue, YValue, WidthValue, +% HeightValue, XNegative, YNegative, PercentValue, AspectValue, LessValue, +% GreaterValue, AreaValue, MinimumValue) were located in the geometry +% string. % % o image_geometry: Specifies a character string representing the geometry % specification. @@ -1602,6 +1612,8 @@ MagickExport MagickPassFail GetExecutionPathUsingName(char *path) % % */ +#define MagickULongRangeOk(double_val) ((double_val <= (double) ULONG_MAX) && (double_val >= 0.0)) +#define MagickLongRangeOk(double_val) ((double_val <= (double) LONG_MAX) && (double_val >= (double) LONG_MIN)) MagickExport int GetGeometry(const char *image_geometry,long *x,long *y, unsigned long *width,unsigned long *height) { @@ -1740,8 +1752,12 @@ MagickExport int GetGeometry(const char *image_geometry,long *x,long *y, count=MagickStrToD(p,&q,&double_val); if (count) { - bounds.width=(unsigned long) floor(double_val+0.5); - flags|=WidthValue; + double_val=floor(double_val+0.5); + if (MagickULongRangeOk(double_val)) + { + bounds.width=(unsigned long) double_val; + flags|=WidthValue; + } } if ((*q == 'x') || (*q == 'X') || ((flags & AreaValue) && (*q == '\0'))) p=q; @@ -1750,9 +1766,13 @@ MagickExport int GetGeometry(const char *image_geometry,long *x,long *y, count=MagickStrToD(p,&p,&double_val); if (count) { - bounds.width=(unsigned long) floor(double_val+0.5); - bounds.height=bounds.width; - flags|=HeightValue; + double_val=floor(double_val+0.5); + if (MagickULongRangeOk(double_val)) + { + bounds.width=(unsigned long) double_val; + bounds.height=bounds.width; + flags|=HeightValue; + } } } } @@ -1766,8 +1786,12 @@ MagickExport int GetGeometry(const char *image_geometry,long *x,long *y, count=MagickStrToD(p,&p,&double_val); if (count) { - bounds.height=(unsigned long) floor(double_val+0.5); - flags|=HeightValue; + double_val=floor(double_val+0.5); + if (MagickULongRangeOk(double_val)) + { + bounds.height=(unsigned long) double_val; + flags|=HeightValue; + } } } if ((*p == '+') || (*p == '-')) @@ -1780,7 +1804,15 @@ MagickExport int GetGeometry(const char *image_geometry,long *x,long *y, p++; q=p; count=MagickStrToD(p,&p,&double_val); - bounds.x=(long) ceil(double_val-0.5); + if (count) + { + double_val=ceil(double_val-0.5); + if (MagickLongRangeOk(double_val)) + { + bounds.x=(long) double_val; + flags|=XValue; + } + } } else { @@ -1789,12 +1821,15 @@ MagickExport int GetGeometry(const char *image_geometry,long *x,long *y, count=MagickStrToD(p,&p,&double_val); if (count) { - bounds.x=(long) ceil(-double_val-0.5); - flags|=XNegative; + double_val=ceil(-double_val-0.5); + if (MagickLongRangeOk(double_val)) + { + bounds.x=(long) double_val; + flags|=XValue; + flags|=XNegative; + } } } - if (count) - flags|=XValue; if ((*p == '+') || (*p == '-')) { /* @@ -1805,7 +1840,15 @@ MagickExport int GetGeometry(const char *image_geometry,long *x,long *y, p++; q=p; count=MagickStrToD(p,&p,&double_val); - bounds.y=(long) ceil(double_val-0.5); + if (count) + { + double_val = ceil(double_val-0.5); + if (MagickLongRangeOk(double_val)) + { + bounds.y=(long) double_val; + flags|=YValue; + } + } } else { @@ -1814,12 +1857,15 @@ MagickExport int GetGeometry(const char *image_geometry,long *x,long *y, count=MagickStrToD(p,&p,&double_val); if (count) { - bounds.y=(long) ceil(-double_val-0.5); - flags|=YNegative; + double_val=ceil(-double_val-0.5); + if (MagickLongRangeOk(double_val)) + { + bounds.y=(long) ceil(double_val); + flags|=YValue; + flags|=YNegative; + } } } - if (count) - flags|=YValue; } } if (*p != '\0') @@ -1876,7 +1922,7 @@ static int MagickStrToD(const char *start,char **end,double *value) char buff[MaxTextExtent], - *endptr; + *estr; int i, @@ -1888,10 +1934,32 @@ static int MagickStrToD(const char *start,char **end,double *value) buff[i]=*p++; buff[i]=0; errno=0; - *value=strtod(buff,&endptr); - if ((errno == 0) && (buff != endptr)) - n++; - *end=(char *) start+(endptr-buff); + *value=strtod(buff,&estr); + if (buff == estr) + { + *value=0.0; + } +#if defined(INFINITY) + else if ((*value == +INFINITY) || (*value == -INFINITY)) + { + *value=0.0; + errno=ERANGE; + } +#endif + else if (isnan(*value)) + { + *value=0.0; + errno=ERANGE; + } + /* + Warning: Visual Studio 2008 64-bit returns errno 34 "Result too + large", even though a correct value is returned! + */ + else if (errno == 0) + { + n++; + } + *end=(char *) start+(estr-buff); return (n); } @@ -2184,6 +2252,10 @@ MagickExport int GetMagickGeometry(const char *geometry,long *x,long *y, } *width=(unsigned long) floor(scale_factor*former_width+0.5); *height=(unsigned long) floor(scale_factor*former_height+0.5); + + /* Width and height can not be zero! */ + *width=Max(*width,1); + *height=Max(*height,1); } if (flags & GreaterValue) /* > */ { @@ -2343,7 +2415,7 @@ MagickExport char *GetPageGeometry(const char *page_geometry) flags=GetGeometry(page,&geometry.x,&geometry.y,&geometry.width, &geometry.height); if (!(flags & GreaterValue)) - (void) strcat(page,">"); + (void) strlcat(page,">",sizeof(page)); break; } return (AcquireString(page)); @@ -3671,6 +3743,221 @@ MagickExport long MagickDoubleToLong(const double dval/*, ExceptionInfo *excepti } /* + Convert a double to an int, with clipping. + Someday a warning or an error may be produced here. +*/ +MagickExport int MagickDoubleToInt(const double dval/*, ExceptionInfo *exception*/) +{ + int lval; + + do + { +#if defined(INFINITY) + if (dval == +INFINITY) + { + lval=INT_MAX; + break; + } + if (dval == -INFINITY) + { + lval=INT_MIN; + break; + } +#endif + if (isnan(dval)) + { + lval=0; + break; + } + if (floor(dval) > ((double) INT_MAX - 1)) + { + lval=INT_MAX; + break; + } + if (ceil(dval) < ((double) INT_MIN + 1)) + { + lval=INT_MIN; + break; + } + lval=(int) dval; + } while (0); + + return lval; +} + +/* + Convert a double to an unsigned long, with clipping. + Someday a warning or an error may be produced here. +*/ +MagickExport unsigned long MagickDoubleToULong(const double dval/*, ExceptionInfo *exception*/) +{ + unsigned long lval; + + do + { +#if defined(INFINITY) + if (dval == +INFINITY) + { + lval=ULONG_MAX; + break; + } + if (dval == -INFINITY) + { + lval=0; + break; + } +#endif + if (isnan(dval)) + { + lval=0; + break; + } + if (floor(dval) > ((double) ULONG_MAX - 1)) + { + lval=ULONG_MAX; + break; + } + if (ceil(dval) < 0.0) + { + lval=0; + break; + } + lval=(unsigned long) dval; + } while (0); + + return lval; +} + +/* + Convert a double to an unsigned int, with clipping. + Someday a warning or an error may be produced here. +*/ +MagickExport unsigned int MagickDoubleToUInt(const double dval/*, ExceptionInfo *exception*/) +{ + unsigned int lval; + + do + { +#if defined(INFINITY) + if (dval == +INFINITY) + { + lval=UINT_MAX; + break; + } + if (dval == -INFINITY) + { + lval=0; + break; + } +#endif + if (isnan(dval)) + { + lval=0; + break; + } + if (floor(dval) > ((double) UINT_MAX - 1)) + { + lval=UINT_MAX; + break; + } + if (ceil(dval) < 0.0) + { + lval=0; + break; + } + lval=(unsigned int) dval; + } while (0); + + return lval; +} + +/* + Convert a double to a short, with clipping. + Someday a warning or an error may be produced here. +*/ +MagickExport short int MagickDoubleToShort(const double dval/*, ExceptionInfo *exception*/) +{ + short int lval; + + do + { +#if defined(INFINITY) + if (dval == +INFINITY) + { + lval=SHRT_MAX; + break; + } + if (dval == -INFINITY) + { + lval=SHRT_MIN; + break; + } +#endif + if (isnan(dval)) + { + lval=0; + break; + } + if (floor(dval) > ((double) SHRT_MAX - 1)) + { + lval=SHRT_MAX; + break; + } + if (ceil(dval) < ((double) SHRT_MIN + 1)) + { + lval=SHRT_MIN; + break; + } + lval=(short int) dval; + } while (0); + + return lval; +} + +/* + Convert a double to an unsigned short, with clipping. + Someday a warning or an error may be produced here. +*/ +MagickExport unsigned short int MagickDoubleToUShort(const double dval/*, ExceptionInfo *exception*/) +{ + unsigned short int lval; + + do + { +#if defined(INFINITY) + if (dval == +INFINITY) + { + lval=USHRT_MAX; + break; + } + if (dval == -INFINITY) + { + lval=0; + break; + } +#endif + if (isnan(dval)) + { + lval=0; + break; + } + if (floor(dval) > ((double) USHRT_MAX - 1)) + { + lval=USHRT_MAX; + break; + } + if (ceil(dval) < 0.0) + { + lval=0; + break; + } + lval=(unsigned short int) dval; + } while (0); + + return lval; +} + +/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % @@ -5931,8 +6218,9 @@ MagickExport int Tokenizer(TokenInfo *token_info,unsigned flag,char *token, % % A description of each parameter follows: % -% o translated_text: Method TranslateText returns the translated -% text string. +% o translated_text: Method TranslateText returns a new allocation +% containing the translated text string. If the translated text +% string would be empty, a NULL pointer is returned instead. % % o image_info: The imageInfo (may be NULL!). % @@ -6020,8 +6308,9 @@ MagickExport char *TranslateText(const ImageInfo *image_info, % % A description of each parameter follows: % -% o translated_text: Method TranslateText returns the translated -% text string. +% o translated_text: Method TranslateTextEx returns a new allocation +% containing the translated text string. If the translated text +% string would be empty, a NULL pointer is returned instead. % % o image_info: The imageInfo (may be NULL!). % @@ -6064,15 +6353,13 @@ MagickExport char *TranslateTextEx(const ImageInfo *image_info, /* Translate any embedded format characters. */ - length=strlen(text)+MaxTextExtent; - translated_text=MagickAllocateMemory(char *,length); + length=strlen(text); + translated_text=MagickAllocateMemory(char *,length+MaxTextExtent); if (translated_text == (char *) NULL) return NULL; - /* - FIXME: Overlapping memory detected here where memory should not be overlapping. - */ - (void) strlcpy(translated_text,text,length); - /* (void) memmove(translated_text,text,strlen(text)+1); */ + (void) memcpy(translated_text,text,length); + translated_text[length]='\0'; + length=length+MaxTextExtent; p=text; for (q=translated_text; *p != '\0'; p++) { diff --git a/magick/utility.h b/magick/utility.h index 138008e..e2cca78 100644 --- a/magick/utility.h +++ b/magick/utility.h @@ -79,7 +79,7 @@ extern MagickExport char extern MagickExport const char *GetClientFilename(void) MAGICK_FUNC_CONST, - *GetClientName(void) MAGICK_FUNC_CONST, + *GetClientName(void) MAGICK_FUNC_PURE, *GetClientPath(void) MAGICK_FUNC_CONST, *SetClientFilename(const char *), *SetClientName(const char *), diff --git a/magick/version.h b/magick/version.h index 3aad325..2bcdd62 100644 --- a/magick/version.h +++ b/magick/version.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2003 - 2022 GraphicsMagick Group + Copyright (C) 2003 - 2023 GraphicsMagick Group Copyright (C) 2002 ImageMagick Studio Copyright 1991-1999 E. I. du Pont de Nemours and Company @@ -34,12 +34,12 @@ extern "C" { identifying the release. */ #define MagickPackageName "GraphicsMagick" -#define MagickCopyright "Copyright (C) 2002-2022 GraphicsMagick Group.\nAdditional copyrights and licenses apply to this software.\nSee http://www.GraphicsMagick.org/www/Copyright.html for details." -#define MagickLibVersion 0x272400 -#define MagickLibVersionText "1.3.38" -#define MagickLibVersionNumber 27,24,0 -#define MagickChangeDate "20220326" -#define MagickReleaseDate "2022-03-26" +#define MagickCopyright "Copyright (C) 2002-2023 GraphicsMagick Group.\nAdditional copyrights and licenses apply to this software.\nSee http://www.GraphicsMagick.org/www/Copyright.html for details." +#define MagickLibVersion 0x272404 +#define MagickLibVersionText "1.3.42" +#define MagickLibVersionNumber 27,24,4 +#define MagickChangeDate "20230923" +#define MagickReleaseDate "2023-09-23" /* The MagickLibInterfaceNewest and MagickLibInterfaceOldest defines diff --git a/magick/version.h.in b/magick/version.h.in index 84cab7d..c00c8a1 100644 --- a/magick/version.h.in +++ b/magick/version.h.in @@ -1,5 +1,5 @@ /* - Copyright (C) 2003 - 2022 GraphicsMagick Group + Copyright (C) 2003 - 2023 GraphicsMagick Group Copyright (C) 2002 ImageMagick Studio Copyright 1991-1999 E. I. du Pont de Nemours and Company @@ -34,7 +34,7 @@ extern "C" { identifying the release. */ #define MagickPackageName "@PACKAGE_NAME@" -#define MagickCopyright "Copyright (C) 2002-2022 GraphicsMagick Group.\nAdditional copyrights and licenses apply to this software.\nSee http://www.GraphicsMagick.org/www/Copyright.html for details." +#define MagickCopyright "Copyright (C) 2002-2023 GraphicsMagick Group.\nAdditional copyrights and licenses apply to this software.\nSee http://www.GraphicsMagick.org/www/Copyright.html for details." #define MagickLibVersion @MAGICK_LIB_VERSION@ #define MagickLibVersionText "@MAGICK_LIB_VERSION_TEXT@" #define MagickLibVersionNumber @MAGICK_LIB_VERSION_NUMBER@ diff --git a/magick/widget.c b/magick/widget.c index 9cd815b..09e2b04 100644 --- a/magick/widget.c +++ b/magick/widget.c @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003-2019 GraphicsMagick Group +% Copyright (C) 2003-2022 GraphicsMagick Group % Copyright (C) 2002 ImageMagick Studio % Copyright 1991-1999 E. I. du Pont de Nemours and Company % @@ -1680,14 +1680,14 @@ void MagickXColorBrowserWidget(Display *display,MagickXWindows *windows, assert(reply != (char *) NULL); MagickXSetCursorState(display,windows,True); MagickXCheckRefreshWindows(display,windows); - (void) strcpy(reset_pattern,"*"); + (void) strlcpy(reset_pattern,"*",sizeof(reset_pattern)); colorlist=GetColorList(glob_pattern,&colors); if (colorlist == (char **) NULL) { /* Pattern failed, obtain all the colors. */ - (void) strcpy(glob_pattern,"*"); + (void) strlcpy(glob_pattern,"*",sizeof(glob_pattern)); colorlist=GetColorList(glob_pattern,&colors); if (colorlist == (char **) NULL) { @@ -1734,7 +1734,7 @@ void MagickXColorBrowserWidget(Display *display,MagickXWindows *windows, /* Map Color Browser widget. */ - (void) strcpy(windows->widget.name,"Browse and Select a Color"); + (void) strlcpy(windows->widget.name,"Browse and Select a Color",MaxTextExtent); status=XStringListToTextProperty(&windows->widget.name,1,&window_name); if (status != 0) { @@ -2209,6 +2209,8 @@ void MagickXColorBrowserWidget(Display *display,MagickXWindows *windows, /* User pressed mode button. */ + if (NULL == mode_info.text) + break; (void) strlcpy(reply_info.text,mode_info.text,MaxTextExtent); (void) strlcpy(primary_selection,reply_info.text,MaxTextExtent); (void) XSetSelectionOwner(display,XA_PRIMARY,windows->widget.id, @@ -2727,7 +2729,7 @@ void MagickXColorBrowserWidget(Display *display,MagickXWindows *windows, if (status != 0) return; MagickXNoticeWidget(display,windows,"Color is unknown to X server:",reply); - (void) strcpy(reply,"gray"); + (void) strlcpy(reply,"gray",MaxTextExtent); } /* @@ -3093,7 +3095,7 @@ static const unsigned char tile_bits[] = { default: break; } - if (state & UpdateConfigurationState) + if ((state & UpdateConfigurationState) && number_selections) { /* Initialize button information. @@ -3265,7 +3267,7 @@ int MagickXConfirmWidget(Display *display,MagickXWindows *windows, /* Map Confirm widget. */ - (void) strcpy(windows->widget.name,"Confirm"); + (void) strlcpy(windows->widget.name,"Confirm",MaxTextExtent); status=XStringListToTextProperty(&windows->widget.name,1,&window_name); if (status != 0) { @@ -3334,7 +3336,7 @@ int MagickXConfirmWidget(Display *display,MagickXWindows *windows, question[MaxTextExtent]; (void) strlcpy(question,description,MaxTextExtent); - (void) strcat(question,"?"); + (void) strlcat(question,"?",sizeof(question)); width=XTextWidth(font_info,question,Extent(question)); x=(windows->widget.width >> 1)-(width >> 1); y+=height; @@ -3672,7 +3674,7 @@ int MagickXDialogWidget(Display *display,MagickXWindows *windows, /* Map Dialog widget. */ - (void) strcpy(windows->widget.name,"Dialog"); + (void) strlcpy(windows->widget.name,"Dialog",MaxTextExtent); status=XStringListToTextProperty(&windows->widget.name,1,&window_name); if (status != 0) { @@ -4309,7 +4311,7 @@ void MagickXFileBrowserWidget(Display *display,MagickXWindows *windows, /* Map File Browser widget. */ - (void) strcpy(windows->widget.name,"Browse and Select a File"); + (void) strlcpy(windows->widget.name,"Browse and Select a File",MaxTextExtent); status=XStringListToTextProperty(&windows->widget.name,1,&window_name); if (status != 0) { @@ -4858,7 +4860,7 @@ void MagickXFileBrowserWidget(Display *display,MagickXWindows *windows, if (event.xbutton.window == windows->widget.id) if (MatteIsActive(up_info,event.xbutton)) { - (void) strcpy(working_directory,".."); + (void) strlcpy(working_directory,"..",sizeof(working_directory)); state|=UpdateListState; } up_info.raised=True; @@ -4943,7 +4945,7 @@ void MagickXFileBrowserWidget(Display *display,MagickXWindows *windows, if (event.xbutton.window == windows->widget.id) if (MatteIsActive(special_info,event.xbutton)) { - (void) strcpy(reply_info.text,"x:"); + (void) strlcpy(reply_info.text,"x:",MaxTextExtent); state|=ExitState; } special_info.raised=True; @@ -5494,8 +5496,8 @@ void MagickXFontBrowserWidget(Display *display,MagickXWindows *windows, assert(reply != (char *) NULL); MagickXSetCursorState(display,windows,True); MagickXCheckRefreshWindows(display,windows); - (void) strlcpy(back_pattern,glob_pattern,MaxTextExtent); - (void) strcpy(reset_pattern,"*"); + (void) strlcpy(back_pattern,glob_pattern,sizeof(back_pattern)); + (void) strlcpy(reset_pattern,"*",sizeof(reset_pattern)); fontlist=XListFonts(display,glob_pattern,32767,&fonts); if (fonts == 0) { @@ -5504,7 +5506,7 @@ void MagickXFontBrowserWidget(Display *display,MagickXWindows *windows, */ MagickXNoticeWidget(display,windows,"Unable to obtain fonts names:", glob_pattern); - (void) strcpy(glob_pattern,"*"); + (void) strlcpy(glob_pattern,"*",sizeof(glob_pattern)); fontlist=XListFonts(display,glob_pattern,32767,&fonts); if (fontlist == (char **) NULL) { @@ -5563,7 +5565,7 @@ void MagickXFontBrowserWidget(Display *display,MagickXWindows *windows, /* Map Font Browser widget. */ - (void) strcpy(windows->widget.name,"Browse and Select a Font"); + (void) strlcpy(windows->widget.name,"Browse and Select a Font",MaxTextExtent); status=XStringListToTextProperty(&windows->widget.name,1,&window_name); if (status != 0) { @@ -6791,7 +6793,7 @@ void MagickXListBrowserWidget(Display *display,MagickXWindows *windows, /* Map List Browser widget. */ - (void) strcpy(window_info->name,"Browse"); + (void) strlcpy(window_info->name,"Browse",MaxTextExtent); status=XStringListToTextProperty(&window_info->name,1,&window_name); if (status != 0) { @@ -8170,7 +8172,7 @@ void MagickXNoticeWidget(Display *display,MagickXWindows *windows, /* Map Notice widget. */ - (void) strcpy(windows->widget.name,"Notice"); + (void) strlcpy(windows->widget.name,"Notice",MaxTextExtent); status=XStringListToTextProperty(&windows->widget.name,1,&window_name); if (status != 0) { @@ -8506,7 +8508,7 @@ unsigned int MagickXPreferencesWidget(Display *display, /* Map Preferences widget. */ - (void) strcpy(windows->widget.name,"Preferences"); + (void) strlcpy(windows->widget.name,"Preferences",MaxTextExtent); status=XStringListToTextProperty(&windows->widget.name,1,&window_name); if (status != 0) { diff --git a/magick/xwindow.c b/magick/xwindow.c index 24f78e6..1f1cd08 100644 --- a/magick/xwindow.c +++ b/magick/xwindow.c @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003 - 2020 GraphicsMagick Group +% Copyright (C) 2003 - 2022 GraphicsMagick Group % Copyright (C) 2002 ImageMagick Studio % % This program is covered by multiple licenses, which are described in @@ -2109,9 +2109,11 @@ MagickXDisplayImageInfo(Display *display, %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Method XDitherImage dithers the reference image as required by the HP -% Color Recovery algorithm. The color values are quantized to 3 bits of red -% and green, and 2 bits of blue (3/3/2) and can be used as indices into a -% 8-bit X standard colormap. +% Color Recovery algorithm +% (https://www.hpl.hp.com/hpjournal/95apr/apr95a6.pdf). +% The color values are quantized to 3 bits of red and green, and 2 bits +% of blue (3/3/2) and can be used as indices into a 8-bit X standard +% colormap. % % The format of the XDitherImage method is: % @@ -2149,10 +2151,11 @@ static void MagickXDitherImage(Image *image,XImage *ximage) PixelPacket color; - int + long + x, y; - long + magick_int32_t value; register char @@ -2163,13 +2166,12 @@ static void MagickXDitherImage(Image *image,XImage *ximage) register int i, - j, - x; + j; unsigned int scanline_pad; - register unsigned long + register magick_uint32_t pixel; unsigned char @@ -2180,6 +2182,9 @@ static void MagickXDitherImage(Image *image,XImage *ximage) /* Allocate and initialize dither maps. */ + memset(blue_map,0,sizeof(blue_map)); + memset(green_map,0,sizeof(green_map)); + memset(red_map,0,sizeof(red_map)); for (i=0; i < 2; i++) for (j=0; j < 16; j++) { @@ -2193,7 +2198,7 @@ static void MagickXDitherImage(Image *image,XImage *ximage) { MagickError3(ResourceLimitError,MemoryAllocationFailed, UnableToDitherImage); - return; + goto done_xditherimage; } } /* @@ -2218,7 +2223,9 @@ static void MagickXDitherImage(Image *image,XImage *ximage) value=x-32; if (x < 112) value=x/2+24; - value+=(dither_blue[i][j] << 1); + /* FIXME: Cast to unsigned added below to avoid undefined + behavior. Not sure if result is what was expected! */ + value+=((magick_uint32_t) dither_blue[i][j] << 1); blue_map[i][j][x]=(unsigned char) ((value < 0) ? 0 : (value > 255) ? 255 : value); } @@ -2240,10 +2247,10 @@ static void MagickXDitherImage(Image *image,XImage *ximage) color.red=red_map[i][j][ScaleQuantumToChar(p->red)] << 8; color.green=green_map[i][j][ScaleQuantumToChar(p->green)] << 8; color.blue=blue_map[i][j][ScaleQuantumToChar(p->blue)] << 8; - pixel=(unsigned long) ((color.red & 0xe0) | - ((unsigned long) (color.green & 0xe0) >> 3) | - ((unsigned long) (color.blue & 0xc0) >> 6)); - *q++=(unsigned char) pixel; + pixel=(magick_uint32_t) ((color.red & 0xe0) | + ((magick_uint32_t) (color.green & 0xe0) >> 3) | + ((magick_uint32_t) (color.blue & 0xc0) >> 6)); + *q++=(magick_uint32_t) pixel; p++; j++; if (j == 16) @@ -2254,6 +2261,7 @@ static void MagickXDitherImage(Image *image,XImage *ximage) if (i == 2) i=0; } + done_xditherimage: /* Free allocated memory. */ @@ -3910,7 +3918,7 @@ MagickXGetWindowColor(Display *display,MagickXWindows *windows,char *name) pixel; RectangleInfo - crop_info; + crop_info = { 0, 0, 0, 0 }; unsigned int status; @@ -4488,7 +4496,8 @@ MagickXGetWindowImage(Display *display,const Window window, /* Create colormap. */ - if (!AllocateImageColormap(composite_image,number_colors)) + if ((NULL == colors) || + !AllocateImageColormap(composite_image,number_colors)) { XDestroyImage(ximage); ximage=(XImage *) NULL; @@ -4526,7 +4535,9 @@ MagickXGetWindowImage(Display *display,const Window window, } } XDestroyImage(ximage); +#if !defined(__COVERITY__) /* 384805 Unused value */ ximage=(XImage *) NULL; +#endif /* if !defined(__COVERITY__) */ /* Evaluate image depth. @@ -5233,7 +5244,7 @@ MagickXInitializeWindows(Display *display, #if defined(MSWINDOWS) (void) XSynchronize(display,IsWindows95()); #endif - if (IsEventLogging()) + if (IsEventLogged(X11Event)) { (void) XSynchronize(display,True); (void) LogMagickEvent(X11Event,GetMagickModule(),"Version: %.1024s", @@ -5300,7 +5311,7 @@ MagickXInitializeWindows(Display *display, (windows->icon_visual == (XVisualInfo *) NULL)) MagickFatalError(XServerFatalError,UnableToGetVisual, resource_info->visual_type); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) { (void) LogMagickEvent(X11Event,GetMagickModule(),"Visual:"); (void) LogMagickEvent(X11Event,GetMagickModule()," visual id: 0x%lx", @@ -5783,7 +5794,7 @@ MagickXMakeImage(Display *display, (void) XDefineCursor(display,window->id,window->cursor); return(False); } - if (IsEventLogging()) + if (IsEventLogged(X11Event)) { (void) LogMagickEvent(X11Event,GetMagickModule(),"XImage:"); (void) LogMagickEvent(X11Event,GetMagickModule()," width x height: %dx%d", @@ -5891,7 +5902,7 @@ MagickXMakeImage(Display *display, */ matte_image=XCreateImage(display,window->visual,1,XYBitmap,0, (char *) NULL,width,height,XBitmapPad(display),0); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) { (void) LogMagickEvent(X11Event,GetMagickModule(),"Matte Image:"); (void) LogMagickEvent(X11Event,GetMagickModule(), @@ -7195,6 +7206,13 @@ MagickXMakeMagnifyImage(Display *display,MagickXWindows *windows) magnify>>=1; while (magnify > windows->magnify.height) magnify>>=1; + if (magnify == 0) + { + if (previous_magnify != 0) + magnify = previous_magnify; + else + magnify = 1; + } if (magnify != previous_magnify) { unsigned int @@ -7635,7 +7653,7 @@ MagickXMakePixmap(Display *display, if (!window->shared_memory) (void) XPutImage(display,window->pixmap,window->annotate_context, window->ximage,0,0,0,0,width,height); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) { (void) LogMagickEvent(X11Event,GetMagickModule(),"Pixmap:"); (void) LogMagickEvent(X11Event,GetMagickModule()," width, height: %ux%u", @@ -7816,7 +7834,7 @@ MagickXMakeStandardColormap(Display *display, (void) SetImageType(image,TrueColorType); DestroyImage(map_image); } - if (IsEventLogging()) + if (IsEventLogged(X11Event)) { (void) LogMagickEvent(X11Event,GetMagickModule(),"Standard Colormap:"); (void) LogMagickEvent(X11Event,GetMagickModule()," colormap id: 0x%lx", @@ -8257,7 +8275,7 @@ MagickXMakeStandardColormap(Display *display, pixel->colors=image->colors+MaxNumberPens; } MagickFreeMemory(colors); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) { (void) LogMagickEvent(X11Event,GetMagickModule(),"Standard Colormap:"); (void) LogMagickEvent(X11Event,GetMagickModule()," colormap id: 0x%lx", |