summaryrefslogtreecommitdiff
path: root/coders/msl.c
diff options
context:
space:
mode:
Diffstat (limited to 'coders/msl.c')
-rw-r--r--coders/msl.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/coders/msl.c b/coders/msl.c
index d0b3017..4549310 100644
--- a/coders/msl.c
+++ b/coders/msl.c
@@ -1,5 +1,5 @@
/*
-% Copyright (C) 2003 - 2017 GraphicsMagick Group
+% Copyright (C) 2003 - 2019 GraphicsMagick Group
% Copyright (C) 2002 ImageMagick Studio
%
% This program is covered by multiple licenses, which are described in
@@ -3270,16 +3270,13 @@ MSLStartElement(void *context,const xmlChar *name,
{
if (LocaleCompare(keyword, "opacity") == 0)
{
- int opac = OpaqueOpacity,
- len = (int) strlen( value );
+ int opac = OpaqueOpacity;
+ size_t len = strlen( value );
- if (value[len-1] == '%') {
- char tmp[100];
- (void) strncpy(tmp, value, (size_t) (len-1));
- opac = MagickAtoI( tmp );
+ opac = MagickAtoI( value );
+ if ((opac > 0) && (len > 1) && value[len-1] == '%')
opac = (int)(MaxRGB * ((float)opac/100));
- } else
- opac = MagickAtoI( value );
+
SetImageOpacity( msl_info->image[n], opac );
break;
}
@@ -4556,6 +4553,18 @@ ProcessMSLScript(const ImageInfo *image_info,Image **image,
SAXHandler;
/*
+ Libxml initialization. We call it here since initialization can
+ be expensive and we don't know when/if libxml will be
+ needed. Should normally be called at program start-up but may be
+ called several times since libxml uses a flag to know if it has
+ already been initialized. When libxml2 is built to support
+ threads, it tests if it is already initialized under a lock and
+ holds a lock while it is being initialized so calling this
+ function from multiple threads is ok.
+ */
+ xmlInitParser();
+
+ /*
Open image file.
*/
assert(image_info != (const ImageInfo *) NULL);
@@ -4654,7 +4663,7 @@ ProcessMSLScript(const ImageInfo *image_info,Image **image,
xmlFreeDoc(msl_info.document);
- xmlCleanupParser();
+ /* xmlCleanupParser(); */
/* printf("ProcessMSLScript(msl_info->n=%ld\n",msl_info.n); */
@@ -4695,13 +4704,14 @@ ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
Image *
image;
- /*
- Open image file.
- */
assert(image_info != (const ImageInfo *) NULL);
assert(image_info->signature == MagickSignature);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
+
+ /*
+ Open image file.
+ */
image=(Image *) NULL;
(void) ProcessMSLScript(image_info,&image,exception);
return(image);