]> granicus.if.org Git - imagemagick/blobdiff - coders/jpeg.c
(no commit message)
[imagemagick] / coders / jpeg.c
index b2d768a86e0f780b946259b34c294291ddbd4a4b..0ba7077b3f45dda96a7c503d891b97ca1014d156 100644 (file)
@@ -17,7 +17,7 @@
 %                                 July 1992                                   %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization      %
 %  dedicated to making software imaging solutions freely available.           %
 %                                                                             %
 %  You may not use this file except in compliance with the License.  You may  %
@@ -510,7 +510,7 @@ static boolean ReadIPTCProfile(j_decompress_ptr jpeg_info)
     ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
       image->filename);
   p=GetStringInfoDatum(profile);
-  for (i=(ssize_t) GetStringInfoLength(profile)-1; i >= 0; i--)
+  for (i=0;  i < (ssize_t) GetStringInfoLength(profile); i++)
     *p++=(unsigned char) GetCharacter(jpeg_info);
   iptc_profile=(StringInfo *) GetImageProfile(image,"8bim");
   if (iptc_profile != (StringInfo *) NULL)
@@ -918,6 +918,7 @@ static Image *ReadJPEGImage(const ImageInfo *image_info,
   assert(exception != (ExceptionInfo *) NULL);
   assert(exception->signature == MagickSignature);
   debug=IsEventLogging();
+  (void) debug;
   image=AcquireImage(image_info);
   status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
   if (status == MagickFalse)
@@ -1507,7 +1508,11 @@ static void WriteProfile(j_compress_ptr jpeg_info,Image *image)
   ResetImageProfileIterator(image);
   for (name=GetNextImageProfile(image); name != (const char *) NULL; )
   {
+    register unsigned char
+      *p;
+
     profile=GetImageProfile(image,name);
+    p=GetStringInfoDatum(custom_profile);
     if (LocaleCompare(name,"EXIF") == 0)
       for (i=0; i < (ssize_t) GetStringInfoLength(profile); i+=65533L)
       {
@@ -1526,7 +1531,6 @@ static void WriteProfile(j_compress_ptr jpeg_info,Image *image)
         for (i=0; i < (ssize_t) GetStringInfoLength(profile); i+=65519L)
         {
           length=MagickMin(GetStringInfoLength(profile)-i,65519L);
-          p=GetStringInfoDatum(custom_profile);
           p[12]=(unsigned char) ((i/65519L)+1);
           p[13]=(unsigned char) (GetStringInfoLength(profile)/65519L+1);
           (void) CopyMagickMemory(p+tag_length,GetStringInfoDatum(profile)+i,
@@ -1538,33 +1542,28 @@ static void WriteProfile(j_compress_ptr jpeg_info,Image *image)
     if (((LocaleCompare(name,"IPTC") == 0) ||
         (LocaleCompare(name,"8BIM") == 0)) && (iptc == MagickFalse))
       {
-        register unsigned char
-          *p;
-
         size_t
           roundup;
 
         iptc=MagickTrue;
-        p=GetStringInfoDatum(custom_profile);
-        if (LocaleNCompare((char *) GetStringInfoDatum(profile),"8BIM",4) == 0)
-          {
-            (void) CopyMagickMemory(p,"Photoshop 3.0\0",14);
-            tag_length=14;
-          }
-        else
-          {
-            (void) CopyMagickMemory(p,"Photoshop 3.0\08BIM\04\04\0\0\0\0",24);
-            p[13]=0x00;
-            p[24]=(unsigned char) (GetStringInfoLength(profile) >> 8);
-            p[25]=(unsigned char) (GetStringInfoLength(profile) & 0xff);
-            tag_length=26;
-          }
         for (i=0; i < (ssize_t) GetStringInfoLength(profile); i+=65500L)
         {
           length=MagickMin(GetStringInfoLength(profile)-i,65500L);
           roundup=(size_t) (length & 0x01);
-          (void) CopyMagickMemory(p+tag_length,GetStringInfoDatum(profile)+i,
-            length);
+          if (LocaleNCompare((char *) GetStringInfoDatum(profile),"8BIM",4) == 0)
+            {
+              (void) memcpy(p,"Photoshop 3.0 ",14);
+              tag_length=14;
+            }
+          else
+            {
+              (void) CopyMagickMemory(p,"Photoshop 3.0 8BIM\04\04\0\0\0\0",24);
+              tag_length=26;
+              p[24]=(unsigned char) (length >> 8);
+              p[25]=(unsigned char) (length & 0xff);
+            }
+          p[13]=0x00;
+          (void) memcpy(p+tag_length,GetStringInfoDatum(profile)+i,length);
           if (roundup != 0)
             p[length+tag_length]='\0';
           jpeg_write_marker(jpeg_info,IPTC_MARKER,GetStringInfoDatum(
@@ -1715,7 +1714,6 @@ static MagickBooleanType WriteJPEGImage(const ImageInfo *image_info,
   jpeg_info.client_data=(void *) image;
   jpeg_info.err=jpeg_std_error(&jpeg_error);
   jpeg_info.err->emit_message=(void (*)(j_common_ptr,int)) EmitMessage;
-  jpeg_info.err->error_exit=(void (*)(j_common_ptr)) JPEGErrorHandler;
   error_manager.image=image;
   jpeg_pixels=(JSAMPLE *) NULL;
   if (setjmp(error_manager.error_recovery) != 0)