GraphicsMagick: GetImageClippingPathAttribute(): Check for and u...

GraphicsMagick Commits <[email protected]>
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.11727.1688239880.17398.graphicsmagick-commit@lists.sourceforge.net>
changeset d09ea9c70be7 in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=d09ea9c70be7
summary: GetImageClippingPathAttribute(): Check for and use clipping path name (ID=2999) to get the real attribute name.

diffstat:

 ChangeLog          |   6 ++++++
 magick/attribute.c |  17 ++++++++++++++++-
 www/Changelog.html |   5 +++++
 3 files changed, 27 insertions(+), 1 deletions(-)

diffs (57 lines):

diff -r cf9a42968e43 -r d09ea9c70be7 ChangeLog
--- a/ChangeLog	Sat Jul 01 13:36:20 2023 -0500
+++ b/ChangeLog	Sat Jul 01 14:31:07 2023 -0500
@@ -1,5 +1,11 @@
 2023-07-01  Bob Friesenhahn  <[email protected]>
 
+	* magick/attribute.c: In GetImageClippingPathAttribute(), check
+	for the presence of the clipping path name (ID=2999). If that's
+	found, it searches for a path with that name. Otherwise, it
+	returns NULL.  Based (in spirit) on SourceForge #62 "Fix for
+	GetImageClippingPathAttribute".
+
 	* configure.ac (LIB_HEIF): SourceForge patch #71 "Use pkg-config
 	for libheif in configure".
 
diff -r cf9a42968e43 -r d09ea9c70be7 magick/attribute.c
--- a/magick/attribute.c	Sat Jul 01 13:36:20 2023 -0500
+++ b/magick/attribute.c	Sat Jul 01 14:31:07 2023 -0500
@@ -2528,7 +2528,22 @@
 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;
 }
 
 /*
diff -r cf9a42968e43 -r d09ea9c70be7 www/Changelog.html
--- a/www/Changelog.html	Sat Jul 01 13:36:20 2023 -0500
+++ b/www/Changelog.html	Sat Jul 01 14:31:07 2023 -0500
@@ -40,6 +40,11 @@
 <p>2023-07-01  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">
+<li><p>magick/attribute.c: In GetImageClippingPathAttribute(), check
+for the presence of the clipping path name (ID=2999). If that's
+found, it searches for a path with that name. Otherwise, it
+returns NULL.  Based (in spirit) on SourceForge #62 &quot;Fix for
+GetImageClippingPathAttribute&quot;.</p></li>
 <li><p>configure.ac (LIB_HEIF): SourceForge patch #71 &quot;Use pkg-config
 for libheif in configure&quot;.</p></li>
 <li><p>TclMagick/{configure.ac, generic/Makefile.am,
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.