]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Thu, 2 Jan 2014 15:52:07 +0000 (15:52 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Thu, 2 Jan 2014 15:52:07 +0000 (15:52 +0000)
MagickCore/magic.c
coders/jp2.c

index 694ba813343af4e899356fd18e60aafeb5f97df4..6a6672fe0e0b12b9d3c302c061cc544afc311357 100644 (file)
@@ -135,8 +135,9 @@ static const MagicMapInfo
     { "IPTC", 0, MagickString("\034\002") },
     { "JNG", 0, MagickString("\213JNG\r\n\032\n") },
     { "JPEG", 0, MagickString("\377\330\377") },
-    { "JPC", 0, MagickString("\377\117") },
-    { "JP2", 4, MagickString("\152\120\040\040\015") },
+    { "J2K", 0, MagickString("\xff\x4f\xff\x51") },
+    { "JPC", 0, MagickString("\x0d\x0a\x87\x0a") },
+    { "JP2", 4, MagickString("\x00\x00\x00\x0c\x6a\x50\x20\x20\x0d\x0a\x87\x0a") },
     { "MAT", 0, MagickString("MATLAB 5.0 MAT-file,") },
     { "MIFF", 0, MagickString("Id=ImageMagick") },
     { "MIFF", 0, MagickString("id=ImageMagick") },
index eb3eafdc0ef678ce73609f67b4e45284357cb6c8..1caa9ef375c857442ef9cddddffd4158314a740c 100644 (file)
@@ -83,6 +83,40 @@ static MagickBooleanType
 %                                                                             %
 %                                                                             %
 %                                                                             %
+%   I s J 2 K                                                                 %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  IsJ2K() returns MagickTrue if the image format type, identified by the
+%  magick string, is J2K.
+%
+%  The format of the IsJ2K method is:
+%
+%      MagickBooleanType IsJP2(const unsigned char *magick,const size_t length)
+%
+%  A description of each parameter follows:
+%
+%    o magick: compare image format pattern against these bytes.
+%
+%    o length: Specifies the length of the magick string.
+%
+*/
+static MagickBooleanType IsJ2K(const unsigned char *magick,const size_t length)
+{
+  if (length < 4)
+    return(MagickFalse);
+  if (memcmp(magick,"\xff\x4f\xff\x51",4) == 0)
+    return(MagickTrue);
+  return(MagickFalse);
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
 %   I s J P 2                                                                 %
 %                                                                             %
 %                                                                             %
@@ -105,9 +139,11 @@ static MagickBooleanType
 */
 static MagickBooleanType IsJP2(const unsigned char *magick,const size_t length)
 {
-  if (length < 9)
+  if (length < 12)
     return(MagickFalse);
-  if (memcmp(magick+4,"\152\120\040\040\015",5) == 0)
+  if (memcmp(magick,"\x00\x00\x00\x0c\x6a\x50\x20\x20\x0d\x0a\x87\x0a",12) == 0)
+    return(MagickTrue);
+  if (memcmp(magick,"\x0d\x0a\x87\x0a",12) == 0)
     return(MagickTrue);
   return(MagickFalse);
 }
@@ -139,9 +175,11 @@ static MagickBooleanType IsJP2(const unsigned char *magick,const size_t length)
 */
 static MagickBooleanType IsJPC(const unsigned char *magick,const size_t length)
 {
-  if (length < 2)
+  if (length < 12)
     return(MagickFalse);
-  if (memcmp(magick,"\377\117",2) == 0)
+  if (memcmp(magick,"\x00\x00\x00\x0c\x6a\x50\x20\x20\x0d\x0a\x87\x0a",12) == 0)
+    return(MagickTrue);
+  if (memcmp(magick,"\x0d\x0a\x87\x0a",12) == 0)
     return(MagickTrue);
   return(MagickFalse);
 }
@@ -530,7 +568,7 @@ ModuleExport size_t RegisterJP2Image(void)
   entry->description=ConstantString("JPEG-2000 Code Stream Syntax");
   entry->mime_type=ConstantString("image/jp2");
   entry->module=ConstantString("JP2");
-  entry->magick=(IsImageFormatHandler *) IsJPC;
+  entry->magick=(IsImageFormatHandler *) IsJ2K;
   entry->adjoin=MagickFalse;
   entry->seekable_stream=MagickTrue;
   entry->thread_support=NoThreadSupport;