Commit a4d1d6209 for imagemagick.org
commit a4d1d62096c8250d7596857cacfd8d59e2b459e1
Author: Cristy <urban-warrior@imagemagick.org>
Date: Fri Aug 28 20:03:32 2026 -0400
add c2pa coder framework
diff --git a/coders/c2pa.c b/coders/c2pa.c
new file mode 100644
index 000000000..dfb68aa37
--- /dev/null
+++ b/coders/c2pa.c
@@ -0,0 +1,187 @@
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
+% CCCC 22222 PPPP AAA %
+% C 22 P P A A %
+% C 22 PPPP AAAAA %
+% C 22 P A A %
+% CCCC 22222 P A A %
+% %
+% %
+% C2PA Provenance Metadata. %
+% %
+% Software Design %
+% Cristy %
+% September 2026 %
+% %
+% %
+% Copyright @ 1999 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 %
+% obtain a copy of the License at %
+% %
+% https://imagemagick.org/license/ %
+% %
+% Unless required by applicable law or agreed to in writing, software %
+% distributed under the License is distributed on an "AS IS" BASIS, %
+% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
+% See the License for the specific language governing permissions and %
+% limitations under the License. %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%
+*/
+
+/*
+ Include declarations.
+*/
+#include "MagickCore/studio.h"
+#include "MagickCore/attribute.h"
+#include "MagickCore/blob.h"
+#include "MagickCore/blob-private.h"
+#include "MagickCore/constitute.h"
+#include "MagickCore/exception.h"
+#include "MagickCore/exception-private.h"
+#include "MagickCore/list.h"
+#include "MagickCore/magick.h"
+#include "MagickCore/memory_.h"
+#include "MagickCore/monitor.h"
+#include "MagickCore/monitor-private.h"
+#include "MagickCore/quantum-private.h"
+#include "MagickCore/static.h"
+#include "MagickCore/string_.h"
+#include "MagickCore/module.h"
+
+/*
+ Forward declarations.
+*/
+static MagickBooleanType
+ WriteC2PAImage(const ImageInfo *,Image *,ExceptionInfo *);
+
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
+% R e a d C L I P I m a g e %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% ReadC2PAImage returns the rendered clip path associated with the image.
+%
+% The format of the ReadC2PAImage method is:
+%
+% Image *ReadC2PAImage(const ImageInfo *image_info,
+% ExceptionInfo *exception)
+%
+% A description of each parameter follows:
+%
+% o image_info: the image info.
+%
+% o exception: return any errors or warnings in this structure.
+%
+*/
+static Image *ReadC2PAImage(const ImageInfo *image_info,
+ ExceptionInfo *exception)
+{
+ return((Image *) NULL);
+}
+
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
+% R e g i s t e r C L I P I m a g e %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% RegisterC2PAImage() adds attributes for the C2PA image format to
+% the list of supported formats. The attributes include the image format
+% tag, a method to read and/or write the format, whether the format
+% supports the saving of more than one frame to the same file or blob,
+% whether the format supports native in-memory I/O, and a brief
+% description of the format.
+%
+% The format of the RegisterC2PAImage method is:
+%
+% size_t RegisterC2PAImage(void)
+%
+*/
+ModuleExport size_t RegisterC2PAImage(void)
+{
+ MagickInfo
+ *entry;
+
+ entry=AcquireMagickInfo("C2PA","C2PA","C2PA Provenance Metadata");
+ entry->decoder=(DecodeImageHandler *) ReadC2PAImage;
+ entry->encoder=(EncodeImageHandler *) WriteC2PAImage;
+ (void) RegisterMagickInfo(entry);
+ return(MagickImageCoderSignature);
+}
+
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
+% U n r e g i s t e r C L I P I m a g e %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% UnregisterC2PAImage() removes format registrations made by the
+% C2PA module from the list of supported formats.
+%
+% The format of the UnregisterC2PAImage method is:
+%
+% UnregisterC2PAImage(void)
+%
+*/
+ModuleExport void UnregisterC2PAImage(void)
+{
+ (void) UnregisterMagickInfo("C2PA");
+}
+
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
+% W r i t e C L I P I m a g e %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% WriteC2PAImage() writes an image of clip bytes to a file. It consists of
+% data from the clip mask of the image.
+%
+% The format of the WriteC2PAImage method is:
+%
+% MagickBooleanType WriteC2PAImage(const ImageInfo *image_info,
+% Image *image,ExceptionInfo *exception)
+%
+% A description of each parameter follows.
+%
+% o image_info: the image info.
+%
+% o image: The image.
+%
+% o exception: return any errors or warnings in this structure.
+%
+*/
+static MagickBooleanType WriteC2PAImage(const ImageInfo *image_info,
+ Image *image,ExceptionInfo *exception)
+{
+ return(MagickFalse);
+}