cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 | % % |
| 4 | % % |
| 5 | % % |
| 6 | % PPPP RRRR OOO PPPP EEEEE RRRR TTTTT Y Y % |
| 7 | % P P R R O O P P E R R T Y Y % |
| 8 | % PPPP RRRR O O PPPP EEE RRRR T Y % |
| 9 | % P R R O O P E R R T Y % |
| 10 | % P R R OOO P EEEEE R R T Y % |
| 11 | % % |
| 12 | % % |
| 13 | % MagickCore Property Methods % |
| 14 | % % |
| 15 | % Software Design % |
cristy | de984cd | 2013-12-01 14:49:27 +0000 | [diff] [blame] | 16 | % Cristy % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 17 | % March 2000 % |
| 18 | % % |
| 19 | % % |
cristy | b56bb24 | 2014-11-25 17:12:48 +0000 | [diff] [blame] | 20 | % Copyright 1999-2015 ImageMagick Studio LLC, a non-profit organization % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 21 | % dedicated to making software imaging solutions freely available. % |
| 22 | % % |
| 23 | % You may not use this file except in compliance with the License. You may % |
| 24 | % obtain a copy of the License at % |
| 25 | % % |
| 26 | % http://www.imagemagick.org/script/license.php % |
| 27 | % % |
| 28 | % Unless required by applicable law or agreed to in writing, software % |
| 29 | % distributed under the License is distributed on an "AS IS" BASIS, % |
| 30 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % |
| 31 | % See the License for the specific language governing permissions and % |
| 32 | % limitations under the License. % |
| 33 | % % |
| 34 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 35 | % |
| 36 | % |
| 37 | % |
| 38 | */ |
dirk | 6015d44 | 2013-10-19 15:07:40 +0000 | [diff] [blame] | 39 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 40 | /* |
| 41 | Include declarations. |
| 42 | */ |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 43 | #include "MagickCore/studio.h" |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 44 | #include "MagickCore/artifact.h" |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 45 | #include "MagickCore/attribute.h" |
| 46 | #include "MagickCore/cache.h" |
cristy | afcb049 | 2013-10-15 01:11:56 +0000 | [diff] [blame] | 47 | #include "MagickCore/cache-private.h" |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 48 | #include "MagickCore/color.h" |
cristy | d228c03 | 2012-06-03 15:01:15 +0000 | [diff] [blame] | 49 | #include "MagickCore/color-private.h" |
cristy | 3d9f5ba | 2012-06-26 13:37:31 +0000 | [diff] [blame] | 50 | #include "MagickCore/colorspace-private.h" |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 51 | #include "MagickCore/compare.h" |
| 52 | #include "MagickCore/constitute.h" |
| 53 | #include "MagickCore/draw.h" |
| 54 | #include "MagickCore/effect.h" |
| 55 | #include "MagickCore/exception.h" |
| 56 | #include "MagickCore/exception-private.h" |
| 57 | #include "MagickCore/fx.h" |
| 58 | #include "MagickCore/fx-private.h" |
| 59 | #include "MagickCore/gem.h" |
| 60 | #include "MagickCore/geometry.h" |
| 61 | #include "MagickCore/histogram.h" |
| 62 | #include "MagickCore/image.h" |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 63 | #include "MagickCore/layer.h" |
cristy | 7832dc2 | 2011-09-05 01:21:53 +0000 | [diff] [blame] | 64 | #include "MagickCore/locale-private.h" |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 65 | #include "MagickCore/list.h" |
| 66 | #include "MagickCore/magick.h" |
| 67 | #include "MagickCore/memory_.h" |
| 68 | #include "MagickCore/monitor.h" |
| 69 | #include "MagickCore/montage.h" |
| 70 | #include "MagickCore/option.h" |
| 71 | #include "MagickCore/profile.h" |
| 72 | #include "MagickCore/property.h" |
| 73 | #include "MagickCore/quantum.h" |
| 74 | #include "MagickCore/resource_.h" |
| 75 | #include "MagickCore/splay-tree.h" |
cristy | 7832dc2 | 2011-09-05 01:21:53 +0000 | [diff] [blame] | 76 | #include "MagickCore/signature.h" |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 77 | #include "MagickCore/statistic.h" |
| 78 | #include "MagickCore/string_.h" |
| 79 | #include "MagickCore/string-private.h" |
| 80 | #include "MagickCore/token.h" |
cristy | 7832dc2 | 2011-09-05 01:21:53 +0000 | [diff] [blame] | 81 | #include "MagickCore/token-private.h" |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 82 | #include "MagickCore/utility.h" |
cristy | d1dd6e4 | 2011-09-04 01:46:08 +0000 | [diff] [blame] | 83 | #include "MagickCore/utility-private.h" |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 84 | #include "MagickCore/version.h" |
| 85 | #include "MagickCore/xml-tree.h" |
cristy | 433d118 | 2011-09-04 13:38:52 +0000 | [diff] [blame] | 86 | #include "MagickCore/xml-tree-private.h" |
dirk | 6015d44 | 2013-10-19 15:07:40 +0000 | [diff] [blame] | 87 | #if defined(MAGICKCORE_LCMS_DELEGATE) |
cristy | d6ac47f | 2015-06-06 13:46:55 +0000 | [diff] [blame] | 88 | #if defined(MAGICKCORE_HAVE_LCMS_LCMS2_H) |
| 89 | #include <lcms/lcms2.h> |
| 90 | #elif defined(MAGICKCORE_HAVE_LCMS2_H) |
cristy | b054e07 | 2015-06-05 20:35:43 +0000 | [diff] [blame] | 91 | #include "lcms2.h" |
cristy | d6ac47f | 2015-06-06 13:46:55 +0000 | [diff] [blame] | 92 | #elif defined(MAGICKCORE_HAVE_LCMS_LCMS_H) |
| 93 | #include <lcms/lcms.h> |
| 94 | #else |
| 95 | #include "lcms.h" |
dirk | 6015d44 | 2013-10-19 15:07:40 +0000 | [diff] [blame] | 96 | #endif |
| 97 | #endif |
cristy | f516f2f | 2014-01-07 01:29:28 +0000 | [diff] [blame] | 98 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 99 | /* |
cristy | d57d563 | 2014-01-23 13:28:07 +0000 | [diff] [blame] | 100 | Define declarations. |
| 101 | */ |
| 102 | #if defined(MAGICKCORE_LCMS_DELEGATE) |
| 103 | #if defined(LCMS_VERSION) && (LCMS_VERSION < 2000) |
cristy | fc57e8c | 2014-01-29 15:50:18 +0000 | [diff] [blame] | 104 | #define cmsUInt32Number DWORD |
cristy | d57d563 | 2014-01-23 13:28:07 +0000 | [diff] [blame] | 105 | #endif |
| 106 | #endif |
| 107 | |
| 108 | /* |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 109 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 110 | % % |
| 111 | % % |
| 112 | % % |
| 113 | % C l o n e I m a g e P r o p e r t i e s % |
| 114 | % % |
| 115 | % % |
| 116 | % % |
| 117 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 118 | % |
anthony | d2f39e0 | 2012-08-20 12:29:28 +0000 | [diff] [blame] | 119 | % CloneImageProperties() clones all the image properties to another image. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 120 | % |
| 121 | % The format of the CloneImageProperties method is: |
| 122 | % |
| 123 | % MagickBooleanType CloneImageProperties(Image *image, |
| 124 | % const Image *clone_image) |
| 125 | % |
| 126 | % A description of each parameter follows: |
| 127 | % |
| 128 | % o image: the image. |
| 129 | % |
| 130 | % o clone_image: the clone image. |
| 131 | % |
| 132 | */ |
| 133 | MagickExport MagickBooleanType CloneImageProperties(Image *image, |
| 134 | const Image *clone_image) |
| 135 | { |
| 136 | assert(image != (Image *) NULL); |
cristy | e1c94d9 | 2015-06-28 12:16:33 +0000 | [diff] [blame] | 137 | assert(image->signature == MagickCoreSignature); |
cristy | cb190b7 | 2014-08-31 20:04:42 +0000 | [diff] [blame] | 138 | if (image->debug != MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 139 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 140 | assert(clone_image != (const Image *) NULL); |
cristy | e1c94d9 | 2015-06-28 12:16:33 +0000 | [diff] [blame] | 141 | assert(clone_image->signature == MagickCoreSignature); |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 142 | if( IfMagickTrue(clone_image->debug) ) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 143 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 144 | clone_image->filename); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 145 | (void) CopyMagickString(image->filename,clone_image->filename,MagickPathExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 146 | (void) CopyMagickString(image->magick_filename,clone_image->magick_filename, |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 147 | MagickPathExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 148 | image->compression=clone_image->compression; |
| 149 | image->quality=clone_image->quality; |
| 150 | image->depth=clone_image->depth; |
| 151 | image->background_color=clone_image->background_color; |
| 152 | image->border_color=clone_image->border_color; |
| 153 | image->matte_color=clone_image->matte_color; |
| 154 | image->transparent_color=clone_image->transparent_color; |
| 155 | image->gamma=clone_image->gamma; |
| 156 | image->chromaticity=clone_image->chromaticity; |
| 157 | image->rendering_intent=clone_image->rendering_intent; |
| 158 | image->black_point_compensation=clone_image->black_point_compensation; |
| 159 | image->units=clone_image->units; |
| 160 | image->montage=(char *) NULL; |
| 161 | image->directory=(char *) NULL; |
| 162 | (void) CloneString(&image->geometry,clone_image->geometry); |
| 163 | image->offset=clone_image->offset; |
cristy | 2a11bef | 2011-10-28 18:33:11 +0000 | [diff] [blame] | 164 | image->resolution.x=clone_image->resolution.x; |
| 165 | image->resolution.y=clone_image->resolution.y; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 166 | image->page=clone_image->page; |
| 167 | image->tile_offset=clone_image->tile_offset; |
| 168 | image->extract_info=clone_image->extract_info; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 169 | image->filter=clone_image->filter; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 170 | image->fuzz=clone_image->fuzz; |
cristy | ff848fa | 2013-06-10 23:34:40 +0000 | [diff] [blame] | 171 | image->intensity=clone_image->intensity; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 172 | image->interlace=clone_image->interlace; |
| 173 | image->interpolate=clone_image->interpolate; |
| 174 | image->endian=clone_image->endian; |
| 175 | image->gravity=clone_image->gravity; |
| 176 | image->compose=clone_image->compose; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 177 | image->orientation=clone_image->orientation; |
cristy | 1169512 | 2014-06-09 12:29:50 +0000 | [diff] [blame] | 178 | image->scene=clone_image->scene; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 179 | image->dispose=clone_image->dispose; |
| 180 | image->delay=clone_image->delay; |
| 181 | image->ticks_per_second=clone_image->ticks_per_second; |
| 182 | image->iterations=clone_image->iterations; |
| 183 | image->total_colors=clone_image->total_colors; |
| 184 | image->taint=clone_image->taint; |
| 185 | image->progress_monitor=clone_image->progress_monitor; |
| 186 | image->client_data=clone_image->client_data; |
| 187 | image->start_loop=clone_image->start_loop; |
| 188 | image->error=clone_image->error; |
| 189 | image->signature=clone_image->signature; |
| 190 | if (clone_image->properties != (void *) NULL) |
| 191 | { |
| 192 | if (image->properties != (void *) NULL) |
| 193 | DestroyImageProperties(image); |
| 194 | image->properties=CloneSplayTree((SplayTreeInfo *) |
| 195 | clone_image->properties,(void *(*)(void *)) ConstantString, |
| 196 | (void *(*)(void *)) ConstantString); |
| 197 | } |
| 198 | return(MagickTrue); |
| 199 | } |
cristy | f516f2f | 2014-01-07 01:29:28 +0000 | [diff] [blame] | 200 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 201 | /* |
| 202 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 203 | % % |
| 204 | % % |
| 205 | % % |
| 206 | % D e f i n e I m a g e P r o p e r t y % |
| 207 | % % |
| 208 | % % |
| 209 | % % |
| 210 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 211 | % |
anthony | d2f39e0 | 2012-08-20 12:29:28 +0000 | [diff] [blame] | 212 | % DefineImageProperty() associates an assignment string of the form |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 213 | % "key=value" with an artifact or options. It is equivelent to |
| 214 | % SetImageProperty() |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 215 | % |
| 216 | % The format of the DefineImageProperty method is: |
| 217 | % |
cristy | 3119762 | 2013-03-06 02:07:54 +0000 | [diff] [blame] | 218 | % MagickBooleanType DefineImageProperty(Image *image,const char *property, |
| 219 | % ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 220 | % |
| 221 | % A description of each parameter follows: |
| 222 | % |
| 223 | % o image: the image. |
| 224 | % |
| 225 | % o property: the image property. |
| 226 | % |
cristy | d15e659 | 2011-10-15 00:13:06 +0000 | [diff] [blame] | 227 | % o exception: return any errors or warnings in this structure. |
| 228 | % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 229 | */ |
| 230 | MagickExport MagickBooleanType DefineImageProperty(Image *image, |
cristy | d15e659 | 2011-10-15 00:13:06 +0000 | [diff] [blame] | 231 | const char *property,ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 232 | { |
| 233 | char |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 234 | key[MagickPathExtent], |
| 235 | value[MagickPathExtent]; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 236 | |
| 237 | register char |
| 238 | *p; |
| 239 | |
| 240 | assert(image != (Image *) NULL); |
| 241 | assert(property != (const char *) NULL); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 242 | (void) CopyMagickString(key,property,MagickPathExtent-1); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 243 | for (p=key; *p != '\0'; p++) |
| 244 | if (*p == '=') |
| 245 | break; |
| 246 | *value='\0'; |
| 247 | if (*p == '=') |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 248 | (void) CopyMagickString(value,p+1,MagickPathExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 249 | *p='\0'; |
cristy | d15e659 | 2011-10-15 00:13:06 +0000 | [diff] [blame] | 250 | return(SetImageProperty(image,key,value,exception)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 251 | } |
cristy | f516f2f | 2014-01-07 01:29:28 +0000 | [diff] [blame] | 252 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 253 | /* |
| 254 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 255 | % % |
| 256 | % % |
| 257 | % % |
| 258 | % D e l e t e I m a g e P r o p e r t y % |
| 259 | % % |
| 260 | % % |
| 261 | % % |
| 262 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 263 | % |
| 264 | % DeleteImageProperty() deletes an image property. |
| 265 | % |
| 266 | % The format of the DeleteImageProperty method is: |
| 267 | % |
| 268 | % MagickBooleanType DeleteImageProperty(Image *image,const char *property) |
| 269 | % |
| 270 | % A description of each parameter follows: |
| 271 | % |
| 272 | % o image: the image. |
| 273 | % |
| 274 | % o property: the image property. |
| 275 | % |
| 276 | */ |
| 277 | MagickExport MagickBooleanType DeleteImageProperty(Image *image, |
| 278 | const char *property) |
| 279 | { |
| 280 | assert(image != (Image *) NULL); |
cristy | e1c94d9 | 2015-06-28 12:16:33 +0000 | [diff] [blame] | 281 | assert(image->signature == MagickCoreSignature); |
cristy | cb190b7 | 2014-08-31 20:04:42 +0000 | [diff] [blame] | 282 | if (image->debug != MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 283 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 284 | image->filename); |
| 285 | if (image->properties == (void *) NULL) |
| 286 | return(MagickFalse); |
| 287 | return(DeleteNodeFromSplayTree((SplayTreeInfo *) image->properties,property)); |
| 288 | } |
cristy | f516f2f | 2014-01-07 01:29:28 +0000 | [diff] [blame] | 289 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 290 | /* |
| 291 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 292 | % % |
| 293 | % % |
| 294 | % % |
| 295 | % D e s t r o y I m a g e P r o p e r t i e s % |
| 296 | % % |
| 297 | % % |
| 298 | % % |
| 299 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 300 | % |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 301 | % DestroyImageProperties() destroys all properties and associated memory |
anthony | d2f39e0 | 2012-08-20 12:29:28 +0000 | [diff] [blame] | 302 | % attached to the given image. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 303 | % |
| 304 | % The format of the DestroyDefines method is: |
| 305 | % |
| 306 | % void DestroyImageProperties(Image *image) |
| 307 | % |
| 308 | % A description of each parameter follows: |
| 309 | % |
| 310 | % o image: the image. |
| 311 | % |
| 312 | */ |
| 313 | MagickExport void DestroyImageProperties(Image *image) |
| 314 | { |
| 315 | assert(image != (Image *) NULL); |
cristy | e1c94d9 | 2015-06-28 12:16:33 +0000 | [diff] [blame] | 316 | assert(image->signature == MagickCoreSignature); |
cristy | cb190b7 | 2014-08-31 20:04:42 +0000 | [diff] [blame] | 317 | if (image->debug != MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 318 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 319 | image->filename); |
| 320 | if (image->properties != (void *) NULL) |
| 321 | image->properties=(void *) DestroySplayTree((SplayTreeInfo *) |
| 322 | image->properties); |
| 323 | } |
cristy | f516f2f | 2014-01-07 01:29:28 +0000 | [diff] [blame] | 324 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 325 | /* |
| 326 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 327 | % % |
| 328 | % % |
| 329 | % % |
| 330 | % F o r m a t I m a g e P r o p e r t y % |
| 331 | % % |
| 332 | % % |
| 333 | % % |
| 334 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 335 | % |
| 336 | % FormatImageProperty() permits formatted property/value pairs to be saved as |
glennrp | 2cc891a | 2010-12-24 13:44:32 +0000 | [diff] [blame] | 337 | % an image property. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 338 | % |
| 339 | % The format of the FormatImageProperty method is: |
| 340 | % |
| 341 | % MagickBooleanType FormatImageProperty(Image *image,const char *property, |
| 342 | % const char *format,...) |
| 343 | % |
| 344 | % A description of each parameter follows. |
| 345 | % |
| 346 | % o image: The image. |
| 347 | % |
| 348 | % o property: The attribute property. |
| 349 | % |
| 350 | % o format: A string describing the format to use to write the remaining |
| 351 | % arguments. |
| 352 | % |
| 353 | */ |
cristy | db584ae | 2011-05-20 14:50:53 +0000 | [diff] [blame] | 354 | MagickExport MagickBooleanType FormatImageProperty(Image *image, |
| 355 | const char *property,const char *format,...) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 356 | { |
| 357 | char |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 358 | value[MagickPathExtent]; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 359 | |
cristy | c82a27b | 2011-10-21 01:07:16 +0000 | [diff] [blame] | 360 | ExceptionInfo |
| 361 | *exception; |
| 362 | |
| 363 | MagickBooleanType |
| 364 | status; |
| 365 | |
cristy | 20ec759 | 2011-05-29 01:28:05 +0000 | [diff] [blame] | 366 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 367 | n; |
| 368 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 369 | va_list |
| 370 | operands; |
| 371 | |
| 372 | va_start(operands,format); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 373 | n=FormatLocaleStringList(value,MagickPathExtent,format,operands); |
cristy | db584ae | 2011-05-20 14:50:53 +0000 | [diff] [blame] | 374 | (void) n; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 375 | va_end(operands); |
cristy | c82a27b | 2011-10-21 01:07:16 +0000 | [diff] [blame] | 376 | exception=AcquireExceptionInfo(); |
| 377 | status=SetImageProperty(image,property,value,exception); |
| 378 | exception=DestroyExceptionInfo(exception); |
| 379 | return(status); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 380 | } |
cristy | f516f2f | 2014-01-07 01:29:28 +0000 | [diff] [blame] | 381 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 382 | /* |
| 383 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 384 | % % |
| 385 | % % |
| 386 | % % |
| 387 | % G e t I m a g e P r o p e r t y % |
| 388 | % % |
| 389 | % % |
| 390 | % % |
| 391 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 392 | % |
| 393 | % GetImageProperty() gets a value associated with an image property. |
| 394 | % |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 395 | % This includes, profile prefixes, such as "exif:", "iptc:" and "8bim:" |
| 396 | % It does not handle non-prifile prefixes, such as "fx:", "option:", or |
| 397 | % "artifact:". |
| 398 | % |
| 399 | % The returned string is stored as a properity of the same name for faster |
| 400 | % lookup later. It should NOT be freed by the caller. |
anthony | d2f39e0 | 2012-08-20 12:29:28 +0000 | [diff] [blame] | 401 | % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 402 | % The format of the GetImageProperty method is: |
| 403 | % |
cristy | d15e659 | 2011-10-15 00:13:06 +0000 | [diff] [blame] | 404 | % const char *GetImageProperty(const Image *image,const char *key, |
| 405 | % ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 406 | % |
| 407 | % A description of each parameter follows: |
| 408 | % |
| 409 | % o image: the image. |
| 410 | % |
| 411 | % o key: the key. |
| 412 | % |
cristy | d15e659 | 2011-10-15 00:13:06 +0000 | [diff] [blame] | 413 | % o exception: return any errors or warnings in this structure. |
| 414 | % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 415 | */ |
| 416 | |
| 417 | static char |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 418 | *TracePSClippath(const unsigned char *,size_t,const size_t, |
| 419 | const size_t), |
| 420 | *TraceSVGClippath(const unsigned char *,size_t,const size_t, |
| 421 | const size_t); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 422 | |
cristy | d15e659 | 2011-10-15 00:13:06 +0000 | [diff] [blame] | 423 | static MagickBooleanType GetIPTCProperty(const Image *image,const char *key, |
| 424 | ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 425 | { |
| 426 | char |
| 427 | *attribute, |
| 428 | *message; |
| 429 | |
| 430 | const StringInfo |
| 431 | *profile; |
| 432 | |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 433 | long |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 434 | count, |
| 435 | dataset, |
| 436 | record; |
| 437 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 438 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 439 | i; |
| 440 | |
| 441 | size_t |
| 442 | length; |
| 443 | |
| 444 | profile=GetImageProfile(image,"iptc"); |
| 445 | if (profile == (StringInfo *) NULL) |
| 446 | profile=GetImageProfile(image,"8bim"); |
| 447 | if (profile == (StringInfo *) NULL) |
| 448 | return(MagickFalse); |
| 449 | count=sscanf(key,"IPTC:%ld:%ld",&dataset,&record); |
| 450 | if (count != 2) |
| 451 | return(MagickFalse); |
| 452 | attribute=(char *) NULL; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 453 | for (i=0; i < (ssize_t) GetStringInfoLength(profile); i+=(ssize_t) length) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 454 | { |
| 455 | length=1; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 456 | if ((ssize_t) GetStringInfoDatum(profile)[i] != 0x1c) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 457 | continue; |
| 458 | length=(size_t) (GetStringInfoDatum(profile)[i+3] << 8); |
| 459 | length|=GetStringInfoDatum(profile)[i+4]; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 460 | if (((long) GetStringInfoDatum(profile)[i+1] == dataset) && |
| 461 | ((long) GetStringInfoDatum(profile)[i+2] == record)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 462 | { |
| 463 | message=(char *) NULL; |
| 464 | if (~length >= 1) |
| 465 | message=(char *) AcquireQuantumMemory(length+1UL,sizeof(*message)); |
| 466 | if (message != (char *) NULL) |
| 467 | { |
| 468 | (void) CopyMagickString(message,(char *) GetStringInfoDatum( |
| 469 | profile)+i+5,length+1); |
| 470 | (void) ConcatenateString(&attribute,message); |
| 471 | (void) ConcatenateString(&attribute,";"); |
| 472 | message=DestroyString(message); |
| 473 | } |
| 474 | } |
| 475 | i+=5; |
| 476 | } |
| 477 | if ((attribute == (char *) NULL) || (*attribute == ';')) |
| 478 | { |
| 479 | if (attribute != (char *) NULL) |
| 480 | attribute=DestroyString(attribute); |
| 481 | return(MagickFalse); |
| 482 | } |
| 483 | attribute[strlen(attribute)-1]='\0'; |
cristy | d15e659 | 2011-10-15 00:13:06 +0000 | [diff] [blame] | 484 | (void) SetImageProperty((Image *) image,key,(const char *) attribute, |
| 485 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 486 | attribute=DestroyString(attribute); |
| 487 | return(MagickTrue); |
| 488 | } |
| 489 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 490 | static inline int ReadPropertyByte(const unsigned char **p,size_t *length) |
| 491 | { |
| 492 | int |
| 493 | c; |
| 494 | |
| 495 | if (*length < 1) |
| 496 | return(EOF); |
| 497 | c=(int) (*(*p)++); |
| 498 | (*length)--; |
| 499 | return(c); |
| 500 | } |
| 501 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 502 | static inline size_t ReadPropertyMSBLong(const unsigned char **p, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 503 | size_t *length) |
| 504 | { |
| 505 | int |
| 506 | c; |
| 507 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 508 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 509 | i; |
| 510 | |
| 511 | unsigned char |
| 512 | buffer[4]; |
| 513 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 514 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 515 | value; |
| 516 | |
| 517 | if (*length < 4) |
| 518 | return(~0UL); |
| 519 | for (i=0; i < 4; i++) |
| 520 | { |
| 521 | c=(int) (*(*p)++); |
| 522 | (*length)--; |
| 523 | buffer[i]=(unsigned char) c; |
| 524 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 525 | value=(size_t) (buffer[0] << 24); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 526 | value|=buffer[1] << 16; |
| 527 | value|=buffer[2] << 8; |
| 528 | value|=buffer[3]; |
| 529 | return(value & 0xffffffff); |
| 530 | } |
| 531 | |
| 532 | static inline unsigned short ReadPropertyMSBShort(const unsigned char **p, |
| 533 | size_t *length) |
| 534 | { |
| 535 | int |
| 536 | c; |
| 537 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 538 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 539 | i; |
| 540 | |
| 541 | unsigned char |
| 542 | buffer[2]; |
| 543 | |
| 544 | unsigned short |
| 545 | value; |
| 546 | |
| 547 | if (*length < 2) |
dirk | 93b02b7 | 2013-11-16 16:03:36 +0000 | [diff] [blame] | 548 | return((unsigned short) ~0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 549 | for (i=0; i < 2; i++) |
| 550 | { |
| 551 | c=(int) (*(*p)++); |
| 552 | (*length)--; |
| 553 | buffer[i]=(unsigned char) c; |
| 554 | } |
| 555 | value=(unsigned short) (buffer[0] << 8); |
| 556 | value|=buffer[1]; |
| 557 | return((unsigned short) (value & 0xffff)); |
| 558 | } |
| 559 | |
cristy | d15e659 | 2011-10-15 00:13:06 +0000 | [diff] [blame] | 560 | static MagickBooleanType Get8BIMProperty(const Image *image,const char *key, |
| 561 | ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 562 | { |
| 563 | char |
| 564 | *attribute, |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 565 | format[MagickPathExtent], |
| 566 | name[MagickPathExtent], |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 567 | *resource; |
| 568 | |
| 569 | const StringInfo |
| 570 | *profile; |
| 571 | |
| 572 | const unsigned char |
| 573 | *info; |
| 574 | |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 575 | long |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 576 | start, |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 577 | stop; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 578 | |
| 579 | MagickBooleanType |
| 580 | status; |
| 581 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 582 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 583 | i; |
| 584 | |
| 585 | ssize_t |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 586 | count, |
| 587 | id, |
| 588 | sub_number; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 589 | |
| 590 | size_t |
| 591 | length; |
| 592 | |
| 593 | /* |
glennrp | 2cc891a | 2010-12-24 13:44:32 +0000 | [diff] [blame] | 594 | There are no newlines in path names, so it's safe as terminator. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 595 | */ |
| 596 | profile=GetImageProfile(image,"8bim"); |
| 597 | if (profile == (StringInfo *) NULL) |
| 598 | return(MagickFalse); |
| 599 | count=(ssize_t) sscanf(key,"8BIM:%ld,%ld:%[^\n]\n%[^\n]",&start,&stop,name, |
| 600 | format); |
| 601 | if ((count != 2) && (count != 3) && (count != 4)) |
| 602 | return(MagickFalse); |
| 603 | if (count < 4) |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 604 | (void) CopyMagickString(format,"SVG",MagickPathExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 605 | if (count < 3) |
| 606 | *name='\0'; |
| 607 | sub_number=1; |
| 608 | if (*name == '#') |
cristy | ad74005 | 2010-07-03 01:38:03 +0000 | [diff] [blame] | 609 | sub_number=(ssize_t) StringToLong(&name[1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 610 | sub_number=MagickMax(sub_number,1L); |
| 611 | resource=(char *) NULL; |
| 612 | status=MagickFalse; |
| 613 | length=GetStringInfoLength(profile); |
| 614 | info=GetStringInfoDatum(profile); |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 615 | while ((length > 0) && IfMagickFalse(status)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 616 | { |
| 617 | if (ReadPropertyByte(&info,&length) != (unsigned char) '8') |
| 618 | continue; |
| 619 | if (ReadPropertyByte(&info,&length) != (unsigned char) 'B') |
| 620 | continue; |
| 621 | if (ReadPropertyByte(&info,&length) != (unsigned char) 'I') |
| 622 | continue; |
| 623 | if (ReadPropertyByte(&info,&length) != (unsigned char) 'M') |
| 624 | continue; |
cristy | 4a8b017 | 2012-02-03 16:39:53 +0000 | [diff] [blame] | 625 | id=(ssize_t) ((int) ReadPropertyMSBShort(&info,&length)); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 626 | if (id < (ssize_t) start) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 627 | continue; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 628 | if (id > (ssize_t) stop) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 629 | continue; |
| 630 | if (resource != (char *) NULL) |
| 631 | resource=DestroyString(resource); |
| 632 | count=(ssize_t) ReadPropertyByte(&info,&length); |
| 633 | if ((count != 0) && ((size_t) count <= length)) |
| 634 | { |
| 635 | resource=(char *) NULL; |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 636 | if (~((size_t) count) >= (MagickPathExtent-1)) |
| 637 | resource=(char *) AcquireQuantumMemory((size_t) count+MagickPathExtent, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 638 | sizeof(*resource)); |
| 639 | if (resource != (char *) NULL) |
| 640 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 641 | for (i=0; i < (ssize_t) count; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 642 | resource[i]=(char) ReadPropertyByte(&info,&length); |
| 643 | resource[count]='\0'; |
| 644 | } |
| 645 | } |
| 646 | if ((count & 0x01) == 0) |
| 647 | (void) ReadPropertyByte(&info,&length); |
cristy | 55a91cd | 2010-12-01 00:57:40 +0000 | [diff] [blame] | 648 | count=(ssize_t) ((int) ReadPropertyMSBLong(&info,&length)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 649 | if ((*name != '\0') && (*name != '#')) |
| 650 | if ((resource == (char *) NULL) || (LocaleCompare(name,resource) != 0)) |
| 651 | { |
| 652 | /* |
| 653 | No name match, scroll forward and try next. |
| 654 | */ |
| 655 | info+=count; |
cristy | 4a8b017 | 2012-02-03 16:39:53 +0000 | [diff] [blame] | 656 | length-=MagickMin(count,(ssize_t) length); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 657 | continue; |
| 658 | } |
| 659 | if ((*name == '#') && (sub_number != 1)) |
| 660 | { |
| 661 | /* |
| 662 | No numbered match, scroll forward and try next. |
| 663 | */ |
| 664 | sub_number--; |
| 665 | info+=count; |
cristy | 4a8b017 | 2012-02-03 16:39:53 +0000 | [diff] [blame] | 666 | length-=MagickMin(count,(ssize_t) length); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 667 | continue; |
| 668 | } |
| 669 | /* |
| 670 | We have the resource of interest. |
| 671 | */ |
| 672 | attribute=(char *) NULL; |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 673 | if (~((size_t) count) >= (MagickPathExtent-1)) |
| 674 | attribute=(char *) AcquireQuantumMemory((size_t) count+MagickPathExtent, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 675 | sizeof(*attribute)); |
| 676 | if (attribute != (char *) NULL) |
| 677 | { |
| 678 | (void) CopyMagickMemory(attribute,(char *) info,(size_t) count); |
| 679 | attribute[count]='\0'; |
| 680 | info+=count; |
cristy | 4a8b017 | 2012-02-03 16:39:53 +0000 | [diff] [blame] | 681 | length-=MagickMin(count,(ssize_t) length); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 682 | if ((id <= 1999) || (id >= 2999)) |
| 683 | (void) SetImageProperty((Image *) image,key,(const char *) |
cristy | d15e659 | 2011-10-15 00:13:06 +0000 | [diff] [blame] | 684 | attribute,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 685 | else |
| 686 | { |
| 687 | char |
| 688 | *path; |
| 689 | |
| 690 | if (LocaleCompare(format,"svg") == 0) |
| 691 | path=TraceSVGClippath((unsigned char *) attribute,(size_t) count, |
| 692 | image->columns,image->rows); |
| 693 | else |
| 694 | path=TracePSClippath((unsigned char *) attribute,(size_t) count, |
| 695 | image->columns,image->rows); |
cristy | d15e659 | 2011-10-15 00:13:06 +0000 | [diff] [blame] | 696 | (void) SetImageProperty((Image *) image,key,(const char *) path, |
| 697 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 698 | path=DestroyString(path); |
| 699 | } |
| 700 | attribute=DestroyString(attribute); |
| 701 | status=MagickTrue; |
| 702 | } |
| 703 | } |
| 704 | if (resource != (char *) NULL) |
| 705 | resource=DestroyString(resource); |
| 706 | return(status); |
| 707 | } |
| 708 | |
| 709 | static inline unsigned short ReadPropertyShort(const EndianType endian, |
| 710 | const unsigned char *buffer) |
| 711 | { |
| 712 | unsigned short |
| 713 | value; |
| 714 | |
cristy | 1715f79 | 2012-11-22 16:56:12 +0000 | [diff] [blame] | 715 | if (endian == LSBEndian) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 716 | { |
cristy | 1715f79 | 2012-11-22 16:56:12 +0000 | [diff] [blame] | 717 | value=(unsigned short) ((buffer[1] << 8) | buffer[0]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 718 | return((unsigned short) (value & 0xffff)); |
| 719 | } |
cristy | 1715f79 | 2012-11-22 16:56:12 +0000 | [diff] [blame] | 720 | value=(unsigned short) ((((unsigned char *) buffer)[0] << 8) | |
| 721 | ((unsigned char *) buffer)[1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 722 | return((unsigned short) (value & 0xffff)); |
| 723 | } |
| 724 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 725 | static inline size_t ReadPropertyLong(const EndianType endian, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 726 | const unsigned char *buffer) |
| 727 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 728 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 729 | value; |
| 730 | |
cristy | 1715f79 | 2012-11-22 16:56:12 +0000 | [diff] [blame] | 731 | if (endian == LSBEndian) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 732 | { |
cristy | 1715f79 | 2012-11-22 16:56:12 +0000 | [diff] [blame] | 733 | value=(size_t) ((buffer[3] << 24) | (buffer[2] << 16) | |
| 734 | (buffer[1] << 8 ) | (buffer[0])); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 735 | return((size_t) (value & 0xffffffff)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 736 | } |
cristy | 1715f79 | 2012-11-22 16:56:12 +0000 | [diff] [blame] | 737 | value=(size_t) ((buffer[0] << 24) | (buffer[1] << 16) | |
| 738 | (buffer[2] << 8) | buffer[3]); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 739 | return((size_t) (value & 0xffffffff)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 740 | } |
| 741 | |
| 742 | static MagickBooleanType GetEXIFProperty(const Image *image, |
cristy | d15e659 | 2011-10-15 00:13:06 +0000 | [diff] [blame] | 743 | const char *property,ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 744 | { |
| 745 | #define MaxDirectoryStack 16 |
| 746 | #define EXIF_DELIMITER "\n" |
| 747 | #define EXIF_NUM_FORMATS 12 |
| 748 | #define EXIF_FMT_BYTE 1 |
| 749 | #define EXIF_FMT_STRING 2 |
| 750 | #define EXIF_FMT_USHORT 3 |
| 751 | #define EXIF_FMT_ULONG 4 |
| 752 | #define EXIF_FMT_URATIONAL 5 |
| 753 | #define EXIF_FMT_SBYTE 6 |
| 754 | #define EXIF_FMT_UNDEFINED 7 |
| 755 | #define EXIF_FMT_SSHORT 8 |
| 756 | #define EXIF_FMT_SLONG 9 |
| 757 | #define EXIF_FMT_SRATIONAL 10 |
| 758 | #define EXIF_FMT_SINGLE 11 |
| 759 | #define EXIF_FMT_DOUBLE 12 |
| 760 | #define TAG_EXIF_OFFSET 0x8769 |
| 761 | #define TAG_GPS_OFFSET 0x8825 |
| 762 | #define TAG_INTEROP_OFFSET 0xa005 |
| 763 | |
cristy | 96ea486 | 2011-11-22 00:45:47 +0000 | [diff] [blame] | 764 | #define EXIFMultipleValues(size,format,arg) \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 765 | { \ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 766 | ssize_t \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 767 | component; \ |
| 768 | \ |
| 769 | size_t \ |
| 770 | length; \ |
| 771 | \ |
| 772 | unsigned char \ |
| 773 | *p1; \ |
| 774 | \ |
| 775 | length=0; \ |
| 776 | p1=p; \ |
| 777 | for (component=0; component < components; component++) \ |
| 778 | { \ |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 779 | length+=FormatLocaleString(buffer+length,MagickPathExtent-length, \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 780 | format", ",arg); \ |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 781 | if (length >= (MagickPathExtent-1)) \ |
| 782 | length=MagickPathExtent-1; \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 783 | p1+=size; \ |
| 784 | } \ |
| 785 | if (length > 1) \ |
| 786 | buffer[length-2]='\0'; \ |
| 787 | value=AcquireString(buffer); \ |
| 788 | } |
| 789 | |
cristy | 96ea486 | 2011-11-22 00:45:47 +0000 | [diff] [blame] | 790 | #define EXIFMultipleFractions(size,format,arg1,arg2) \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 791 | { \ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 792 | ssize_t \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 793 | component; \ |
| 794 | \ |
| 795 | size_t \ |
| 796 | length; \ |
| 797 | \ |
| 798 | unsigned char \ |
| 799 | *p1; \ |
| 800 | \ |
| 801 | length=0; \ |
| 802 | p1=p; \ |
| 803 | for (component=0; component < components; component++) \ |
| 804 | { \ |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 805 | length+=FormatLocaleString(buffer+length,MagickPathExtent-length, \ |
cristy | d66c108 | 2012-03-28 18:17:37 +0000 | [diff] [blame] | 806 | format", ",(arg1),(arg2)); \ |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 807 | if (length >= (MagickPathExtent-1)) \ |
| 808 | length=MagickPathExtent-1; \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 809 | p1+=size; \ |
| 810 | } \ |
| 811 | if (length > 1) \ |
| 812 | buffer[length-2]='\0'; \ |
| 813 | value=AcquireString(buffer); \ |
| 814 | } |
| 815 | |
| 816 | typedef struct _DirectoryInfo |
| 817 | { |
| 818 | const unsigned char |
| 819 | *directory; |
| 820 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 821 | size_t |
cristy | 3d8d1f1 | 2012-02-29 01:59:28 +0000 | [diff] [blame] | 822 | entry; |
| 823 | |
| 824 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 825 | offset; |
| 826 | } DirectoryInfo; |
| 827 | |
| 828 | typedef struct _TagInfo |
| 829 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 830 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 831 | tag; |
| 832 | |
| 833 | const char |
| 834 | *description; |
| 835 | } TagInfo; |
| 836 | |
| 837 | static TagInfo |
| 838 | EXIFTag[] = |
| 839 | { |
| 840 | { 0x001, "exif:InteroperabilityIndex" }, |
| 841 | { 0x002, "exif:InteroperabilityVersion" }, |
| 842 | { 0x100, "exif:ImageWidth" }, |
| 843 | { 0x101, "exif:ImageLength" }, |
| 844 | { 0x102, "exif:BitsPerSample" }, |
| 845 | { 0x103, "exif:Compression" }, |
| 846 | { 0x106, "exif:PhotometricInterpretation" }, |
| 847 | { 0x10a, "exif:FillOrder" }, |
| 848 | { 0x10d, "exif:DocumentName" }, |
| 849 | { 0x10e, "exif:ImageDescription" }, |
| 850 | { 0x10f, "exif:Make" }, |
| 851 | { 0x110, "exif:Model" }, |
| 852 | { 0x111, "exif:StripOffsets" }, |
| 853 | { 0x112, "exif:Orientation" }, |
| 854 | { 0x115, "exif:SamplesPerPixel" }, |
| 855 | { 0x116, "exif:RowsPerStrip" }, |
| 856 | { 0x117, "exif:StripByteCounts" }, |
| 857 | { 0x11a, "exif:XResolution" }, |
| 858 | { 0x11b, "exif:YResolution" }, |
| 859 | { 0x11c, "exif:PlanarConfiguration" }, |
| 860 | { 0x11d, "exif:PageName" }, |
| 861 | { 0x11e, "exif:XPosition" }, |
| 862 | { 0x11f, "exif:YPosition" }, |
| 863 | { 0x118, "exif:MinSampleValue" }, |
| 864 | { 0x119, "exif:MaxSampleValue" }, |
| 865 | { 0x120, "exif:FreeOffsets" }, |
| 866 | { 0x121, "exif:FreeByteCounts" }, |
| 867 | { 0x122, "exif:GrayResponseUnit" }, |
| 868 | { 0x123, "exif:GrayResponseCurve" }, |
| 869 | { 0x124, "exif:T4Options" }, |
| 870 | { 0x125, "exif:T6Options" }, |
| 871 | { 0x128, "exif:ResolutionUnit" }, |
| 872 | { 0x12d, "exif:TransferFunction" }, |
| 873 | { 0x131, "exif:Software" }, |
| 874 | { 0x132, "exif:DateTime" }, |
| 875 | { 0x13b, "exif:Artist" }, |
| 876 | { 0x13e, "exif:WhitePoint" }, |
| 877 | { 0x13f, "exif:PrimaryChromaticities" }, |
| 878 | { 0x140, "exif:ColorMap" }, |
| 879 | { 0x141, "exif:HalfToneHints" }, |
| 880 | { 0x142, "exif:TileWidth" }, |
| 881 | { 0x143, "exif:TileLength" }, |
| 882 | { 0x144, "exif:TileOffsets" }, |
| 883 | { 0x145, "exif:TileByteCounts" }, |
| 884 | { 0x14a, "exif:SubIFD" }, |
| 885 | { 0x14c, "exif:InkSet" }, |
| 886 | { 0x14d, "exif:InkNames" }, |
| 887 | { 0x14e, "exif:NumberOfInks" }, |
| 888 | { 0x150, "exif:DotRange" }, |
| 889 | { 0x151, "exif:TargetPrinter" }, |
| 890 | { 0x152, "exif:ExtraSample" }, |
| 891 | { 0x153, "exif:SampleFormat" }, |
| 892 | { 0x154, "exif:SMinSampleValue" }, |
| 893 | { 0x155, "exif:SMaxSampleValue" }, |
| 894 | { 0x156, "exif:TransferRange" }, |
| 895 | { 0x157, "exif:ClipPath" }, |
| 896 | { 0x158, "exif:XClipPathUnits" }, |
| 897 | { 0x159, "exif:YClipPathUnits" }, |
| 898 | { 0x15a, "exif:Indexed" }, |
| 899 | { 0x15b, "exif:JPEGTables" }, |
| 900 | { 0x15f, "exif:OPIProxy" }, |
| 901 | { 0x200, "exif:JPEGProc" }, |
| 902 | { 0x201, "exif:JPEGInterchangeFormat" }, |
| 903 | { 0x202, "exif:JPEGInterchangeFormatLength" }, |
| 904 | { 0x203, "exif:JPEGRestartInterval" }, |
| 905 | { 0x205, "exif:JPEGLosslessPredictors" }, |
| 906 | { 0x206, "exif:JPEGPointTransforms" }, |
| 907 | { 0x207, "exif:JPEGQTables" }, |
| 908 | { 0x208, "exif:JPEGDCTables" }, |
| 909 | { 0x209, "exif:JPEGACTables" }, |
| 910 | { 0x211, "exif:YCbCrCoefficients" }, |
| 911 | { 0x212, "exif:YCbCrSubSampling" }, |
| 912 | { 0x213, "exif:YCbCrPositioning" }, |
| 913 | { 0x214, "exif:ReferenceBlackWhite" }, |
| 914 | { 0x2bc, "exif:ExtensibleMetadataPlatform" }, |
| 915 | { 0x301, "exif:Gamma" }, |
| 916 | { 0x302, "exif:ICCProfileDescriptor" }, |
| 917 | { 0x303, "exif:SRGBRenderingIntent" }, |
| 918 | { 0x320, "exif:ImageTitle" }, |
| 919 | { 0x5001, "exif:ResolutionXUnit" }, |
| 920 | { 0x5002, "exif:ResolutionYUnit" }, |
| 921 | { 0x5003, "exif:ResolutionXLengthUnit" }, |
| 922 | { 0x5004, "exif:ResolutionYLengthUnit" }, |
| 923 | { 0x5005, "exif:PrintFlags" }, |
| 924 | { 0x5006, "exif:PrintFlagsVersion" }, |
| 925 | { 0x5007, "exif:PrintFlagsCrop" }, |
| 926 | { 0x5008, "exif:PrintFlagsBleedWidth" }, |
| 927 | { 0x5009, "exif:PrintFlagsBleedWidthScale" }, |
| 928 | { 0x500A, "exif:HalftoneLPI" }, |
| 929 | { 0x500B, "exif:HalftoneLPIUnit" }, |
| 930 | { 0x500C, "exif:HalftoneDegree" }, |
| 931 | { 0x500D, "exif:HalftoneShape" }, |
| 932 | { 0x500E, "exif:HalftoneMisc" }, |
| 933 | { 0x500F, "exif:HalftoneScreen" }, |
| 934 | { 0x5010, "exif:JPEGQuality" }, |
| 935 | { 0x5011, "exif:GridSize" }, |
| 936 | { 0x5012, "exif:ThumbnailFormat" }, |
| 937 | { 0x5013, "exif:ThumbnailWidth" }, |
| 938 | { 0x5014, "exif:ThumbnailHeight" }, |
| 939 | { 0x5015, "exif:ThumbnailColorDepth" }, |
| 940 | { 0x5016, "exif:ThumbnailPlanes" }, |
| 941 | { 0x5017, "exif:ThumbnailRawBytes" }, |
| 942 | { 0x5018, "exif:ThumbnailSize" }, |
| 943 | { 0x5019, "exif:ThumbnailCompressedSize" }, |
| 944 | { 0x501a, "exif:ColorTransferFunction" }, |
| 945 | { 0x501b, "exif:ThumbnailData" }, |
| 946 | { 0x5020, "exif:ThumbnailImageWidth" }, |
| 947 | { 0x5021, "exif:ThumbnailImageHeight" }, |
| 948 | { 0x5022, "exif:ThumbnailBitsPerSample" }, |
| 949 | { 0x5023, "exif:ThumbnailCompression" }, |
| 950 | { 0x5024, "exif:ThumbnailPhotometricInterp" }, |
| 951 | { 0x5025, "exif:ThumbnailImageDescription" }, |
| 952 | { 0x5026, "exif:ThumbnailEquipMake" }, |
| 953 | { 0x5027, "exif:ThumbnailEquipModel" }, |
| 954 | { 0x5028, "exif:ThumbnailStripOffsets" }, |
| 955 | { 0x5029, "exif:ThumbnailOrientation" }, |
| 956 | { 0x502a, "exif:ThumbnailSamplesPerPixel" }, |
| 957 | { 0x502b, "exif:ThumbnailRowsPerStrip" }, |
| 958 | { 0x502c, "exif:ThumbnailStripBytesCount" }, |
| 959 | { 0x502d, "exif:ThumbnailResolutionX" }, |
| 960 | { 0x502e, "exif:ThumbnailResolutionY" }, |
| 961 | { 0x502f, "exif:ThumbnailPlanarConfig" }, |
| 962 | { 0x5030, "exif:ThumbnailResolutionUnit" }, |
| 963 | { 0x5031, "exif:ThumbnailTransferFunction" }, |
| 964 | { 0x5032, "exif:ThumbnailSoftwareUsed" }, |
| 965 | { 0x5033, "exif:ThumbnailDateTime" }, |
| 966 | { 0x5034, "exif:ThumbnailArtist" }, |
| 967 | { 0x5035, "exif:ThumbnailWhitePoint" }, |
| 968 | { 0x5036, "exif:ThumbnailPrimaryChromaticities" }, |
| 969 | { 0x5037, "exif:ThumbnailYCbCrCoefficients" }, |
| 970 | { 0x5038, "exif:ThumbnailYCbCrSubsampling" }, |
| 971 | { 0x5039, "exif:ThumbnailYCbCrPositioning" }, |
| 972 | { 0x503A, "exif:ThumbnailRefBlackWhite" }, |
| 973 | { 0x503B, "exif:ThumbnailCopyRight" }, |
| 974 | { 0x5090, "exif:LuminanceTable" }, |
| 975 | { 0x5091, "exif:ChrominanceTable" }, |
| 976 | { 0x5100, "exif:FrameDelay" }, |
| 977 | { 0x5101, "exif:LoopCount" }, |
| 978 | { 0x5110, "exif:PixelUnit" }, |
| 979 | { 0x5111, "exif:PixelPerUnitX" }, |
| 980 | { 0x5112, "exif:PixelPerUnitY" }, |
| 981 | { 0x5113, "exif:PaletteHistogram" }, |
| 982 | { 0x1000, "exif:RelatedImageFileFormat" }, |
| 983 | { 0x1001, "exif:RelatedImageLength" }, |
| 984 | { 0x1002, "exif:RelatedImageWidth" }, |
| 985 | { 0x800d, "exif:ImageID" }, |
| 986 | { 0x80e3, "exif:Matteing" }, |
| 987 | { 0x80e4, "exif:DataType" }, |
| 988 | { 0x80e5, "exif:ImageDepth" }, |
| 989 | { 0x80e6, "exif:TileDepth" }, |
| 990 | { 0x828d, "exif:CFARepeatPatternDim" }, |
| 991 | { 0x828e, "exif:CFAPattern2" }, |
| 992 | { 0x828f, "exif:BatteryLevel" }, |
| 993 | { 0x8298, "exif:Copyright" }, |
| 994 | { 0x829a, "exif:ExposureTime" }, |
| 995 | { 0x829d, "exif:FNumber" }, |
| 996 | { 0x83bb, "exif:IPTC/NAA" }, |
| 997 | { 0x84e3, "exif:IT8RasterPadding" }, |
| 998 | { 0x84e5, "exif:IT8ColorTable" }, |
| 999 | { 0x8649, "exif:ImageResourceInformation" }, |
| 1000 | { 0x8769, "exif:ExifOffset" }, |
| 1001 | { 0x8773, "exif:InterColorProfile" }, |
| 1002 | { 0x8822, "exif:ExposureProgram" }, |
| 1003 | { 0x8824, "exif:SpectralSensitivity" }, |
| 1004 | { 0x8825, "exif:GPSInfo" }, |
| 1005 | { 0x8827, "exif:ISOSpeedRatings" }, |
| 1006 | { 0x8828, "exif:OECF" }, |
| 1007 | { 0x8829, "exif:Interlace" }, |
| 1008 | { 0x882a, "exif:TimeZoneOffset" }, |
| 1009 | { 0x882b, "exif:SelfTimerMode" }, |
| 1010 | { 0x9000, "exif:ExifVersion" }, |
| 1011 | { 0x9003, "exif:DateTimeOriginal" }, |
| 1012 | { 0x9004, "exif:DateTimeDigitized" }, |
| 1013 | { 0x9101, "exif:ComponentsConfiguration" }, |
| 1014 | { 0x9102, "exif:CompressedBitsPerPixel" }, |
| 1015 | { 0x9201, "exif:ShutterSpeedValue" }, |
| 1016 | { 0x9202, "exif:ApertureValue" }, |
| 1017 | { 0x9203, "exif:BrightnessValue" }, |
| 1018 | { 0x9204, "exif:ExposureBiasValue" }, |
| 1019 | { 0x9205, "exif:MaxApertureValue" }, |
| 1020 | { 0x9206, "exif:SubjectDistance" }, |
| 1021 | { 0x9207, "exif:MeteringMode" }, |
| 1022 | { 0x9208, "exif:LightSource" }, |
| 1023 | { 0x9209, "exif:Flash" }, |
| 1024 | { 0x920a, "exif:FocalLength" }, |
| 1025 | { 0x920b, "exif:FlashEnergy" }, |
| 1026 | { 0x920c, "exif:SpatialFrequencyResponse" }, |
| 1027 | { 0x920d, "exif:Noise" }, |
| 1028 | { 0x9211, "exif:ImageNumber" }, |
| 1029 | { 0x9212, "exif:SecurityClassification" }, |
| 1030 | { 0x9213, "exif:ImageHistory" }, |
| 1031 | { 0x9214, "exif:SubjectArea" }, |
| 1032 | { 0x9215, "exif:ExposureIndex" }, |
| 1033 | { 0x9216, "exif:TIFF-EPStandardID" }, |
| 1034 | { 0x927c, "exif:MakerNote" }, |
| 1035 | { 0x9C9b, "exif:WinXP-Title" }, |
| 1036 | { 0x9C9c, "exif:WinXP-Comments" }, |
| 1037 | { 0x9C9d, "exif:WinXP-Author" }, |
| 1038 | { 0x9C9e, "exif:WinXP-Keywords" }, |
| 1039 | { 0x9C9f, "exif:WinXP-Subject" }, |
| 1040 | { 0x9286, "exif:UserComment" }, |
| 1041 | { 0x9290, "exif:SubSecTime" }, |
| 1042 | { 0x9291, "exif:SubSecTimeOriginal" }, |
| 1043 | { 0x9292, "exif:SubSecTimeDigitized" }, |
| 1044 | { 0xa000, "exif:FlashPixVersion" }, |
| 1045 | { 0xa001, "exif:ColorSpace" }, |
| 1046 | { 0xa002, "exif:ExifImageWidth" }, |
| 1047 | { 0xa003, "exif:ExifImageLength" }, |
| 1048 | { 0xa004, "exif:RelatedSoundFile" }, |
| 1049 | { 0xa005, "exif:InteroperabilityOffset" }, |
| 1050 | { 0xa20b, "exif:FlashEnergy" }, |
| 1051 | { 0xa20c, "exif:SpatialFrequencyResponse" }, |
| 1052 | { 0xa20d, "exif:Noise" }, |
| 1053 | { 0xa20e, "exif:FocalPlaneXResolution" }, |
| 1054 | { 0xa20f, "exif:FocalPlaneYResolution" }, |
| 1055 | { 0xa210, "exif:FocalPlaneResolutionUnit" }, |
| 1056 | { 0xa214, "exif:SubjectLocation" }, |
| 1057 | { 0xa215, "exif:ExposureIndex" }, |
| 1058 | { 0xa216, "exif:TIFF/EPStandardID" }, |
| 1059 | { 0xa217, "exif:SensingMethod" }, |
| 1060 | { 0xa300, "exif:FileSource" }, |
| 1061 | { 0xa301, "exif:SceneType" }, |
| 1062 | { 0xa302, "exif:CFAPattern" }, |
| 1063 | { 0xa401, "exif:CustomRendered" }, |
| 1064 | { 0xa402, "exif:ExposureMode" }, |
| 1065 | { 0xa403, "exif:WhiteBalance" }, |
| 1066 | { 0xa404, "exif:DigitalZoomRatio" }, |
| 1067 | { 0xa405, "exif:FocalLengthIn35mmFilm" }, |
| 1068 | { 0xa406, "exif:SceneCaptureType" }, |
| 1069 | { 0xa407, "exif:GainControl" }, |
| 1070 | { 0xa408, "exif:Contrast" }, |
| 1071 | { 0xa409, "exif:Saturation" }, |
| 1072 | { 0xa40a, "exif:Sharpness" }, |
| 1073 | { 0xa40b, "exif:DeviceSettingDescription" }, |
| 1074 | { 0xa40c, "exif:SubjectDistanceRange" }, |
| 1075 | { 0xa420, "exif:ImageUniqueID" }, |
| 1076 | { 0xc4a5, "exif:PrintImageMatching" }, |
cristy | b3fea0e | 2009-11-28 01:46:20 +0000 | [diff] [blame] | 1077 | { 0xa500, "exif:Gamma" }, |
| 1078 | { 0xc640, "exif:CR2Slice" }, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1079 | { 0x10000, "exif:GPSVersionID" }, |
| 1080 | { 0x10001, "exif:GPSLatitudeRef" }, |
| 1081 | { 0x10002, "exif:GPSLatitude" }, |
| 1082 | { 0x10003, "exif:GPSLongitudeRef" }, |
| 1083 | { 0x10004, "exif:GPSLongitude" }, |
| 1084 | { 0x10005, "exif:GPSAltitudeRef" }, |
| 1085 | { 0x10006, "exif:GPSAltitude" }, |
| 1086 | { 0x10007, "exif:GPSTimeStamp" }, |
| 1087 | { 0x10008, "exif:GPSSatellites" }, |
| 1088 | { 0x10009, "exif:GPSStatus" }, |
| 1089 | { 0x1000a, "exif:GPSMeasureMode" }, |
| 1090 | { 0x1000b, "exif:GPSDop" }, |
| 1091 | { 0x1000c, "exif:GPSSpeedRef" }, |
| 1092 | { 0x1000d, "exif:GPSSpeed" }, |
| 1093 | { 0x1000e, "exif:GPSTrackRef" }, |
| 1094 | { 0x1000f, "exif:GPSTrack" }, |
| 1095 | { 0x10010, "exif:GPSImgDirectionRef" }, |
| 1096 | { 0x10011, "exif:GPSImgDirection" }, |
| 1097 | { 0x10012, "exif:GPSMapDatum" }, |
| 1098 | { 0x10013, "exif:GPSDestLatitudeRef" }, |
| 1099 | { 0x10014, "exif:GPSDestLatitude" }, |
| 1100 | { 0x10015, "exif:GPSDestLongitudeRef" }, |
| 1101 | { 0x10016, "exif:GPSDestLongitude" }, |
| 1102 | { 0x10017, "exif:GPSDestBearingRef" }, |
| 1103 | { 0x10018, "exif:GPSDestBearing" }, |
| 1104 | { 0x10019, "exif:GPSDestDistanceRef" }, |
| 1105 | { 0x1001a, "exif:GPSDestDistance" }, |
| 1106 | { 0x1001b, "exif:GPSProcessingMethod" }, |
| 1107 | { 0x1001c, "exif:GPSAreaInformation" }, |
| 1108 | { 0x1001d, "exif:GPSDateStamp" }, |
| 1109 | { 0x1001e, "exif:GPSDifferential" }, |
cristy | 6e617e6 | 2012-09-29 14:12:23 +0000 | [diff] [blame] | 1110 | { 0x00000, (const char *) NULL } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1111 | }; |
| 1112 | |
| 1113 | const StringInfo |
| 1114 | *profile; |
| 1115 | |
| 1116 | const unsigned char |
| 1117 | *directory, |
| 1118 | *exif; |
| 1119 | |
| 1120 | DirectoryInfo |
| 1121 | directory_stack[MaxDirectoryStack]; |
| 1122 | |
| 1123 | EndianType |
| 1124 | endian; |
| 1125 | |
cristy | 929ea32 | 2011-02-21 15:21:35 +0000 | [diff] [blame] | 1126 | MagickBooleanType |
| 1127 | status; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1128 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1129 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1130 | i; |
| 1131 | |
| 1132 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1133 | entry, |
cristy | 929ea32 | 2011-02-21 15:21:35 +0000 | [diff] [blame] | 1134 | length, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1135 | number_entries, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1136 | tag; |
| 1137 | |
cristy | 142ab01 | 2012-02-02 02:26:18 +0000 | [diff] [blame] | 1138 | SplayTreeInfo |
| 1139 | *exif_resources; |
| 1140 | |
cristy | 929ea32 | 2011-02-21 15:21:35 +0000 | [diff] [blame] | 1141 | ssize_t |
| 1142 | all, |
| 1143 | id, |
| 1144 | level, |
| 1145 | offset, |
cristy | 3d8d1f1 | 2012-02-29 01:59:28 +0000 | [diff] [blame] | 1146 | tag_offset, |
cristy | 929ea32 | 2011-02-21 15:21:35 +0000 | [diff] [blame] | 1147 | tag_value; |
| 1148 | |
| 1149 | static int |
| 1150 | tag_bytes[] = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8}; |
| 1151 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1152 | /* |
| 1153 | If EXIF data exists, then try to parse the request for a tag. |
| 1154 | */ |
| 1155 | profile=GetImageProfile(image,"exif"); |
cristy | d5fc531 | 2015-02-19 12:28:37 +0000 | [diff] [blame] | 1156 | if (profile == (const StringInfo *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1157 | return(MagickFalse); |
| 1158 | if ((property == (const char *) NULL) || (*property == '\0')) |
| 1159 | return(MagickFalse); |
| 1160 | while (isspace((int) ((unsigned char) *property)) != 0) |
| 1161 | property++; |
cristy | d5fc531 | 2015-02-19 12:28:37 +0000 | [diff] [blame] | 1162 | if (strlen(property) <= 5) |
| 1163 | return(MagickFalse); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1164 | all=0; |
| 1165 | tag=(~0UL); |
| 1166 | switch (*(property+5)) |
| 1167 | { |
| 1168 | case '*': |
| 1169 | { |
| 1170 | /* |
| 1171 | Caller has asked for all the tags in the EXIF data. |
| 1172 | */ |
| 1173 | tag=0; |
| 1174 | all=1; /* return the data in description=value format */ |
| 1175 | break; |
| 1176 | } |
| 1177 | case '!': |
| 1178 | { |
| 1179 | tag=0; |
| 1180 | all=2; /* return the data in tagid=value format */ |
| 1181 | break; |
| 1182 | } |
| 1183 | case '#': |
| 1184 | case '@': |
| 1185 | { |
| 1186 | int |
| 1187 | c; |
| 1188 | |
| 1189 | size_t |
| 1190 | n; |
| 1191 | |
| 1192 | /* |
| 1193 | Check for a hex based tag specification first. |
| 1194 | */ |
| 1195 | tag=(*(property+5) == '@') ? 1UL : 0UL; |
| 1196 | property+=6; |
| 1197 | n=strlen(property); |
| 1198 | if (n != 4) |
| 1199 | return(MagickFalse); |
| 1200 | /* |
| 1201 | Parse tag specification as a hex number. |
| 1202 | */ |
| 1203 | n/=4; |
| 1204 | do |
| 1205 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1206 | for (i=(ssize_t) n-1L; i >= 0; i--) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1207 | { |
| 1208 | c=(*property++); |
| 1209 | tag<<=4; |
| 1210 | if ((c >= '0') && (c <= '9')) |
| 1211 | tag|=(c-'0'); |
| 1212 | else |
| 1213 | if ((c >= 'A') && (c <= 'F')) |
| 1214 | tag|=(c-('A'-10)); |
| 1215 | else |
| 1216 | if ((c >= 'a') && (c <= 'f')) |
| 1217 | tag|=(c-('a'-10)); |
| 1218 | else |
| 1219 | return(MagickFalse); |
| 1220 | } |
| 1221 | } while (*property != '\0'); |
| 1222 | break; |
| 1223 | } |
| 1224 | default: |
| 1225 | { |
| 1226 | /* |
| 1227 | Try to match the text with a tag name instead. |
| 1228 | */ |
| 1229 | for (i=0; ; i++) |
| 1230 | { |
| 1231 | if (EXIFTag[i].tag == 0) |
| 1232 | break; |
| 1233 | if (LocaleCompare(EXIFTag[i].description,property) == 0) |
| 1234 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1235 | tag=(size_t) EXIFTag[i].tag; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1236 | break; |
| 1237 | } |
| 1238 | } |
| 1239 | break; |
| 1240 | } |
| 1241 | } |
| 1242 | if (tag == (~0UL)) |
| 1243 | return(MagickFalse); |
| 1244 | length=GetStringInfoLength(profile); |
| 1245 | exif=GetStringInfoDatum(profile); |
| 1246 | while (length != 0) |
| 1247 | { |
| 1248 | if (ReadPropertyByte(&exif,&length) != 0x45) |
| 1249 | continue; |
| 1250 | if (ReadPropertyByte(&exif,&length) != 0x78) |
| 1251 | continue; |
| 1252 | if (ReadPropertyByte(&exif,&length) != 0x69) |
| 1253 | continue; |
| 1254 | if (ReadPropertyByte(&exif,&length) != 0x66) |
| 1255 | continue; |
| 1256 | if (ReadPropertyByte(&exif,&length) != 0x00) |
| 1257 | continue; |
| 1258 | if (ReadPropertyByte(&exif,&length) != 0x00) |
| 1259 | continue; |
| 1260 | break; |
| 1261 | } |
| 1262 | if (length < 16) |
| 1263 | return(MagickFalse); |
cristy | f069667 | 2012-02-01 23:43:06 +0000 | [diff] [blame] | 1264 | id=(ssize_t) ((int) ReadPropertyShort(LSBEndian,exif)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1265 | endian=LSBEndian; |
| 1266 | if (id == 0x4949) |
| 1267 | endian=LSBEndian; |
| 1268 | else |
| 1269 | if (id == 0x4D4D) |
| 1270 | endian=MSBEndian; |
| 1271 | else |
| 1272 | return(MagickFalse); |
| 1273 | if (ReadPropertyShort(endian,exif+2) != 0x002a) |
| 1274 | return(MagickFalse); |
| 1275 | /* |
| 1276 | This the offset to the first IFD. |
| 1277 | */ |
cristy | 55a91cd | 2010-12-01 00:57:40 +0000 | [diff] [blame] | 1278 | offset=(ssize_t) ((int) ReadPropertyLong(endian,exif+4)); |
cristy | 64de157 | 2012-02-29 02:44:11 +0000 | [diff] [blame] | 1279 | if ((offset < 0) || (size_t) offset >= length) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1280 | return(MagickFalse); |
| 1281 | /* |
| 1282 | Set the pointer to the first IFD and follow it were it leads. |
| 1283 | */ |
cristy | 929ea32 | 2011-02-21 15:21:35 +0000 | [diff] [blame] | 1284 | status=MagickFalse; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1285 | directory=exif+offset; |
| 1286 | level=0; |
| 1287 | entry=0; |
| 1288 | tag_offset=0; |
cristy | 142ab01 | 2012-02-02 02:26:18 +0000 | [diff] [blame] | 1289 | exif_resources=NewSplayTree((int (*)(const void *,const void *)) NULL, |
| 1290 | (void *(*)(void *)) NULL,(void *(*)(void *)) NULL); |
| 1291 | do |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1292 | { |
| 1293 | /* |
| 1294 | If there is anything on the stack then pop it off. |
| 1295 | */ |
| 1296 | if (level > 0) |
| 1297 | { |
| 1298 | level--; |
| 1299 | directory=directory_stack[level].directory; |
| 1300 | entry=directory_stack[level].entry; |
| 1301 | tag_offset=directory_stack[level].offset; |
| 1302 | } |
cristy | d5fc531 | 2015-02-19 12:28:37 +0000 | [diff] [blame] | 1303 | if ((directory < exif) || (directory > (exif+length-2))) |
| 1304 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1305 | /* |
| 1306 | Determine how many entries there are in the current IFD. |
| 1307 | */ |
cristy | 4a8b017 | 2012-02-03 16:39:53 +0000 | [diff] [blame] | 1308 | number_entries=(size_t) ((int) ReadPropertyShort(endian,directory)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1309 | for ( ; entry < number_entries; entry++) |
| 1310 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1311 | register unsigned char |
| 1312 | *p, |
| 1313 | *q; |
| 1314 | |
| 1315 | size_t |
anthony | 90ebc0d | 2012-04-28 08:10:02 +0000 | [diff] [blame] | 1316 | format; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1317 | |
cristy | 9d314ff | 2011-03-09 01:30:28 +0000 | [diff] [blame] | 1318 | ssize_t |
anthony | 90ebc0d | 2012-04-28 08:10:02 +0000 | [diff] [blame] | 1319 | number_bytes, |
cristy | 9d314ff | 2011-03-09 01:30:28 +0000 | [diff] [blame] | 1320 | components; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1321 | |
cristy | f069667 | 2012-02-01 23:43:06 +0000 | [diff] [blame] | 1322 | q=(unsigned char *) (directory+(12*entry)+2); |
cristy | 142ab01 | 2012-02-02 02:26:18 +0000 | [diff] [blame] | 1323 | if (GetValueFromSplayTree(exif_resources,q) == q) |
| 1324 | break; |
| 1325 | (void) AddValueToSplayTree(exif_resources,q,q); |
cristy | f069667 | 2012-02-01 23:43:06 +0000 | [diff] [blame] | 1326 | tag_value=(ssize_t) ((int) ReadPropertyShort(endian,q)+tag_offset); |
| 1327 | format=(size_t) ((int) ReadPropertyShort(endian,q+2)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1328 | if (format >= (sizeof(tag_bytes)/sizeof(*tag_bytes))) |
| 1329 | break; |
cristy | 55a91cd | 2010-12-01 00:57:40 +0000 | [diff] [blame] | 1330 | components=(ssize_t) ((int) ReadPropertyLong(endian,q+4)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1331 | number_bytes=(size_t) components*tag_bytes[format]; |
cristy | 5f06bc1 | 2012-04-03 12:47:36 +0000 | [diff] [blame] | 1332 | if (number_bytes < components) |
| 1333 | break; /* prevent overflow */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1334 | if (number_bytes <= 4) |
| 1335 | p=q+8; |
| 1336 | else |
| 1337 | { |
| 1338 | ssize_t |
| 1339 | offset; |
| 1340 | |
| 1341 | /* |
| 1342 | The directory entry contains an offset. |
| 1343 | */ |
cristy | 55a91cd | 2010-12-01 00:57:40 +0000 | [diff] [blame] | 1344 | offset=(ssize_t) ((int) ReadPropertyLong(endian,q+8)); |
cristy | dca8d58 | 2014-10-29 15:53:19 +0000 | [diff] [blame] | 1345 | if ((offset < 0) || (size_t) offset >= length) |
| 1346 | continue; |
anthony | 90ebc0d | 2012-04-28 08:10:02 +0000 | [diff] [blame] | 1347 | if ((ssize_t) (offset+number_bytes) < offset) |
| 1348 | continue; /* prevent overflow */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1349 | if ((size_t) (offset+number_bytes) > length) |
| 1350 | continue; |
| 1351 | p=(unsigned char *) (exif+offset); |
| 1352 | } |
cristy | 90e72a0 | 2012-09-29 01:08:57 +0000 | [diff] [blame] | 1353 | if ((all != 0) || (tag == (size_t) tag_value)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1354 | { |
| 1355 | char |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1356 | buffer[MagickPathExtent], |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1357 | *value; |
| 1358 | |
cristy | 7ad8a13 | 2012-03-28 22:42:29 +0000 | [diff] [blame] | 1359 | value=(char *) NULL; |
| 1360 | *buffer='\0'; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1361 | switch (format) |
| 1362 | { |
| 1363 | case EXIF_FMT_BYTE: |
| 1364 | case EXIF_FMT_UNDEFINED: |
| 1365 | { |
cristy | 13adad0 | 2011-08-16 19:22:15 +0000 | [diff] [blame] | 1366 | EXIFMultipleValues(1,"%.20g",(double) (*(unsigned char *) p1)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1367 | break; |
| 1368 | } |
| 1369 | case EXIF_FMT_SBYTE: |
| 1370 | { |
cristy | e8c25f9 | 2010-06-03 00:53:06 +0000 | [diff] [blame] | 1371 | EXIFMultipleValues(1,"%.20g",(double) (*(signed char *) p1)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1372 | break; |
| 1373 | } |
| 1374 | case EXIF_FMT_SSHORT: |
| 1375 | { |
| 1376 | EXIFMultipleValues(2,"%hd",ReadPropertyShort(endian,p1)); |
| 1377 | break; |
| 1378 | } |
| 1379 | case EXIF_FMT_USHORT: |
| 1380 | { |
| 1381 | EXIFMultipleValues(2,"%hu",ReadPropertyShort(endian,p1)); |
| 1382 | break; |
| 1383 | } |
| 1384 | case EXIF_FMT_ULONG: |
| 1385 | { |
cristy | e8c25f9 | 2010-06-03 00:53:06 +0000 | [diff] [blame] | 1386 | EXIFMultipleValues(4,"%.20g",(double) |
cristy | 4a8b017 | 2012-02-03 16:39:53 +0000 | [diff] [blame] | 1387 | ((int) ReadPropertyLong(endian,p1))); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1388 | break; |
| 1389 | } |
| 1390 | case EXIF_FMT_SLONG: |
| 1391 | { |
cristy | e8c25f9 | 2010-06-03 00:53:06 +0000 | [diff] [blame] | 1392 | EXIFMultipleValues(4,"%.20g",(double) |
cristy | 96ea486 | 2011-11-22 00:45:47 +0000 | [diff] [blame] | 1393 | ((int) ReadPropertyLong(endian,p1))); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1394 | break; |
| 1395 | } |
| 1396 | case EXIF_FMT_URATIONAL: |
| 1397 | { |
cristy | e8c25f9 | 2010-06-03 00:53:06 +0000 | [diff] [blame] | 1398 | EXIFMultipleFractions(8,"%.20g/%.20g",(double) |
cristy | f069667 | 2012-02-01 23:43:06 +0000 | [diff] [blame] | 1399 | ((int) ReadPropertyLong(endian,p1)),(double) |
| 1400 | ((int) ReadPropertyLong(endian,p1+4))); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1401 | break; |
| 1402 | } |
| 1403 | case EXIF_FMT_SRATIONAL: |
| 1404 | { |
cristy | e8c25f9 | 2010-06-03 00:53:06 +0000 | [diff] [blame] | 1405 | EXIFMultipleFractions(8,"%.20g/%.20g",(double) |
cristy | 96ea486 | 2011-11-22 00:45:47 +0000 | [diff] [blame] | 1406 | ((int) ReadPropertyLong(endian,p1)),(double) |
| 1407 | ((int) ReadPropertyLong(endian,p1+4))); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1408 | break; |
| 1409 | } |
| 1410 | case EXIF_FMT_SINGLE: |
| 1411 | { |
| 1412 | EXIFMultipleValues(4,"%f",(double) *(float *) p1); |
| 1413 | break; |
| 1414 | } |
| 1415 | case EXIF_FMT_DOUBLE: |
| 1416 | { |
| 1417 | EXIFMultipleValues(8,"%f",*(double *) p1); |
| 1418 | break; |
| 1419 | } |
| 1420 | default: |
| 1421 | case EXIF_FMT_STRING: |
| 1422 | { |
| 1423 | value=(char *) NULL; |
cristy | 9c66d8c | 2012-08-10 11:05:36 +0000 | [diff] [blame] | 1424 | if (~((size_t) number_bytes) >= 1) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1425 | value=(char *) AcquireQuantumMemory((size_t) number_bytes+1UL, |
| 1426 | sizeof(*value)); |
| 1427 | if (value != (char *) NULL) |
| 1428 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1429 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1430 | i; |
| 1431 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1432 | for (i=0; i < (ssize_t) number_bytes; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1433 | { |
| 1434 | value[i]='.'; |
| 1435 | if ((isprint((int) p[i]) != 0) || (p[i] == '\0')) |
| 1436 | value[i]=(char) p[i]; |
| 1437 | } |
| 1438 | value[i]='\0'; |
| 1439 | } |
| 1440 | break; |
| 1441 | } |
| 1442 | } |
| 1443 | if (value != (char *) NULL) |
| 1444 | { |
| 1445 | char |
cristy | 6e617e6 | 2012-09-29 14:12:23 +0000 | [diff] [blame] | 1446 | *key; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1447 | |
| 1448 | register const char |
| 1449 | *p; |
| 1450 | |
cristy | 6e617e6 | 2012-09-29 14:12:23 +0000 | [diff] [blame] | 1451 | key=AcquireString(property); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1452 | switch (all) |
| 1453 | { |
| 1454 | case 1: |
| 1455 | { |
| 1456 | const char |
| 1457 | *description; |
| 1458 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1459 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1460 | i; |
| 1461 | |
| 1462 | description="unknown"; |
| 1463 | for (i=0; ; i++) |
| 1464 | { |
| 1465 | if (EXIFTag[i].tag == 0) |
| 1466 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1467 | if ((ssize_t) EXIFTag[i].tag == tag_value) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1468 | { |
| 1469 | description=EXIFTag[i].description; |
| 1470 | break; |
| 1471 | } |
| 1472 | } |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1473 | (void) FormatLocaleString(key,MagickPathExtent,"%s",description); |
dirk | e1c4ce4 | 2014-12-30 19:47:47 +0000 | [diff] [blame] | 1474 | if (level == 2) |
| 1475 | (void) SubstituteString(&key,"exif:","exif:thumbnail:"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1476 | break; |
| 1477 | } |
| 1478 | case 2: |
| 1479 | { |
| 1480 | if (tag_value < 0x10000) |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1481 | (void) FormatLocaleString(key,MagickPathExtent,"#%04lx", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 1482 | (unsigned long) tag_value); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1483 | else |
| 1484 | if (tag_value < 0x20000) |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1485 | (void) FormatLocaleString(key,MagickPathExtent,"@%04lx", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 1486 | (unsigned long) (tag_value & 0xffff)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1487 | else |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1488 | (void) FormatLocaleString(key,MagickPathExtent,"unknown"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1489 | break; |
| 1490 | } |
dirk | e1c4ce4 | 2014-12-30 19:47:47 +0000 | [diff] [blame] | 1491 | default: |
| 1492 | { |
| 1493 | if (level == 2) |
| 1494 | (void) SubstituteString(&key,"exif:","exif:thumbnail:"); |
| 1495 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1496 | } |
| 1497 | p=(const char *) NULL; |
| 1498 | if (image->properties != (void *) NULL) |
| 1499 | p=(const char *) GetValueFromSplayTree((SplayTreeInfo *) |
| 1500 | image->properties,key); |
| 1501 | if (p == (const char *) NULL) |
cristy | d15e659 | 2011-10-15 00:13:06 +0000 | [diff] [blame] | 1502 | (void) SetImageProperty((Image *) image,key,value,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1503 | value=DestroyString(value); |
cristy | 6e617e6 | 2012-09-29 14:12:23 +0000 | [diff] [blame] | 1504 | key=DestroyString(key); |
cristy | 929ea32 | 2011-02-21 15:21:35 +0000 | [diff] [blame] | 1505 | status=MagickTrue; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1506 | } |
| 1507 | } |
| 1508 | if ((tag_value == TAG_EXIF_OFFSET) || |
cristy | 4a8b017 | 2012-02-03 16:39:53 +0000 | [diff] [blame] | 1509 | (tag_value == TAG_INTEROP_OFFSET) || (tag_value == TAG_GPS_OFFSET)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1510 | { |
cristy | 3d8d1f1 | 2012-02-29 01:59:28 +0000 | [diff] [blame] | 1511 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1512 | offset; |
| 1513 | |
cristy | 3d8d1f1 | 2012-02-29 01:59:28 +0000 | [diff] [blame] | 1514 | offset=(ssize_t) ((int) ReadPropertyLong(endian,p)); |
| 1515 | if (((size_t) offset < length) && (level < (MaxDirectoryStack-2))) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1516 | { |
cristy | 3d8d1f1 | 2012-02-29 01:59:28 +0000 | [diff] [blame] | 1517 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1518 | tag_offset1; |
| 1519 | |
cristy | 3d8d1f1 | 2012-02-29 01:59:28 +0000 | [diff] [blame] | 1520 | tag_offset1=(ssize_t) ((tag_value == TAG_GPS_OFFSET) ? 0x10000 : |
| 1521 | 0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1522 | directory_stack[level].directory=directory; |
| 1523 | entry++; |
| 1524 | directory_stack[level].entry=entry; |
| 1525 | directory_stack[level].offset=tag_offset; |
| 1526 | level++; |
| 1527 | directory_stack[level].directory=exif+offset; |
| 1528 | directory_stack[level].offset=tag_offset1; |
| 1529 | directory_stack[level].entry=0; |
| 1530 | level++; |
| 1531 | if ((directory+2+(12*number_entries)) > (exif+length)) |
| 1532 | break; |
cristy | 3d8d1f1 | 2012-02-29 01:59:28 +0000 | [diff] [blame] | 1533 | offset=(ssize_t) ((int) ReadPropertyLong(endian,directory+2+(12* |
cristy | 4a8b017 | 2012-02-03 16:39:53 +0000 | [diff] [blame] | 1534 | number_entries))); |
cristy | 3d8d1f1 | 2012-02-29 01:59:28 +0000 | [diff] [blame] | 1535 | if ((offset != 0) && ((size_t) offset < length) && |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1536 | (level < (MaxDirectoryStack-2))) |
| 1537 | { |
| 1538 | directory_stack[level].directory=exif+offset; |
| 1539 | directory_stack[level].entry=0; |
| 1540 | directory_stack[level].offset=tag_offset1; |
| 1541 | level++; |
| 1542 | } |
| 1543 | } |
| 1544 | break; |
| 1545 | } |
| 1546 | } |
cristy | 142ab01 | 2012-02-02 02:26:18 +0000 | [diff] [blame] | 1547 | } while (level > 0); |
| 1548 | exif_resources=DestroySplayTree(exif_resources); |
cristy | 929ea32 | 2011-02-21 15:21:35 +0000 | [diff] [blame] | 1549 | return(status); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1550 | } |
| 1551 | |
cristy | 920a0e7 | 2014-01-24 14:20:14 +0000 | [diff] [blame] | 1552 | static MagickBooleanType GetICCProperty(const Image *image,const char *property, |
cristy | 5516632 | 2014-01-23 01:53:24 +0000 | [diff] [blame] | 1553 | ExceptionInfo *exception) |
| 1554 | { |
| 1555 | const StringInfo |
| 1556 | *profile; |
| 1557 | |
cristy | 920a0e7 | 2014-01-24 14:20:14 +0000 | [diff] [blame] | 1558 | magick_unreferenced(property); |
cristy | 65c88e9 | 2014-01-24 14:15:27 +0000 | [diff] [blame] | 1559 | |
cristy | 5516632 | 2014-01-23 01:53:24 +0000 | [diff] [blame] | 1560 | profile=GetImageProfile(image,"icc"); |
| 1561 | if (profile == (StringInfo *) NULL) |
| 1562 | profile=GetImageProfile(image,"icm"); |
| 1563 | if (profile == (StringInfo *) NULL) |
| 1564 | return(MagickFalse); |
cristy | 89da59a | 2014-02-02 19:54:09 +0000 | [diff] [blame] | 1565 | if (GetStringInfoLength(profile) < 128) |
| 1566 | return(MagickFalse); /* minimum ICC profile length */ |
cristy | 5516632 | 2014-01-23 01:53:24 +0000 | [diff] [blame] | 1567 | #if defined(MAGICKCORE_LCMS_DELEGATE) |
| 1568 | { |
| 1569 | cmsHPROFILE |
| 1570 | icc_profile; |
| 1571 | |
| 1572 | icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile), |
| 1573 | (cmsUInt32Number) GetStringInfoLength(profile)); |
| 1574 | if (icc_profile != (cmsHPROFILE *) NULL) |
| 1575 | { |
| 1576 | #if defined(LCMS_VERSION) && (LCMS_VERSION < 2000) |
| 1577 | const char |
| 1578 | *name; |
| 1579 | |
| 1580 | name=cmsTakeProductName(icc_profile); |
| 1581 | if (name != (const char *) NULL) |
| 1582 | (void) SetImageProperty((Image *) image,"icc:name",name,exception); |
| 1583 | #else |
| 1584 | char |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1585 | info[MagickPathExtent]; |
cristy | 5516632 | 2014-01-23 01:53:24 +0000 | [diff] [blame] | 1586 | |
| 1587 | (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription, |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1588 | "en","US",info,MagickPathExtent); |
cristy | 5516632 | 2014-01-23 01:53:24 +0000 | [diff] [blame] | 1589 | (void) SetImageProperty((Image *) image,"icc:description",info, |
| 1590 | exception); |
| 1591 | (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoManufacturer, |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1592 | "en","US",info,MagickPathExtent); |
cristy | 5516632 | 2014-01-23 01:53:24 +0000 | [diff] [blame] | 1593 | (void) SetImageProperty((Image *) image,"icc:manufacturer",info, |
| 1594 | exception); |
| 1595 | (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoModel,"en", |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1596 | "US",info,MagickPathExtent); |
cristy | 5516632 | 2014-01-23 01:53:24 +0000 | [diff] [blame] | 1597 | (void) SetImageProperty((Image *) image,"icc:model",info,exception); |
| 1598 | (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoCopyright, |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1599 | "en","US",info,MagickPathExtent); |
cristy | 5516632 | 2014-01-23 01:53:24 +0000 | [diff] [blame] | 1600 | (void) SetImageProperty((Image *) image,"icc:copyright",info,exception); |
| 1601 | #endif |
| 1602 | (void) cmsCloseProfile(icc_profile); |
| 1603 | } |
| 1604 | } |
| 1605 | #endif |
| 1606 | return(MagickTrue); |
| 1607 | } |
| 1608 | |
dirk | 90d6896 | 2014-05-23 11:11:17 +0000 | [diff] [blame] | 1609 | static MagickBooleanType SkipXMPValue(const char *value) |
| 1610 | { |
| 1611 | if (value == (const char*) NULL) |
| 1612 | return(MagickTrue); |
cristy | e905419 | 2014-09-24 11:53:14 +0000 | [diff] [blame] | 1613 | while (*value != '\0') |
dirk | 90d6896 | 2014-05-23 11:11:17 +0000 | [diff] [blame] | 1614 | { |
cristy | e905419 | 2014-09-24 11:53:14 +0000 | [diff] [blame] | 1615 | if (isspace((int) ((unsigned char) *value)) == 0) |
dirk | 90d6896 | 2014-05-23 11:11:17 +0000 | [diff] [blame] | 1616 | return(MagickFalse); |
| 1617 | value++; |
| 1618 | } |
dirk | 90d6896 | 2014-05-23 11:11:17 +0000 | [diff] [blame] | 1619 | return(MagickTrue); |
| 1620 | } |
| 1621 | |
cristy | 13adad0 | 2011-08-16 19:22:15 +0000 | [diff] [blame] | 1622 | static MagickBooleanType GetXMPProperty(const Image *image,const char *property) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1623 | { |
| 1624 | char |
| 1625 | *xmp_profile; |
| 1626 | |
dirk | 90d6896 | 2014-05-23 11:11:17 +0000 | [diff] [blame] | 1627 | const char |
| 1628 | *content; |
| 1629 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1630 | const StringInfo |
| 1631 | *profile; |
| 1632 | |
| 1633 | ExceptionInfo |
| 1634 | *exception; |
| 1635 | |
| 1636 | MagickBooleanType |
| 1637 | status; |
| 1638 | |
| 1639 | register const char |
| 1640 | *p; |
| 1641 | |
| 1642 | XMLTreeInfo |
| 1643 | *child, |
| 1644 | *description, |
| 1645 | *node, |
| 1646 | *rdf, |
| 1647 | *xmp; |
| 1648 | |
| 1649 | profile=GetImageProfile(image,"xmp"); |
| 1650 | if (profile == (StringInfo *) NULL) |
| 1651 | return(MagickFalse); |
| 1652 | if ((property == (const char *) NULL) || (*property == '\0')) |
| 1653 | return(MagickFalse); |
| 1654 | xmp_profile=StringInfoToString(profile); |
| 1655 | if (xmp_profile == (char *) NULL) |
| 1656 | return(MagickFalse); |
| 1657 | for (p=xmp_profile; *p != '\0'; p++) |
| 1658 | if ((*p == '<') && (*(p+1) == 'x')) |
| 1659 | break; |
| 1660 | exception=AcquireExceptionInfo(); |
| 1661 | xmp=NewXMLTree((char *) p,exception); |
| 1662 | xmp_profile=DestroyString(xmp_profile); |
| 1663 | exception=DestroyExceptionInfo(exception); |
| 1664 | if (xmp == (XMLTreeInfo *) NULL) |
| 1665 | return(MagickFalse); |
| 1666 | status=MagickFalse; |
| 1667 | rdf=GetXMLTreeChild(xmp,"rdf:RDF"); |
| 1668 | if (rdf != (XMLTreeInfo *) NULL) |
| 1669 | { |
| 1670 | if (image->properties == (void *) NULL) |
| 1671 | ((Image *) image)->properties=NewSplayTree(CompareSplayTreeString, |
| 1672 | RelinquishMagickMemory,RelinquishMagickMemory); |
| 1673 | description=GetXMLTreeChild(rdf,"rdf:Description"); |
| 1674 | while (description != (XMLTreeInfo *) NULL) |
| 1675 | { |
| 1676 | node=GetXMLTreeChild(description,(const char *) NULL); |
| 1677 | while (node != (XMLTreeInfo *) NULL) |
| 1678 | { |
| 1679 | child=GetXMLTreeChild(node,(const char *) NULL); |
dirk | 90d6896 | 2014-05-23 11:11:17 +0000 | [diff] [blame] | 1680 | content=GetXMLTreeContent(node); |
cristy | 9745ca8 | 2014-05-23 20:10:13 +0000 | [diff] [blame] | 1681 | if ((child == (XMLTreeInfo *) NULL) && |
| 1682 | (SkipXMPValue(content) == MagickFalse)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1683 | (void) AddValueToSplayTree((SplayTreeInfo *) image->properties, |
cristy | 9745ca8 | 2014-05-23 20:10:13 +0000 | [diff] [blame] | 1684 | ConstantString(GetXMLTreeTag(node)),ConstantString(content)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1685 | while (child != (XMLTreeInfo *) NULL) |
| 1686 | { |
dirk | 90d6896 | 2014-05-23 11:11:17 +0000 | [diff] [blame] | 1687 | content=GetXMLTreeContent(child); |
| 1688 | if (SkipXMPValue(content) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1689 | (void) AddValueToSplayTree((SplayTreeInfo *) image->properties, |
cristy | 9745ca8 | 2014-05-23 20:10:13 +0000 | [diff] [blame] | 1690 | ConstantString(GetXMLTreeTag(child)),ConstantString(content)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1691 | child=GetXMLTreeSibling(child); |
| 1692 | } |
| 1693 | node=GetXMLTreeSibling(node); |
| 1694 | } |
| 1695 | description=GetNextXMLTreeTag(description); |
| 1696 | } |
| 1697 | } |
| 1698 | xmp=DestroyXMLTree(xmp); |
| 1699 | return(status); |
| 1700 | } |
| 1701 | |
| 1702 | static char *TracePSClippath(const unsigned char *blob,size_t length, |
cristy | f5d0a1a | 2012-02-03 12:33:10 +0000 | [diff] [blame] | 1703 | const size_t magick_unused(columns),const size_t magick_unused(rows)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1704 | { |
| 1705 | char |
| 1706 | *path, |
| 1707 | *message; |
| 1708 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1709 | MagickBooleanType |
| 1710 | in_subpath; |
| 1711 | |
| 1712 | PointInfo |
| 1713 | first[3], |
| 1714 | last[3], |
| 1715 | point[3]; |
| 1716 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1717 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1718 | i, |
| 1719 | x; |
| 1720 | |
cristy | 9d314ff | 2011-03-09 01:30:28 +0000 | [diff] [blame] | 1721 | ssize_t |
| 1722 | knot_count, |
| 1723 | selector, |
| 1724 | y; |
| 1725 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1726 | path=AcquireString((char *) NULL); |
| 1727 | if (path == (char *) NULL) |
| 1728 | return((char *) NULL); |
| 1729 | message=AcquireString((char *) NULL); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1730 | (void) FormatLocaleString(message,MagickPathExtent,"/ClipImage\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1731 | (void) ConcatenateString(&path,message); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1732 | (void) FormatLocaleString(message,MagickPathExtent,"{\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1733 | (void) ConcatenateString(&path,message); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1734 | (void) FormatLocaleString(message,MagickPathExtent," /c {curveto} bind def\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1735 | (void) ConcatenateString(&path,message); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1736 | (void) FormatLocaleString(message,MagickPathExtent," /l {lineto} bind def\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1737 | (void) ConcatenateString(&path,message); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1738 | (void) FormatLocaleString(message,MagickPathExtent," /m {moveto} bind def\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1739 | (void) ConcatenateString(&path,message); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1740 | (void) FormatLocaleString(message,MagickPathExtent, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1741 | " /v {currentpoint 6 2 roll curveto} bind def\n"); |
| 1742 | (void) ConcatenateString(&path,message); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1743 | (void) FormatLocaleString(message,MagickPathExtent, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1744 | " /y {2 copy curveto} bind def\n"); |
| 1745 | (void) ConcatenateString(&path,message); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1746 | (void) FormatLocaleString(message,MagickPathExtent, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1747 | " /z {closepath} bind def\n"); |
| 1748 | (void) ConcatenateString(&path,message); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1749 | (void) FormatLocaleString(message,MagickPathExtent," newpath\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1750 | (void) ConcatenateString(&path,message); |
| 1751 | /* |
| 1752 | The clipping path format is defined in "Adobe Photoshop File |
| 1753 | Formats Specification" version 6.0 downloadable from adobe.com. |
| 1754 | */ |
| 1755 | (void) ResetMagickMemory(point,0,sizeof(point)); |
| 1756 | (void) ResetMagickMemory(first,0,sizeof(first)); |
| 1757 | (void) ResetMagickMemory(last,0,sizeof(last)); |
| 1758 | knot_count=0; |
| 1759 | in_subpath=MagickFalse; |
| 1760 | while (length > 0) |
| 1761 | { |
cristy | 4a8b017 | 2012-02-03 16:39:53 +0000 | [diff] [blame] | 1762 | selector=(ssize_t) ((int) ReadPropertyMSBShort(&blob,&length)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1763 | switch (selector) |
| 1764 | { |
| 1765 | case 0: |
| 1766 | case 3: |
| 1767 | { |
| 1768 | if (knot_count != 0) |
| 1769 | { |
| 1770 | blob+=24; |
cristy | 4a8b017 | 2012-02-03 16:39:53 +0000 | [diff] [blame] | 1771 | length-=MagickMin(24,(ssize_t) length); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1772 | break; |
| 1773 | } |
| 1774 | /* |
| 1775 | Expected subpath length record. |
| 1776 | */ |
cristy | 4a8b017 | 2012-02-03 16:39:53 +0000 | [diff] [blame] | 1777 | knot_count=(ssize_t) ((int) ReadPropertyMSBShort(&blob,&length)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1778 | blob+=22; |
cristy | 4a8b017 | 2012-02-03 16:39:53 +0000 | [diff] [blame] | 1779 | length-=MagickMin(22,(ssize_t) length); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1780 | break; |
| 1781 | } |
| 1782 | case 1: |
| 1783 | case 2: |
| 1784 | case 4: |
| 1785 | case 5: |
| 1786 | { |
| 1787 | if (knot_count == 0) |
| 1788 | { |
| 1789 | /* |
| 1790 | Unexpected subpath knot |
| 1791 | */ |
| 1792 | blob+=24; |
cristy | 4a8b017 | 2012-02-03 16:39:53 +0000 | [diff] [blame] | 1793 | length-=MagickMin(24,(ssize_t) length); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1794 | break; |
| 1795 | } |
| 1796 | /* |
| 1797 | Add sub-path knot |
| 1798 | */ |
| 1799 | for (i=0; i < 3; i++) |
| 1800 | { |
cristy | 13b9a2e | 2010-11-10 14:03:51 +0000 | [diff] [blame] | 1801 | size_t |
cristy | 9743320 | 2009-10-27 02:05:08 +0000 | [diff] [blame] | 1802 | xx, |
| 1803 | yy; |
| 1804 | |
cristy | 4a8b017 | 2012-02-03 16:39:53 +0000 | [diff] [blame] | 1805 | yy=(size_t) ((int) ReadPropertyMSBLong(&blob,&length)); |
| 1806 | xx=(size_t) ((int) ReadPropertyMSBLong(&blob,&length)); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1807 | x=(ssize_t) xx; |
cristy | 9743320 | 2009-10-27 02:05:08 +0000 | [diff] [blame] | 1808 | if (xx > 2147483647) |
cristy | 17df857 | 2011-05-25 16:39:58 +0000 | [diff] [blame] | 1809 | x=(ssize_t) xx-4294967295U-1; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1810 | y=(ssize_t) yy; |
cristy | 9743320 | 2009-10-27 02:05:08 +0000 | [diff] [blame] | 1811 | if (yy > 2147483647) |
cristy | 17df857 | 2011-05-25 16:39:58 +0000 | [diff] [blame] | 1812 | y=(ssize_t) yy-4294967295U-1; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1813 | point[i].x=(double) x/4096/4096; |
| 1814 | point[i].y=1.0-(double) y/4096/4096; |
| 1815 | } |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 1816 | if( IfMagickFalse(in_subpath) ) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1817 | { |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1818 | (void) FormatLocaleString(message,MagickPathExtent," %g %g m\n", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1819 | point[1].x,point[1].y); |
| 1820 | for (i=0; i < 3; i++) |
| 1821 | { |
| 1822 | first[i]=point[i]; |
| 1823 | last[i]=point[i]; |
| 1824 | } |
| 1825 | } |
| 1826 | else |
| 1827 | { |
| 1828 | /* |
| 1829 | Handle special cases when Bezier curves are used to describe |
| 1830 | corners and straight lines. |
| 1831 | */ |
| 1832 | if ((last[1].x == last[2].x) && (last[1].y == last[2].y) && |
| 1833 | (point[0].x == point[1].x) && (point[0].y == point[1].y)) |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1834 | (void) FormatLocaleString(message,MagickPathExtent, |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 1835 | " %g %g l\n",point[1].x,point[1].y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1836 | else |
| 1837 | if ((last[1].x == last[2].x) && (last[1].y == last[2].y)) |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1838 | (void) FormatLocaleString(message,MagickPathExtent, |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 1839 | " %g %g %g %g v\n",point[0].x,point[0].y, |
cristy | 8cd5b31 | 2010-01-07 01:10:24 +0000 | [diff] [blame] | 1840 | point[1].x,point[1].y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1841 | else |
| 1842 | if ((point[0].x == point[1].x) && (point[0].y == point[1].y)) |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1843 | (void) FormatLocaleString(message,MagickPathExtent, |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 1844 | " %g %g %g %g y\n",last[2].x,last[2].y, |
cristy | 8cd5b31 | 2010-01-07 01:10:24 +0000 | [diff] [blame] | 1845 | point[1].x,point[1].y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1846 | else |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1847 | (void) FormatLocaleString(message,MagickPathExtent, |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 1848 | " %g %g %g %g %g %g c\n",last[2].x, |
cristy | 8cd5b31 | 2010-01-07 01:10:24 +0000 | [diff] [blame] | 1849 | last[2].y,point[0].x,point[0].y,point[1].x,point[1].y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1850 | for (i=0; i < 3; i++) |
| 1851 | last[i]=point[i]; |
| 1852 | } |
| 1853 | (void) ConcatenateString(&path,message); |
| 1854 | in_subpath=MagickTrue; |
| 1855 | knot_count--; |
| 1856 | /* |
| 1857 | Close the subpath if there are no more knots. |
| 1858 | */ |
| 1859 | if (knot_count == 0) |
| 1860 | { |
| 1861 | /* |
| 1862 | Same special handling as above except we compare to the |
| 1863 | first point in the path and close the path. |
| 1864 | */ |
| 1865 | if ((last[1].x == last[2].x) && (last[1].y == last[2].y) && |
| 1866 | (first[0].x == first[1].x) && (first[0].y == first[1].y)) |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1867 | (void) FormatLocaleString(message,MagickPathExtent, |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 1868 | " %g %g l z\n",first[1].x,first[1].y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1869 | else |
| 1870 | if ((last[1].x == last[2].x) && (last[1].y == last[2].y)) |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1871 | (void) FormatLocaleString(message,MagickPathExtent, |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 1872 | " %g %g %g %g v z\n",first[0].x,first[0].y, |
cristy | 8cd5b31 | 2010-01-07 01:10:24 +0000 | [diff] [blame] | 1873 | first[1].x,first[1].y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1874 | else |
| 1875 | if ((first[0].x == first[1].x) && (first[0].y == first[1].y)) |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1876 | (void) FormatLocaleString(message,MagickPathExtent, |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 1877 | " %g %g %g %g y z\n",last[2].x,last[2].y, |
cristy | 8cd5b31 | 2010-01-07 01:10:24 +0000 | [diff] [blame] | 1878 | first[1].x,first[1].y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1879 | else |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1880 | (void) FormatLocaleString(message,MagickPathExtent, |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 1881 | " %g %g %g %g %g %g c z\n",last[2].x, |
cristy | 8cd5b31 | 2010-01-07 01:10:24 +0000 | [diff] [blame] | 1882 | last[2].y,first[0].x,first[0].y,first[1].x,first[1].y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1883 | (void) ConcatenateString(&path,message); |
| 1884 | in_subpath=MagickFalse; |
| 1885 | } |
| 1886 | break; |
| 1887 | } |
| 1888 | case 6: |
| 1889 | case 7: |
| 1890 | case 8: |
| 1891 | default: |
| 1892 | { |
| 1893 | blob+=24; |
cristy | 4a8b017 | 2012-02-03 16:39:53 +0000 | [diff] [blame] | 1894 | length-=MagickMin(24,(ssize_t) length); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1895 | break; |
| 1896 | } |
| 1897 | } |
| 1898 | } |
| 1899 | /* |
| 1900 | Returns an empty PS path if the path has no knots. |
| 1901 | */ |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1902 | (void) FormatLocaleString(message,MagickPathExtent," eoclip\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1903 | (void) ConcatenateString(&path,message); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1904 | (void) FormatLocaleString(message,MagickPathExtent,"} bind def"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1905 | (void) ConcatenateString(&path,message); |
| 1906 | message=DestroyString(message); |
| 1907 | return(path); |
| 1908 | } |
| 1909 | |
| 1910 | static char *TraceSVGClippath(const unsigned char *blob,size_t length, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1911 | const size_t columns,const size_t rows) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1912 | { |
| 1913 | char |
| 1914 | *path, |
| 1915 | *message; |
| 1916 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1917 | MagickBooleanType |
| 1918 | in_subpath; |
| 1919 | |
| 1920 | PointInfo |
| 1921 | first[3], |
| 1922 | last[3], |
| 1923 | point[3]; |
| 1924 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1925 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1926 | i; |
| 1927 | |
cristy | 9d314ff | 2011-03-09 01:30:28 +0000 | [diff] [blame] | 1928 | ssize_t |
| 1929 | knot_count, |
| 1930 | selector, |
| 1931 | x, |
| 1932 | y; |
| 1933 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1934 | path=AcquireString((char *) NULL); |
| 1935 | if (path == (char *) NULL) |
| 1936 | return((char *) NULL); |
| 1937 | message=AcquireString((char *) NULL); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1938 | (void) FormatLocaleString(message,MagickPathExtent, |
dirk | eba89a3 | 2014-07-19 09:26:27 +0000 | [diff] [blame] | 1939 | ("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n" |
| 1940 | "<svg xmlns=\"http://www.w3.org/2000/svg\"" |
| 1941 | " width=\"%.20g\" height=\"%.20g\">\n" |
| 1942 | "<g>\n" |
| 1943 | "<path fill-rule=\"evenodd\" style=\"fill:#00000000;stroke:#00000000;" |
| 1944 | "stroke-width:0;stroke-antialiasing:false\" d=\"\n"), |
| 1945 | (double) columns,(double) rows); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1946 | (void) ConcatenateString(&path,message); |
| 1947 | (void) ResetMagickMemory(point,0,sizeof(point)); |
| 1948 | (void) ResetMagickMemory(first,0,sizeof(first)); |
| 1949 | (void) ResetMagickMemory(last,0,sizeof(last)); |
| 1950 | knot_count=0; |
| 1951 | in_subpath=MagickFalse; |
| 1952 | while (length != 0) |
| 1953 | { |
cristy | 4a8b017 | 2012-02-03 16:39:53 +0000 | [diff] [blame] | 1954 | selector=(ssize_t) ((int) ReadPropertyMSBShort(&blob,&length)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1955 | switch (selector) |
| 1956 | { |
| 1957 | case 0: |
| 1958 | case 3: |
| 1959 | { |
| 1960 | if (knot_count != 0) |
| 1961 | { |
| 1962 | blob+=24; |
cristy | 4a8b017 | 2012-02-03 16:39:53 +0000 | [diff] [blame] | 1963 | length-=MagickMin(24,(ssize_t) length); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1964 | break; |
| 1965 | } |
| 1966 | /* |
| 1967 | Expected subpath length record. |
| 1968 | */ |
cristy | 4a8b017 | 2012-02-03 16:39:53 +0000 | [diff] [blame] | 1969 | knot_count=(ssize_t) ((int) ReadPropertyMSBShort(&blob,&length)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1970 | blob+=22; |
cristy | 4a8b017 | 2012-02-03 16:39:53 +0000 | [diff] [blame] | 1971 | length-=MagickMin(22,(ssize_t) length); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1972 | break; |
| 1973 | } |
| 1974 | case 1: |
| 1975 | case 2: |
| 1976 | case 4: |
| 1977 | case 5: |
| 1978 | { |
| 1979 | if (knot_count == 0) |
| 1980 | { |
| 1981 | /* |
| 1982 | Unexpected subpath knot. |
| 1983 | */ |
| 1984 | blob+=24; |
cristy | 4a8b017 | 2012-02-03 16:39:53 +0000 | [diff] [blame] | 1985 | length-=MagickMin(24,(ssize_t) length); |
cristy | 9743320 | 2009-10-27 02:05:08 +0000 | [diff] [blame] | 1986 | break; |
| 1987 | } |
| 1988 | /* |
| 1989 | Add sub-path knot |
| 1990 | */ |
| 1991 | for (i=0; i < 3; i++) |
| 1992 | { |
dirk | 68bd1b5 | 2014-08-28 18:58:23 +0000 | [diff] [blame] | 1993 | unsigned int |
cristy | 9743320 | 2009-10-27 02:05:08 +0000 | [diff] [blame] | 1994 | xx, |
| 1995 | yy; |
| 1996 | |
dirk | 68bd1b5 | 2014-08-28 18:58:23 +0000 | [diff] [blame] | 1997 | yy=(unsigned int) ((int) ReadPropertyMSBLong(&blob,&length)); |
| 1998 | xx=(unsigned int) ((int) ReadPropertyMSBLong(&blob,&length)); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1999 | x=(ssize_t) xx; |
cristy | 9743320 | 2009-10-27 02:05:08 +0000 | [diff] [blame] | 2000 | if (xx > 2147483647) |
cristy | 17df857 | 2011-05-25 16:39:58 +0000 | [diff] [blame] | 2001 | x=(ssize_t) xx-4294967295U-1; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2002 | y=(ssize_t) yy; |
cristy | 9743320 | 2009-10-27 02:05:08 +0000 | [diff] [blame] | 2003 | if (yy > 2147483647) |
cristy | 17df857 | 2011-05-25 16:39:58 +0000 | [diff] [blame] | 2004 | y=(ssize_t) yy-4294967295U-1; |
cristy | 9743320 | 2009-10-27 02:05:08 +0000 | [diff] [blame] | 2005 | point[i].x=(double) x*columns/4096/4096; |
| 2006 | point[i].y=(double) y*rows/4096/4096; |
| 2007 | } |
cristy | f516f2f | 2014-01-07 01:29:28 +0000 | [diff] [blame] | 2008 | if (in_subpath == MagickFalse) |
cristy | 9743320 | 2009-10-27 02:05:08 +0000 | [diff] [blame] | 2009 | { |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2010 | (void) FormatLocaleString(message,MagickPathExtent,"M %g %g\n", |
cristy | 9743320 | 2009-10-27 02:05:08 +0000 | [diff] [blame] | 2011 | point[1].x,point[1].y); |
| 2012 | for (i=0; i < 3; i++) |
| 2013 | { |
| 2014 | first[i]=point[i]; |
| 2015 | last[i]=point[i]; |
| 2016 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2017 | } |
| 2018 | else |
| 2019 | { |
cristy | 9eb1847 | 2013-11-11 14:55:48 +0000 | [diff] [blame] | 2020 | /* |
| 2021 | Handle special cases when Bezier curves are used to describe |
| 2022 | corners and straight lines. |
| 2023 | */ |
cristy | 9743320 | 2009-10-27 02:05:08 +0000 | [diff] [blame] | 2024 | if ((last[1].x == last[2].x) && (last[1].y == last[2].y) && |
| 2025 | (point[0].x == point[1].x) && (point[0].y == point[1].y)) |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2026 | (void) FormatLocaleString(message,MagickPathExtent, |
cristy | f516f2f | 2014-01-07 01:29:28 +0000 | [diff] [blame] | 2027 | "L %g %g\n",point[1].x,point[1].y); |
cristy | 9eb1847 | 2013-11-11 14:55:48 +0000 | [diff] [blame] | 2028 | else |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2029 | (void) FormatLocaleString(message,MagickPathExtent, |
dirk | d8c3286 | 2014-09-18 22:01:17 +0000 | [diff] [blame] | 2030 | "C %g %g %g %g %g %g\n",last[2].x, |
| 2031 | last[2].y,point[0].x,point[0].y,point[1].x,point[1].y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2032 | for (i=0; i < 3; i++) |
cristy | 9743320 | 2009-10-27 02:05:08 +0000 | [diff] [blame] | 2033 | last[i]=point[i]; |
| 2034 | } |
| 2035 | (void) ConcatenateString(&path,message); |
| 2036 | in_subpath=MagickTrue; |
| 2037 | knot_count--; |
| 2038 | /* |
| 2039 | Close the subpath if there are no more knots. |
| 2040 | */ |
| 2041 | if (knot_count == 0) |
| 2042 | { |
cristy | 9eb1847 | 2013-11-11 14:55:48 +0000 | [diff] [blame] | 2043 | /* |
| 2044 | Same special handling as above except we compare to the |
| 2045 | first point in the path and close the path. |
| 2046 | */ |
cristy | 9743320 | 2009-10-27 02:05:08 +0000 | [diff] [blame] | 2047 | if ((last[1].x == last[2].x) && (last[1].y == last[2].y) && |
| 2048 | (first[0].x == first[1].x) && (first[0].y == first[1].y)) |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2049 | (void) FormatLocaleString(message,MagickPathExtent, |
cristy | f516f2f | 2014-01-07 01:29:28 +0000 | [diff] [blame] | 2050 | "L %g %g Z\n",first[1].x,first[1].y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2051 | else |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2052 | (void) FormatLocaleString(message,MagickPathExtent, |
dirk | d8c3286 | 2014-09-18 22:01:17 +0000 | [diff] [blame] | 2053 | "C %g %g %g %g %g %g Z\n",last[2].x, |
| 2054 | last[2].y,first[0].x,first[0].y,first[1].x,first[1].y); |
cristy | 9eb1847 | 2013-11-11 14:55:48 +0000 | [diff] [blame] | 2055 | (void) ConcatenateString(&path,message); |
cristy | 9743320 | 2009-10-27 02:05:08 +0000 | [diff] [blame] | 2056 | in_subpath=MagickFalse; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2057 | } |
cristy | 9743320 | 2009-10-27 02:05:08 +0000 | [diff] [blame] | 2058 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2059 | } |
| 2060 | case 6: |
| 2061 | case 7: |
| 2062 | case 8: |
| 2063 | default: |
| 2064 | { |
| 2065 | blob+=24; |
cristy | 4a8b017 | 2012-02-03 16:39:53 +0000 | [diff] [blame] | 2066 | length-=MagickMin(24,(ssize_t) length); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2067 | break; |
| 2068 | } |
| 2069 | } |
| 2070 | } |
| 2071 | /* |
| 2072 | Return an empty SVG image if the path does not have knots. |
| 2073 | */ |
dirk | eba89a3 | 2014-07-19 09:26:27 +0000 | [diff] [blame] | 2074 | (void) ConcatenateString(&path,"\"/>\n</g>\n</svg>\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2075 | message=DestroyString(message); |
| 2076 | return(path); |
| 2077 | } |
| 2078 | |
| 2079 | MagickExport const char *GetImageProperty(const Image *image, |
cristy | d15e659 | 2011-10-15 00:13:06 +0000 | [diff] [blame] | 2080 | const char *property,ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2081 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2082 | register const char |
| 2083 | *p; |
| 2084 | |
| 2085 | assert(image != (Image *) NULL); |
cristy | e1c94d9 | 2015-06-28 12:16:33 +0000 | [diff] [blame] | 2086 | assert(image->signature == MagickCoreSignature); |
cristy | 8c8d3f5 | 2014-02-14 02:22:14 +0000 | [diff] [blame] | 2087 | if (IfMagickTrue(image->debug)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2088 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 2089 | p=(const char *) NULL; |
cristy | 27f7af2 | 2010-06-21 12:23:21 +0000 | [diff] [blame] | 2090 | if (image->properties != (void *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2091 | { |
cristy | 5eb9fc8 | 2011-02-21 15:05:41 +0000 | [diff] [blame] | 2092 | if (property == (const char *) NULL) |
| 2093 | { |
| 2094 | ResetSplayTreeIterator((SplayTreeInfo *) image->properties); |
| 2095 | p=(const char *) GetNextValueInSplayTree((SplayTreeInfo *) |
| 2096 | image->properties); |
| 2097 | return(p); |
| 2098 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2099 | p=(const char *) GetValueFromSplayTree((SplayTreeInfo *) |
| 2100 | image->properties,property); |
| 2101 | if (p != (const char *) NULL) |
| 2102 | return(p); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2103 | } |
cristy | 5eb9fc8 | 2011-02-21 15:05:41 +0000 | [diff] [blame] | 2104 | if ((property == (const char *) NULL) || |
| 2105 | (strchr(property,':') == (char *) NULL)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2106 | return(p); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2107 | switch (*property) |
| 2108 | { |
| 2109 | case '8': |
| 2110 | { |
| 2111 | if (LocaleNCompare("8bim:",property,5) == 0) |
| 2112 | { |
cristy | 8c8d3f5 | 2014-02-14 02:22:14 +0000 | [diff] [blame] | 2113 | (void) Get8BIMProperty(image,property,exception); |
| 2114 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2115 | } |
| 2116 | break; |
| 2117 | } |
| 2118 | case 'E': |
| 2119 | case 'e': |
| 2120 | { |
| 2121 | if (LocaleNCompare("exif:",property,5) == 0) |
| 2122 | { |
cristy | 8c8d3f5 | 2014-02-14 02:22:14 +0000 | [diff] [blame] | 2123 | (void) GetEXIFProperty(image,property,exception); |
| 2124 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2125 | } |
| 2126 | break; |
| 2127 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2128 | case 'I': |
| 2129 | case 'i': |
| 2130 | { |
cristy | 5516632 | 2014-01-23 01:53:24 +0000 | [diff] [blame] | 2131 | if ((LocaleNCompare("icc:",property,4) == 0) || |
| 2132 | (LocaleNCompare("icm:",property,4) == 0)) |
| 2133 | { |
cristy | 8c8d3f5 | 2014-02-14 02:22:14 +0000 | [diff] [blame] | 2134 | (void) GetICCProperty(image,property,exception); |
| 2135 | break; |
cristy | 5516632 | 2014-01-23 01:53:24 +0000 | [diff] [blame] | 2136 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2137 | if (LocaleNCompare("iptc:",property,5) == 0) |
| 2138 | { |
cristy | 8c8d3f5 | 2014-02-14 02:22:14 +0000 | [diff] [blame] | 2139 | (void) GetIPTCProperty(image,property,exception); |
| 2140 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2141 | } |
| 2142 | break; |
| 2143 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2144 | case 'X': |
| 2145 | case 'x': |
| 2146 | { |
| 2147 | if (LocaleNCompare("xmp:",property,4) == 0) |
| 2148 | { |
cristy | 8c8d3f5 | 2014-02-14 02:22:14 +0000 | [diff] [blame] | 2149 | (void) GetXMPProperty(image,property); |
| 2150 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2151 | } |
| 2152 | break; |
| 2153 | } |
cristy | 5eb9fc8 | 2011-02-21 15:05:41 +0000 | [diff] [blame] | 2154 | default: |
| 2155 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2156 | } |
cristy | 8c8d3f5 | 2014-02-14 02:22:14 +0000 | [diff] [blame] | 2157 | if (image->properties != (void *) NULL) |
| 2158 | { |
| 2159 | p=(const char *) GetValueFromSplayTree((SplayTreeInfo *) |
| 2160 | image->properties,property); |
| 2161 | return(p); |
| 2162 | } |
| 2163 | return((const char *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2164 | } |
cristy | f516f2f | 2014-01-07 01:29:28 +0000 | [diff] [blame] | 2165 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2166 | /* |
| 2167 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2168 | % % |
| 2169 | % % |
| 2170 | % % |
| 2171 | + G e t M a g i c k P r o p e r t y % |
| 2172 | % % |
| 2173 | % % |
| 2174 | % % |
| 2175 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2176 | % |
anthony | 0676223 | 2012-04-29 11:45:40 +0000 | [diff] [blame] | 2177 | % GetMagickProperty() gets attributes or calculated values that is associated |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2178 | % with a fixed known property name, or single letter property. It may be |
anthony | db2a1d6 | 2013-04-29 01:34:58 +0000 | [diff] [blame] | 2179 | % called if no image is defined (IMv7), in which case only global image_info |
cristy | 934c77d | 2014-12-14 20:14:16 +0000 | [diff] [blame] | 2180 | % values are available: |
| 2181 | % |
| 2182 | % \n newline |
| 2183 | % \r carriage return |
| 2184 | % < less-than character. |
| 2185 | % > greater-than character. |
| 2186 | % & ampersand character. |
| 2187 | % %% a percent sign |
| 2188 | % %b file size of image read in |
| 2189 | % %c comment meta-data property |
| 2190 | % %d directory component of path |
| 2191 | % %e filename extension or suffix |
| 2192 | % %f filename (including suffix) |
| 2193 | % %g layer canvas page geometry (equivalent to "%Wx%H%X%Y") |
| 2194 | % %h current image height in pixels |
| 2195 | % %i image filename (note: becomes output filename for "info:") |
| 2196 | % %k CALCULATED: number of unique colors |
| 2197 | % %l label meta-data property |
| 2198 | % %m image file format (file magic) |
| 2199 | % %n number of images in current image sequence |
| 2200 | % %o output filename (used for delegates) |
| 2201 | % %p index of image in current image list |
| 2202 | % %q quantum depth (compile-time constant) |
| 2203 | % %r image class and colorspace |
| 2204 | % %s scene number (from input unless re-assigned) |
| 2205 | % %t filename without directory or extension (suffix) |
| 2206 | % %u unique temporary filename (used for delegates) |
| 2207 | % %w current width in pixels |
| 2208 | % %x x resolution (density) |
| 2209 | % %y y resolution (density) |
| 2210 | % %z image depth (as read in unless modified, image save depth) |
| 2211 | % %A image transparency channel enabled (true/false) |
| 2212 | % %C image compression type |
| 2213 | % %D image GIF dispose method |
| 2214 | % %G original image size (%wx%h; before any resizes) |
| 2215 | % %H page (canvas) height |
| 2216 | % %M Magick filename (original file exactly as given, including read mods) |
| 2217 | % %O page (canvas) offset ( = %X%Y ) |
| 2218 | % %P page (canvas) size ( = %Wx%H ) |
| 2219 | % %Q image compression quality ( 0 = default ) |
| 2220 | % %S ?? scenes ?? |
| 2221 | % %T image time delay (in centi-seconds) |
| 2222 | % %U image resolution units |
| 2223 | % %W page (canvas) width |
| 2224 | % %X page (canvas) x offset (including sign) |
| 2225 | % %Y page (canvas) y offset (including sign) |
| 2226 | % %Z unique filename (used for delegates) |
| 2227 | % %@ CALCULATED: trim bounding box (without actually trimming) |
| 2228 | % %# CALCULATED: 'signature' hash of image values |
anthony | 0676223 | 2012-04-29 11:45:40 +0000 | [diff] [blame] | 2229 | % |
anthony | db2a1d6 | 2013-04-29 01:34:58 +0000 | [diff] [blame] | 2230 | % This routine only handles specifically known properties. It does not |
| 2231 | % handle special prefixed properties, profiles, or expressions. Nor does |
| 2232 | % it return any free-form property strings. |
anthony | 0676223 | 2012-04-29 11:45:40 +0000 | [diff] [blame] | 2233 | % |
anthony | db2a1d6 | 2013-04-29 01:34:58 +0000 | [diff] [blame] | 2234 | % The returned string is stored in a structure somewhere, and should not be |
| 2235 | % directly freed. If the string was generated (common) the string will be |
| 2236 | % stored as as either as artifact or option 'get-property'. These may be |
| 2237 | % deleted (cleaned up) when no longer required, but neither artifact or |
| 2238 | % option is guranteed to exist. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2239 | % |
| 2240 | % The format of the GetMagickProperty method is: |
| 2241 | % |
anthony | db2a1d6 | 2013-04-29 01:34:58 +0000 | [diff] [blame] | 2242 | % const char *GetMagickProperty(ImageInfo *image_info,Image *image, |
cristy | 97fc9f3 | 2012-06-13 21:04:44 +0000 | [diff] [blame] | 2243 | % const char *property,ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2244 | % |
| 2245 | % A description of each parameter follows: |
| 2246 | % |
anthony | db2a1d6 | 2013-04-29 01:34:58 +0000 | [diff] [blame] | 2247 | % o image_info: the image info (optional) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2248 | % |
anthony | db2a1d6 | 2013-04-29 01:34:58 +0000 | [diff] [blame] | 2249 | % o image: the image (optional) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2250 | % |
| 2251 | % o key: the key. |
| 2252 | % |
cristy | d15e659 | 2011-10-15 00:13:06 +0000 | [diff] [blame] | 2253 | % o exception: return any errors or warnings in this structure. |
| 2254 | % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2255 | */ |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2256 | #define WarnNoImageReturn(format,arg) \ |
| 2257 | if (image == (Image *) NULL ) { \ |
| 2258 | (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning, \ |
| 2259 | "NoImageForProperty",format,arg); \ |
cristy | f432c63 | 2014-12-07 15:11:28 +0000 | [diff] [blame] | 2260 | return((const char *) NULL); \ |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2261 | } |
anthony | db2a1d6 | 2013-04-29 01:34:58 +0000 | [diff] [blame] | 2262 | #define WarnNoImageInfoReturn(format,arg) \ |
cristy | 4d246fc | 2014-01-15 22:33:44 +0000 | [diff] [blame] | 2263 | if (image_info == (ImageInfo *) NULL ) { \ |
anthony | db2a1d6 | 2013-04-29 01:34:58 +0000 | [diff] [blame] | 2264 | (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning, \ |
| 2265 | "NoImageInfoForProperty",format,arg); \ |
cristy | f432c63 | 2014-12-07 15:11:28 +0000 | [diff] [blame] | 2266 | return((const char *) NULL); \ |
anthony | db2a1d6 | 2013-04-29 01:34:58 +0000 | [diff] [blame] | 2267 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2268 | |
anthony | db2a1d6 | 2013-04-29 01:34:58 +0000 | [diff] [blame] | 2269 | static const char *GetMagickPropertyLetter(ImageInfo *image_info, |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2270 | Image *image,const char letter,ExceptionInfo *exception) |
| 2271 | { |
| 2272 | char |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2273 | value[MagickPathExtent]; /* formated string to store as a returned artifact */ |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2274 | |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 2275 | const char |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2276 | *string; /* return a string already stored somewher */ |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 2277 | |
| 2278 | if (image != (Image *) NULL && IfMagickTrue(image->debug)) |
cristy | 68064d7 | 2012-06-13 20:56:14 +0000 | [diff] [blame] | 2279 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
anthony | db2a1d6 | 2013-04-29 01:34:58 +0000 | [diff] [blame] | 2280 | else if( image_info != (ImageInfo *) NULL && IfMagickTrue(image_info->debug)) |
| 2281 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s","no-images"); |
| 2282 | |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2283 | *value='\0'; /* formatted string */ |
cristy | 68064d7 | 2012-06-13 20:56:14 +0000 | [diff] [blame] | 2284 | string=(char *) NULL; /* constant string reference */ |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2285 | |
| 2286 | /* Get properities that are directly defined by images */ |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2287 | switch (letter) |
| 2288 | { |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2289 | case 'b': /* image size read in - in bytes */ |
| 2290 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2291 | WarnNoImageReturn("\"%%%c\"",letter); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2292 | (void) FormatMagickSize(image->extent,MagickFalse,"B",MagickPathExtent, |
cristy | d4618c0 | 2015-04-14 23:54:43 +0000 | [diff] [blame] | 2293 | value); |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2294 | break; |
| 2295 | } |
anthony | 7bb7aee | 2012-05-15 00:09:16 +0000 | [diff] [blame] | 2296 | case 'c': /* image comment property - empty string by default */ |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2297 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2298 | WarnNoImageReturn("\"%%%c\"",letter); |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 2299 | string=GetImageProperty(image,"comment",exception); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2300 | if ( string == (const char *) NULL ) |
anthony | 7bb7aee | 2012-05-15 00:09:16 +0000 | [diff] [blame] | 2301 | string=""; |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2302 | break; |
| 2303 | } |
| 2304 | case 'd': /* Directory component of filename */ |
| 2305 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2306 | WarnNoImageReturn("\"%%%c\"",letter); |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2307 | GetPathComponent(image->magick_filename,HeadPath,value); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2308 | if (*value == '\0') string=""; |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2309 | break; |
| 2310 | } |
| 2311 | case 'e': /* Filename extension (suffix) of image file */ |
| 2312 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2313 | WarnNoImageReturn("\"%%%c\"",letter); |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2314 | GetPathComponent(image->magick_filename,ExtensionPath,value); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2315 | if (*value == '\0') string=""; |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2316 | break; |
| 2317 | } |
| 2318 | case 'f': /* Filename without directory component */ |
| 2319 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2320 | WarnNoImageReturn("\"%%%c\"",letter); |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2321 | GetPathComponent(image->magick_filename,TailPath,value); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2322 | if (*value == '\0') string=""; |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2323 | break; |
| 2324 | } |
| 2325 | case 'g': /* Image geometry, canvas and offset %Wx%H+%X+%Y */ |
| 2326 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2327 | WarnNoImageReturn("\"%%%c\"",letter); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2328 | (void) FormatLocaleString(value,MagickPathExtent,"%.20gx%.20g%+.20g%+.20g", |
cristy | 68064d7 | 2012-06-13 20:56:14 +0000 | [diff] [blame] | 2329 | (double) image->page.width,(double) image->page.height, |
| 2330 | (double) image->page.x,(double) image->page.y); |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2331 | break; |
| 2332 | } |
| 2333 | case 'h': /* Image height (current) */ |
| 2334 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2335 | WarnNoImageReturn("\"%%%c\"",letter); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2336 | (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double) |
cristy | ec6934f | 2012-08-14 18:38:40 +0000 | [diff] [blame] | 2337 | (image->rows != 0 ? image->rows : image->magick_rows)); |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2338 | break; |
| 2339 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2340 | case 'i': /* Filename last used for an image (read or write) */ |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2341 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2342 | WarnNoImageReturn("\"%%%c\"",letter); |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 2343 | string=image->filename; |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2344 | break; |
| 2345 | } |
| 2346 | case 'k': /* Number of unique colors */ |
| 2347 | { |
cristy | ec6934f | 2012-08-14 18:38:40 +0000 | [diff] [blame] | 2348 | /* |
| 2349 | FUTURE: ensure this does not generate the formatted comment! |
| 2350 | */ |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2351 | WarnNoImageReturn("\"%%%c\"",letter); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2352 | (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double) |
cristy | 68064d7 | 2012-06-13 20:56:14 +0000 | [diff] [blame] | 2353 | GetNumberColors(image,(FILE *) NULL,exception)); |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2354 | break; |
| 2355 | } |
cristy | 97fc9f3 | 2012-06-13 21:04:44 +0000 | [diff] [blame] | 2356 | case 'l': /* Image label property - empty string by default */ |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2357 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2358 | WarnNoImageReturn("\"%%%c\"",letter); |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 2359 | string=GetImageProperty(image,"label",exception); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2360 | if ( string == (const char *) NULL) |
anthony | 7bb7aee | 2012-05-15 00:09:16 +0000 | [diff] [blame] | 2361 | string=""; |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2362 | break; |
| 2363 | } |
| 2364 | case 'm': /* Image format (file magick) */ |
| 2365 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2366 | WarnNoImageReturn("\"%%%c\"",letter); |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 2367 | string=image->magick; |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2368 | break; |
| 2369 | } |
| 2370 | case 'n': /* Number of images in the list. */ |
| 2371 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2372 | if ( image != (Image *) NULL ) |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2373 | (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double) |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2374 | GetImageListLength(image)); |
| 2375 | else |
| 2376 | string="0"; /* no images or scenes */ |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2377 | break; |
| 2378 | } |
| 2379 | case 'o': /* Output Filename - for delegate use only */ |
anthony | db2a1d6 | 2013-04-29 01:34:58 +0000 | [diff] [blame] | 2380 | WarnNoImageInfoReturn("\"%%%c\"",letter); |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 2381 | string=image_info->filename; |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2382 | break; |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2383 | case 'p': /* Image index in current image list */ |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2384 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2385 | WarnNoImageReturn("\"%%%c\"",letter); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2386 | (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double) |
cristy | 68064d7 | 2012-06-13 20:56:14 +0000 | [diff] [blame] | 2387 | GetImageIndexInList(image)); |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2388 | break; |
| 2389 | } |
| 2390 | case 'q': /* Quantum depth of image in memory */ |
| 2391 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2392 | WarnNoImageReturn("\"%%%c\"",letter); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2393 | (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double) |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2394 | MAGICKCORE_QUANTUM_DEPTH); |
| 2395 | break; |
| 2396 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2397 | case 'r': /* Image storage class, colorspace, and alpha enabled. */ |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2398 | { |
| 2399 | ColorspaceType |
| 2400 | colorspace; |
| 2401 | |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2402 | WarnNoImageReturn("\"%%%c\"",letter); |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2403 | colorspace=image->colorspace; |
dirk | f1d8548 | 2015-04-06 00:36:00 +0000 | [diff] [blame] | 2404 | if (IfMagickTrue(SetImageGray(image,exception))) |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2405 | colorspace=GRAYColorspace; /* FUTURE: this is IMv6 not IMv7 */ |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2406 | (void) FormatLocaleString(value,MagickPathExtent,"%s %s %s", |
cristy | 68064d7 | 2012-06-13 20:56:14 +0000 | [diff] [blame] | 2407 | CommandOptionToMnemonic(MagickClassOptions,(ssize_t) image->storage_class), |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2408 | CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t) colorspace), |
cristy | 17f11b0 | 2014-12-20 19:37:04 +0000 | [diff] [blame] | 2409 | image->alpha_trait != UndefinedPixelTrait ? "Alpha" : ""); |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2410 | break; |
| 2411 | } |
| 2412 | case 's': /* Image scene number */ |
| 2413 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2414 | #if 0 /* this seems non-sensical -- simplifing */ |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2415 | if (image_info->number_scenes != 0) |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2416 | (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double) |
cristy | 68064d7 | 2012-06-13 20:56:14 +0000 | [diff] [blame] | 2417 | image_info->scene); |
cristy | f432c63 | 2014-12-07 15:11:28 +0000 | [diff] [blame] | 2418 | else if (image != (Image *) NULL) |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2419 | (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double) |
cristy | 68064d7 | 2012-06-13 20:56:14 +0000 | [diff] [blame] | 2420 | image->scene); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2421 | else |
| 2422 | string="0"; |
| 2423 | #else |
| 2424 | WarnNoImageReturn("\"%%%c\"",letter); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2425 | (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double) |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2426 | image->scene); |
| 2427 | #endif |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2428 | break; |
| 2429 | } |
| 2430 | case 't': /* Base filename without directory or extention */ |
| 2431 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2432 | WarnNoImageReturn("\"%%%c\"",letter); |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2433 | GetPathComponent(image->magick_filename,BasePath,value); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2434 | if (*value == '\0') string=""; |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2435 | break; |
| 2436 | } |
| 2437 | case 'u': /* Unique filename */ |
anthony | db2a1d6 | 2013-04-29 01:34:58 +0000 | [diff] [blame] | 2438 | WarnNoImageInfoReturn("\"%%%c\"",letter); |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 2439 | string=image_info->unique; |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2440 | break; |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2441 | case 'w': /* Image width (current) */ |
| 2442 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2443 | WarnNoImageReturn("\"%%%c\"",letter); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2444 | (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double) |
cristy | 68064d7 | 2012-06-13 20:56:14 +0000 | [diff] [blame] | 2445 | (image->columns != 0 ? image->columns : image->magick_columns)); |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2446 | break; |
| 2447 | } |
anthony | c69008c | 2012-05-07 11:45:32 +0000 | [diff] [blame] | 2448 | case 'x': /* Image horizontal resolution (with units) */ |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2449 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2450 | WarnNoImageReturn("\"%%%c\"",letter); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2451 | (void) FormatLocaleString(value,MagickPathExtent,"%.20g", |
cristy | ed8d785 | 2013-08-01 22:44:22 +0000 | [diff] [blame] | 2452 | fabs(image->resolution.x) > MagickEpsilon ? image->resolution.x : 72.0); |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2453 | break; |
| 2454 | } |
anthony | c69008c | 2012-05-07 11:45:32 +0000 | [diff] [blame] | 2455 | case 'y': /* Image vertical resolution (with units) */ |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2456 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2457 | WarnNoImageReturn("\"%%%c\"",letter); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2458 | (void) FormatLocaleString(value,MagickPathExtent,"%.20g", |
cristy | ed8d785 | 2013-08-01 22:44:22 +0000 | [diff] [blame] | 2459 | fabs(image->resolution.y) > MagickEpsilon ? image->resolution.y : 72.0); |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2460 | break; |
| 2461 | } |
| 2462 | case 'z': /* Image depth as read in */ |
| 2463 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2464 | WarnNoImageReturn("\"%%%c\"",letter); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2465 | (void) FormatLocaleString(value,MagickPathExtent,"%.20g", |
cristy | ed8d785 | 2013-08-01 22:44:22 +0000 | [diff] [blame] | 2466 | (double) image->depth); |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2467 | break; |
| 2468 | } |
| 2469 | case 'A': /* Image alpha channel */ |
| 2470 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2471 | WarnNoImageReturn("\"%%%c\"",letter); |
| 2472 | string=CommandOptionToMnemonic(MagickBooleanOptions, |
cristy | ed8d785 | 2013-08-01 22:44:22 +0000 | [diff] [blame] | 2473 | (ssize_t) image->alpha_trait); |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2474 | break; |
| 2475 | } |
| 2476 | case 'C': /* Image compression method. */ |
| 2477 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2478 | WarnNoImageReturn("\"%%%c\"",letter); |
| 2479 | string=CommandOptionToMnemonic(MagickCompressOptions, |
cristy | ed8d785 | 2013-08-01 22:44:22 +0000 | [diff] [blame] | 2480 | (ssize_t) image->compression); |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2481 | break; |
| 2482 | } |
| 2483 | case 'D': /* Image dispose method. */ |
| 2484 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2485 | WarnNoImageReturn("\"%%%c\"",letter); |
| 2486 | string=CommandOptionToMnemonic(MagickDisposeOptions, |
cristy | ed8d785 | 2013-08-01 22:44:22 +0000 | [diff] [blame] | 2487 | (ssize_t) image->dispose); |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2488 | break; |
| 2489 | } |
| 2490 | case 'G': /* Image size as geometry = "%wx%h" */ |
| 2491 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2492 | WarnNoImageReturn("\"%%%c\"",letter); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2493 | (void) FormatLocaleString(value,MagickPathExtent,"%.20gx%.20g", |
cristy | 68064d7 | 2012-06-13 20:56:14 +0000 | [diff] [blame] | 2494 | (double)image->magick_columns,(double) image->magick_rows); |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2495 | break; |
| 2496 | } |
| 2497 | case 'H': /* layer canvas height */ |
| 2498 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2499 | WarnNoImageReturn("\"%%%c\"",letter); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2500 | (void) FormatLocaleString(value,MagickPathExtent,"%.20g", |
cristy | ed8d785 | 2013-08-01 22:44:22 +0000 | [diff] [blame] | 2501 | (double) image->page.height); |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2502 | break; |
| 2503 | } |
| 2504 | case 'M': /* Magick filename - filename given incl. coder & read mods */ |
| 2505 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2506 | WarnNoImageReturn("\"%%%c\"",letter); |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 2507 | string=image->magick_filename; |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2508 | break; |
| 2509 | } |
| 2510 | case 'O': /* layer canvas offset with sign = "+%X+%Y" */ |
| 2511 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2512 | WarnNoImageReturn("\"%%%c\"",letter); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2513 | (void) FormatLocaleString(value,MagickPathExtent,"%+ld%+ld",(long) |
cristy | 68064d7 | 2012-06-13 20:56:14 +0000 | [diff] [blame] | 2514 | image->page.x,(long) image->page.y); |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2515 | break; |
| 2516 | } |
| 2517 | case 'P': /* layer canvas page size = "%Wx%H" */ |
| 2518 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2519 | WarnNoImageReturn("\"%%%c\"",letter); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2520 | (void) FormatLocaleString(value,MagickPathExtent,"%.20gx%.20g", |
cristy | 68064d7 | 2012-06-13 20:56:14 +0000 | [diff] [blame] | 2521 | (double) image->page.width,(double) image->page.height); |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2522 | break; |
| 2523 | } |
| 2524 | case 'Q': /* image compression quality */ |
| 2525 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2526 | WarnNoImageReturn("\"%%%c\"",letter); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2527 | (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double) |
cristy | d46a07e | 2013-08-03 23:07:04 +0000 | [diff] [blame] | 2528 | (image->quality == 0 ? 92 : image->quality)); |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2529 | break; |
| 2530 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2531 | case 'S': /* Number of scenes in image list. */ |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2532 | { |
anthony | db2a1d6 | 2013-04-29 01:34:58 +0000 | [diff] [blame] | 2533 | WarnNoImageInfoReturn("\"%%%c\"",letter); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2534 | #if 0 /* What is this number? -- it makes no sense - simplifing */ |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2535 | if (image_info->number_scenes == 0) |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2536 | string="2147483647"; |
| 2537 | else if ( image != (Image *) NULL ) |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2538 | (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double) |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2539 | image_info->scene+image_info->number_scenes); |
anthony | db2a1d6 | 2013-04-29 01:34:58 +0000 | [diff] [blame] | 2540 | else |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2541 | string="0"; |
| 2542 | #else |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2543 | (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double) |
cristy | ab5fbd8 | 2013-04-28 17:08:53 +0000 | [diff] [blame] | 2544 | (image_info->number_scenes == 0 ? 2147483647 : |
| 2545 | image_info->number_scenes)); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2546 | #endif |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2547 | break; |
| 2548 | } |
| 2549 | case 'T': /* image time delay for animations */ |
| 2550 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2551 | WarnNoImageReturn("\"%%%c\"",letter); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2552 | (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double) |
cristy | ed8d785 | 2013-08-01 22:44:22 +0000 | [diff] [blame] | 2553 | image->delay); |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2554 | break; |
| 2555 | } |
cristy | e9f6b9e | 2013-10-27 22:04:52 +0000 | [diff] [blame] | 2556 | case 'U': /* Image resolution units. */ |
| 2557 | { |
| 2558 | WarnNoImageReturn("\"%%%c\"",letter); |
| 2559 | string=CommandOptionToMnemonic(MagickResolutionOptions, |
| 2560 | (ssize_t) image->units); |
| 2561 | break; |
| 2562 | } |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2563 | case 'W': /* layer canvas width */ |
| 2564 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2565 | WarnNoImageReturn("\"%%%c\"",letter); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2566 | (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double) |
cristy | 68064d7 | 2012-06-13 20:56:14 +0000 | [diff] [blame] | 2567 | image->page.width); |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2568 | break; |
| 2569 | } |
| 2570 | case 'X': /* layer canvas X offset */ |
| 2571 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2572 | WarnNoImageReturn("\"%%%c\"",letter); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2573 | (void) FormatLocaleString(value,MagickPathExtent,"%+.20g",(double) |
cristy | 68064d7 | 2012-06-13 20:56:14 +0000 | [diff] [blame] | 2574 | image->page.x); |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2575 | break; |
| 2576 | } |
| 2577 | case 'Y': /* layer canvas Y offset */ |
| 2578 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2579 | WarnNoImageReturn("\"%%%c\"",letter); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2580 | (void) FormatLocaleString(value,MagickPathExtent,"%+.20g",(double) |
cristy | 68064d7 | 2012-06-13 20:56:14 +0000 | [diff] [blame] | 2581 | image->page.y); |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2582 | break; |
| 2583 | } |
anthony | 6e2e073 | 2012-05-06 12:22:43 +0000 | [diff] [blame] | 2584 | case 'Z': /* Zero filename ??? */ |
anthony | db2a1d6 | 2013-04-29 01:34:58 +0000 | [diff] [blame] | 2585 | WarnNoImageInfoReturn("\"%%%c\"",letter); |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 2586 | string=image_info->zero; |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2587 | break; |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2588 | case '%': /* percent escaped */ |
| 2589 | string="%"; |
| 2590 | break; |
| 2591 | case '@': /* Trim bounding box, without actually Trimming! */ |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2592 | { |
| 2593 | RectangleInfo |
| 2594 | page; |
| 2595 | |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2596 | WarnNoImageReturn("\"%%%c\"",letter); |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2597 | page=GetImageBoundingBox(image,exception); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2598 | (void) FormatLocaleString(value,MagickPathExtent,"%.20gx%.20g%+.20g%+.20g", |
cristy | 68064d7 | 2012-06-13 20:56:14 +0000 | [diff] [blame] | 2599 | (double) page.width,(double) page.height,(double) page.x,(double) |
| 2600 | page.y); |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2601 | break; |
| 2602 | } |
cristy | e5b517a | 2014-02-14 14:19:29 +0000 | [diff] [blame] | 2603 | case '#': |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2604 | { |
cristy | e5b517a | 2014-02-14 14:19:29 +0000 | [diff] [blame] | 2605 | /* |
| 2606 | Image signature. |
| 2607 | */ |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2608 | WarnNoImageReturn("\"%%%c\"",letter); |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2609 | (void) SignatureImage(image,exception); |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 2610 | string=GetImageProperty(image,"signature",exception); |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2611 | break; |
| 2612 | } |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2613 | } |
cristy | 68064d7 | 2012-06-13 20:56:14 +0000 | [diff] [blame] | 2614 | if (string != (char *) NULL) |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2615 | return(string); |
| 2616 | if (*value != '\0') |
cristy | e5b517a | 2014-02-14 14:19:29 +0000 | [diff] [blame] | 2617 | { |
| 2618 | /* |
| 2619 | Create a cloned copy of result. |
| 2620 | */ |
cristy | f432c63 | 2014-12-07 15:11:28 +0000 | [diff] [blame] | 2621 | if (image != (Image *) NULL) |
cristy | e5b517a | 2014-02-14 14:19:29 +0000 | [diff] [blame] | 2622 | { |
| 2623 | (void) SetImageArtifact(image,"get-property",value); |
| 2624 | return(GetImageArtifact(image,"get-property")); |
| 2625 | } |
| 2626 | else |
| 2627 | { |
| 2628 | (void) SetImageOption(image_info,"get-property",value); |
| 2629 | return(GetImageOption(image_info,"get-property")); |
| 2630 | } |
| 2631 | } |
cristy | f432c63 | 2014-12-07 15:11:28 +0000 | [diff] [blame] | 2632 | return((char *) NULL); |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2633 | } |
| 2634 | |
anthony | db2a1d6 | 2013-04-29 01:34:58 +0000 | [diff] [blame] | 2635 | MagickExport const char *GetMagickProperty(ImageInfo *image_info, |
cristy | d15e659 | 2011-10-15 00:13:06 +0000 | [diff] [blame] | 2636 | Image *image,const char *property,ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2637 | { |
| 2638 | char |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2639 | value[MagickPathExtent]; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2640 | |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 2641 | const char |
| 2642 | *string; |
| 2643 | |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 2644 | assert(property[0] != '\0'); |
cristy | f432c63 | 2014-12-07 15:11:28 +0000 | [diff] [blame] | 2645 | assert(image != (Image *) NULL || image_info != (ImageInfo *) NULL ); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2646 | |
cristy | 68064d7 | 2012-06-13 20:56:14 +0000 | [diff] [blame] | 2647 | if (property[1] == '\0') /* single letter property request */ |
| 2648 | return(GetMagickPropertyLetter(image_info,image,*property,exception)); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2649 | |
anthony | db2a1d6 | 2013-04-29 01:34:58 +0000 | [diff] [blame] | 2650 | if (image != (Image *) NULL && IfMagickTrue(image->debug)) |
cristy | 68064d7 | 2012-06-13 20:56:14 +0000 | [diff] [blame] | 2651 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
anthony | db2a1d6 | 2013-04-29 01:34:58 +0000 | [diff] [blame] | 2652 | else if( image_info != (ImageInfo *) NULL && IfMagickTrue(image_info->debug)) |
| 2653 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s","no-images"); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2654 | |
| 2655 | *value='\0'; /* formated string */ |
cristy | 68064d7 | 2012-06-13 20:56:14 +0000 | [diff] [blame] | 2656 | string=(char *) NULL; /* constant string reference */ |
cristy | ec6897c | 2010-05-12 00:43:15 +0000 | [diff] [blame] | 2657 | switch (*property) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2658 | { |
| 2659 | case 'b': |
| 2660 | { |
cristy | 10d5541 | 2015-02-13 21:52:54 +0000 | [diff] [blame] | 2661 | if (LocaleCompare("basename",property) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2662 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2663 | WarnNoImageReturn("\"%%[%s]\"",property); |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 2664 | GetPathComponent(image->magick_filename,BasePath,value); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2665 | if (*value == '\0') string=""; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2666 | break; |
| 2667 | } |
dirk | 2a08b06 | 2013-10-19 19:26:02 +0000 | [diff] [blame] | 2668 | if (LocaleCompare("bit-depth",property) == 0) |
| 2669 | { |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2670 | (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double) |
dirk | 2a08b06 | 2013-10-19 19:26:02 +0000 | [diff] [blame] | 2671 | GetImageDepth(image, exception)); |
| 2672 | break; |
| 2673 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2674 | break; |
| 2675 | } |
| 2676 | case 'c': |
| 2677 | { |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 2678 | if (LocaleCompare("channels",property) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2679 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2680 | WarnNoImageReturn("\"%%[%s]\"",property); |
anthony | 7bb7aee | 2012-05-15 00:09:16 +0000 | [diff] [blame] | 2681 | /* FUTURE: return actual image channels */ |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2682 | (void) FormatLocaleString(value,MagickPathExtent,"%s", |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 2683 | CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2684 | image->colorspace)); |
| 2685 | LocaleLower(value); |
cristy | 17f11b0 | 2014-12-20 19:37:04 +0000 | [diff] [blame] | 2686 | if( image->alpha_trait != UndefinedPixelTrait ) |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2687 | (void) ConcatenateMagickString(value,"a",MagickPathExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2688 | break; |
| 2689 | } |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 2690 | if (LocaleCompare("colorspace",property) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2691 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2692 | WarnNoImageReturn("\"%%[%s]\"",property); |
anthony | 7bb7aee | 2012-05-15 00:09:16 +0000 | [diff] [blame] | 2693 | /* FUTURE: return actual colorspace - no 'gray' stuff */ |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 2694 | string=CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t) |
cristy | 3f168fe | 2013-06-10 17:33:36 +0000 | [diff] [blame] | 2695 | image->colorspace); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2696 | break; |
| 2697 | } |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 2698 | if (LocaleCompare("copyright",property) == 0) |
cristy | 6305474 | 2010-09-20 12:42:28 +0000 | [diff] [blame] | 2699 | { |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2700 | (void) CopyMagickString(value,GetMagickCopyright(),MagickPathExtent); |
cristy | 6305474 | 2010-09-20 12:42:28 +0000 | [diff] [blame] | 2701 | break; |
| 2702 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2703 | break; |
| 2704 | } |
| 2705 | case 'd': |
| 2706 | { |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 2707 | if (LocaleCompare("depth",property) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2708 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2709 | WarnNoImageReturn("\"%%[%s]\"",property); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2710 | (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double) |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 2711 | image->depth); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2712 | break; |
| 2713 | } |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 2714 | if (LocaleCompare("directory",property) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2715 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2716 | WarnNoImageReturn("\"%%[%s]\"",property); |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 2717 | GetPathComponent(image->magick_filename,HeadPath,value); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2718 | if (*value == '\0') string=""; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2719 | break; |
| 2720 | } |
| 2721 | break; |
| 2722 | } |
| 2723 | case 'e': |
| 2724 | { |
cristy | 50908ac | 2014-11-09 13:49:47 +0000 | [diff] [blame] | 2725 | if (LocaleCompare("entropy",property) == 0) |
| 2726 | { |
| 2727 | double |
| 2728 | entropy; |
| 2729 | |
| 2730 | WarnNoImageReturn("\"%%[%s]\"",property); |
| 2731 | (void) GetImageEntropy(image,&entropy,exception); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2732 | (void) FormatLocaleString(value,MagickPathExtent,"%.*g", |
cristy | 50908ac | 2014-11-09 13:49:47 +0000 | [diff] [blame] | 2733 | GetMagickPrecision(),entropy); |
| 2734 | break; |
| 2735 | } |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 2736 | if (LocaleCompare("extension",property) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2737 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2738 | WarnNoImageReturn("\"%%[%s]\"",property); |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 2739 | GetPathComponent(image->magick_filename,ExtensionPath,value); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2740 | if (*value == '\0') string=""; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2741 | break; |
| 2742 | } |
| 2743 | break; |
| 2744 | } |
| 2745 | case 'g': |
| 2746 | { |
anthony | 2f7f9ca | 2012-05-14 06:33:53 +0000 | [diff] [blame] | 2747 | if (LocaleCompare("gamma",property) == 0) |
| 2748 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2749 | WarnNoImageReturn("\"%%[%s]\"",property); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2750 | (void) FormatLocaleString(value,MagickPathExtent,"%.*g", |
anthony | 2f7f9ca | 2012-05-14 06:33:53 +0000 | [diff] [blame] | 2751 | GetMagickPrecision(),image->gamma); |
| 2752 | break; |
| 2753 | } |
anthony | db2a1d6 | 2013-04-29 01:34:58 +0000 | [diff] [blame] | 2754 | if (LocaleCompare("group",property) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2755 | { |
anthony | db2a1d6 | 2013-04-29 01:34:58 +0000 | [diff] [blame] | 2756 | WarnNoImageInfoReturn("\"%%[%s]\"",property); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2757 | (void) FormatLocaleString(value,MagickPathExtent,"0x%lx",(unsigned long) |
cristy | 68064d7 | 2012-06-13 20:56:14 +0000 | [diff] [blame] | 2758 | image_info->group); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2759 | break; |
| 2760 | } |
| 2761 | break; |
| 2762 | } |
| 2763 | case 'h': |
| 2764 | { |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 2765 | if (LocaleCompare("height",property) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2766 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2767 | WarnNoImageReturn("\"%%[%s]\"",property); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2768 | (void) FormatLocaleString(value,MagickPathExtent,"%.20g", |
cristy | e8c25f9 | 2010-06-03 00:53:06 +0000 | [diff] [blame] | 2769 | image->magick_rows != 0 ? (double) image->magick_rows : 256.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2770 | break; |
| 2771 | } |
| 2772 | break; |
| 2773 | } |
| 2774 | case 'i': |
| 2775 | { |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 2776 | if (LocaleCompare("input",property) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2777 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2778 | WarnNoImageReturn("\"%%[%s]\"",property); |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 2779 | string=image->filename; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2780 | break; |
| 2781 | } |
| 2782 | break; |
| 2783 | } |
| 2784 | case 'k': |
| 2785 | { |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 2786 | if (LocaleCompare("kurtosis",property) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2787 | { |
| 2788 | double |
| 2789 | kurtosis, |
| 2790 | skewness; |
| 2791 | |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2792 | WarnNoImageReturn("\"%%[%s]\"",property); |
cristy | c82a27b | 2011-10-21 01:07:16 +0000 | [diff] [blame] | 2793 | (void) GetImageKurtosis(image,&kurtosis,&skewness,exception); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2794 | (void) FormatLocaleString(value,MagickPathExtent,"%.*g", |
cristy | 0596f85 | 2010-01-17 20:21:09 +0000 | [diff] [blame] | 2795 | GetMagickPrecision(),kurtosis); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2796 | break; |
| 2797 | } |
| 2798 | break; |
| 2799 | } |
| 2800 | case 'm': |
| 2801 | { |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 2802 | if (LocaleCompare("magick",property) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2803 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2804 | WarnNoImageReturn("\"%%[%s]\"",property); |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 2805 | string=image->magick; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2806 | break; |
| 2807 | } |
cristy | 8a304ba | 2015-02-14 01:25:26 +0000 | [diff] [blame] | 2808 | if ((LocaleCompare("maxima",property) == 0) || |
| 2809 | (LocaleCompare("max",property) == 0)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2810 | { |
| 2811 | double |
| 2812 | maximum, |
| 2813 | minimum; |
| 2814 | |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2815 | WarnNoImageReturn("\"%%[%s]\"",property); |
cristy | c82a27b | 2011-10-21 01:07:16 +0000 | [diff] [blame] | 2816 | (void) GetImageRange(image,&minimum,&maximum,exception); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2817 | (void) FormatLocaleString(value,MagickPathExtent,"%.*g", |
cristy | f899bbc | 2010-08-10 18:11:20 +0000 | [diff] [blame] | 2818 | GetMagickPrecision(),maximum); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2819 | break; |
| 2820 | } |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 2821 | if (LocaleCompare("mean",property) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2822 | { |
| 2823 | double |
| 2824 | mean, |
| 2825 | standard_deviation; |
| 2826 | |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2827 | WarnNoImageReturn("\"%%[%s]\"",property); |
cristy | 68064d7 | 2012-06-13 20:56:14 +0000 | [diff] [blame] | 2828 | (void) GetImageMean(image,&mean,&standard_deviation,exception); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2829 | (void) FormatLocaleString(value,MagickPathExtent,"%.*g", |
cristy | 0596f85 | 2010-01-17 20:21:09 +0000 | [diff] [blame] | 2830 | GetMagickPrecision(),mean); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2831 | break; |
| 2832 | } |
cristy | 8a304ba | 2015-02-14 01:25:26 +0000 | [diff] [blame] | 2833 | if ((LocaleCompare("minima",property) == 0) || |
| 2834 | (LocaleCompare("min",property) == 0)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2835 | { |
| 2836 | double |
| 2837 | maximum, |
| 2838 | minimum; |
| 2839 | |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2840 | WarnNoImageReturn("\"%%[%s]\"",property); |
cristy | c82a27b | 2011-10-21 01:07:16 +0000 | [diff] [blame] | 2841 | (void) GetImageRange(image,&minimum,&maximum,exception); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2842 | (void) FormatLocaleString(value,MagickPathExtent,"%.*g", |
cristy | f899bbc | 2010-08-10 18:11:20 +0000 | [diff] [blame] | 2843 | GetMagickPrecision(),minimum); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2844 | break; |
| 2845 | } |
| 2846 | break; |
| 2847 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2848 | case 'o': |
| 2849 | { |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 2850 | if (LocaleCompare("opaque",property) == 0) |
cristy | b009425 | 2011-03-26 12:59:45 +0000 | [diff] [blame] | 2851 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2852 | WarnNoImageReturn("\"%%[%s]\"",property); |
cristy | 1b7a35c | 2015-02-13 18:49:03 +0000 | [diff] [blame] | 2853 | string=CommandOptionToMnemonic(MagickBooleanOptions,(ssize_t) |
| 2854 | IsImageOpaque(image,exception)); |
cristy | b009425 | 2011-03-26 12:59:45 +0000 | [diff] [blame] | 2855 | break; |
| 2856 | } |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 2857 | if (LocaleCompare("orientation",property) == 0) |
cristy | 42aa06c | 2012-04-01 14:05:10 +0000 | [diff] [blame] | 2858 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2859 | WarnNoImageReturn("\"%%[%s]\"",property); |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 2860 | string=CommandOptionToMnemonic(MagickOrientationOptions,(ssize_t) |
| 2861 | image->orientation); |
cristy | 42aa06c | 2012-04-01 14:05:10 +0000 | [diff] [blame] | 2862 | break; |
| 2863 | } |
anthony | db2a1d6 | 2013-04-29 01:34:58 +0000 | [diff] [blame] | 2864 | if (LocaleCompare("output",property) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2865 | { |
anthony | db2a1d6 | 2013-04-29 01:34:58 +0000 | [diff] [blame] | 2866 | WarnNoImageInfoReturn("\"%%[%s]\"",property); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2867 | (void) CopyMagickString(value,image_info->filename,MagickPathExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2868 | break; |
| 2869 | } |
| 2870 | break; |
| 2871 | } |
| 2872 | case 'p': |
| 2873 | { |
dirk | 6015d44 | 2013-10-19 15:07:40 +0000 | [diff] [blame] | 2874 | #if defined(MAGICKCORE_LCMS_DELEGATE) |
| 2875 | if (LocaleCompare("profile:icc",property) == 0 || |
| 2876 | LocaleCompare("profile:icm",property) == 0) |
| 2877 | { |
cristy | 1a2fb52 | 2013-11-20 14:37:58 +0000 | [diff] [blame] | 2878 | #if !defined(LCMS_VERSION) || (LCMS_VERSION < 2000) |
| 2879 | #define cmsUInt32Number DWORD |
| 2880 | #endif |
| 2881 | |
dirk | 6015d44 | 2013-10-19 15:07:40 +0000 | [diff] [blame] | 2882 | const StringInfo |
| 2883 | *profile; |
| 2884 | |
| 2885 | cmsHPROFILE |
| 2886 | icc_profile; |
| 2887 | |
| 2888 | profile=GetImageProfile(image,property+8); |
| 2889 | if (profile == (StringInfo *) NULL) |
| 2890 | break; |
dirk | 6015d44 | 2013-10-19 15:07:40 +0000 | [diff] [blame] | 2891 | icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile), |
| 2892 | (cmsUInt32Number) GetStringInfoLength(profile)); |
| 2893 | if (icc_profile != (cmsHPROFILE *) NULL) |
| 2894 | { |
| 2895 | #if defined(LCMS_VERSION) && (LCMS_VERSION < 2000) |
| 2896 | string=cmsTakeProductName(icc_profile); |
| 2897 | #else |
| 2898 | (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription, |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2899 | "en","US",value,MagickPathExtent); |
dirk | 6015d44 | 2013-10-19 15:07:40 +0000 | [diff] [blame] | 2900 | #endif |
| 2901 | (void) cmsCloseProfile(icc_profile); |
| 2902 | } |
| 2903 | } |
| 2904 | #endif |
| 2905 | if (LocaleCompare("profiles",property) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2906 | { |
cristy | 5954e3c | 2013-10-18 23:23:44 +0000 | [diff] [blame] | 2907 | const char |
| 2908 | *name; |
| 2909 | |
| 2910 | ResetImageProfileIterator(image); |
| 2911 | name=GetNextImageProfile(image); |
dirk | 6015d44 | 2013-10-19 15:07:40 +0000 | [diff] [blame] | 2912 | if (name != (char *) NULL) |
| 2913 | { |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2914 | (void) CopyMagickString(value,name,MagickPathExtent); |
dirk | 6015d44 | 2013-10-19 15:07:40 +0000 | [diff] [blame] | 2915 | name=GetNextImageProfile(image); |
| 2916 | while (name != (char *) NULL) |
| 2917 | { |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2918 | ConcatenateMagickString(value,",",MagickPathExtent); |
| 2919 | ConcatenateMagickString(value,name,MagickPathExtent); |
dirk | 6015d44 | 2013-10-19 15:07:40 +0000 | [diff] [blame] | 2920 | name=GetNextImageProfile(image); |
| 2921 | } |
| 2922 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2923 | break; |
| 2924 | } |
| 2925 | break; |
| 2926 | } |
cristy | 946b103 | 2012-04-01 14:19:07 +0000 | [diff] [blame] | 2927 | case 'r': |
| 2928 | { |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 2929 | if (LocaleCompare("resolution.x",property) == 0) |
cristy | 946b103 | 2012-04-01 14:19:07 +0000 | [diff] [blame] | 2930 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2931 | WarnNoImageReturn("\"%%[%s]\"",property); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2932 | (void) FormatLocaleString(value,MagickPathExtent,"%g", |
cristy | 946b103 | 2012-04-01 14:19:07 +0000 | [diff] [blame] | 2933 | image->resolution.x); |
| 2934 | break; |
| 2935 | } |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 2936 | if (LocaleCompare("resolution.y",property) == 0) |
cristy | 946b103 | 2012-04-01 14:19:07 +0000 | [diff] [blame] | 2937 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2938 | WarnNoImageReturn("\"%%[%s]\"",property); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2939 | (void) FormatLocaleString(value,MagickPathExtent,"%g", |
cristy | 946b103 | 2012-04-01 14:19:07 +0000 | [diff] [blame] | 2940 | image->resolution.y); |
| 2941 | break; |
| 2942 | } |
| 2943 | break; |
| 2944 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2945 | case 's': |
| 2946 | { |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 2947 | if (LocaleCompare("scene",property) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2948 | { |
anthony | db2a1d6 | 2013-04-29 01:34:58 +0000 | [diff] [blame] | 2949 | WarnNoImageInfoReturn("\"%%[%s]\"",property); |
| 2950 | if (image_info->number_scenes != 0) |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2951 | (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double) |
cristy | 68064d7 | 2012-06-13 20:56:14 +0000 | [diff] [blame] | 2952 | image_info->scene); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2953 | else { |
| 2954 | WarnNoImageReturn("\"%%[%s]\"",property); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2955 | (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double) |
cristy | 68064d7 | 2012-06-13 20:56:14 +0000 | [diff] [blame] | 2956 | image->scene); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2957 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2958 | break; |
| 2959 | } |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 2960 | if (LocaleCompare("scenes",property) == 0) |
anthony | c69008c | 2012-05-07 11:45:32 +0000 | [diff] [blame] | 2961 | { |
anthony | db2a1d6 | 2013-04-29 01:34:58 +0000 | [diff] [blame] | 2962 | /* FUTURE: equivelent to %n? */ |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2963 | WarnNoImageReturn("\"%%[%s]\"",property); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2964 | (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double) |
anthony | c69008c | 2012-05-07 11:45:32 +0000 | [diff] [blame] | 2965 | GetImageListLength(image)); |
| 2966 | break; |
| 2967 | } |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 2968 | if (LocaleCompare("size",property) == 0) |
anthony | c69008c | 2012-05-07 11:45:32 +0000 | [diff] [blame] | 2969 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2970 | WarnNoImageReturn("\"%%[%s]\"",property); |
cristy | d4618c0 | 2015-04-14 23:54:43 +0000 | [diff] [blame] | 2971 | (void) FormatMagickSize(GetBlobSize(image),MagickFalse,"B", |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2972 | MagickPathExtent,value); |
anthony | c69008c | 2012-05-07 11:45:32 +0000 | [diff] [blame] | 2973 | break; |
| 2974 | } |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 2975 | if (LocaleCompare("skewness",property) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2976 | { |
| 2977 | double |
| 2978 | kurtosis, |
| 2979 | skewness; |
| 2980 | |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2981 | WarnNoImageReturn("\"%%[%s]\"",property); |
cristy | c82a27b | 2011-10-21 01:07:16 +0000 | [diff] [blame] | 2982 | (void) GetImageKurtosis(image,&kurtosis,&skewness,exception); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2983 | (void) FormatLocaleString(value,MagickPathExtent,"%.*g", |
cristy | 0596f85 | 2010-01-17 20:21:09 +0000 | [diff] [blame] | 2984 | GetMagickPrecision(),skewness); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2985 | break; |
| 2986 | } |
cristy | 10d5541 | 2015-02-13 21:52:54 +0000 | [diff] [blame] | 2987 | if (LocaleCompare("standard-deviation",property) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2988 | { |
| 2989 | double |
| 2990 | mean, |
| 2991 | standard_deviation; |
| 2992 | |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 2993 | WarnNoImageReturn("\"%%[%s]\"",property); |
cristy | 14fed16 | 2012-09-26 10:13:43 +0000 | [diff] [blame] | 2994 | (void) GetImageMean(image,&mean,&standard_deviation,exception); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2995 | (void) FormatLocaleString(value,MagickPathExtent,"%.*g", |
cristy | 0596f85 | 2010-01-17 20:21:09 +0000 | [diff] [blame] | 2996 | GetMagickPrecision(),standard_deviation); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2997 | break; |
| 2998 | } |
| 2999 | break; |
| 3000 | } |
cristy | 623aaec | 2012-06-21 00:49:08 +0000 | [diff] [blame] | 3001 | case 't': |
| 3002 | { |
| 3003 | if (LocaleCompare("type",property) == 0) |
| 3004 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3005 | WarnNoImageReturn("\"%%[%s]\"",property); |
cristy | 623aaec | 2012-06-21 00:49:08 +0000 | [diff] [blame] | 3006 | string=CommandOptionToMnemonic(MagickTypeOptions,(ssize_t) |
dirk | ab4f0bb | 2015-07-25 11:46:32 +0000 | [diff] [blame] | 3007 | IdentifyImageType(image,exception)); |
cristy | 623aaec | 2012-06-21 00:49:08 +0000 | [diff] [blame] | 3008 | break; |
| 3009 | } |
| 3010 | break; |
| 3011 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3012 | case 'u': |
| 3013 | { |
anthony | db2a1d6 | 2013-04-29 01:34:58 +0000 | [diff] [blame] | 3014 | if (LocaleCompare("unique",property) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3015 | { |
anthony | db2a1d6 | 2013-04-29 01:34:58 +0000 | [diff] [blame] | 3016 | WarnNoImageInfoReturn("\"%%[%s]\"",property); |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 3017 | string=image_info->unique; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3018 | break; |
| 3019 | } |
cristy | 9af7f5b | 2013-09-23 18:58:46 +0000 | [diff] [blame] | 3020 | if (LocaleCompare("units",property) == 0) |
| 3021 | { |
| 3022 | WarnNoImageReturn("\"%%[%s]\"",property); |
| 3023 | string=CommandOptionToMnemonic(MagickResolutionOptions,(ssize_t) |
| 3024 | image->units); |
| 3025 | break; |
| 3026 | } |
| 3027 | if (LocaleCompare("copyright",property) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3028 | break; |
| 3029 | } |
cristy | 6305474 | 2010-09-20 12:42:28 +0000 | [diff] [blame] | 3030 | case 'v': |
| 3031 | { |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 3032 | if (LocaleCompare("version",property) == 0) |
cristy | 6305474 | 2010-09-20 12:42:28 +0000 | [diff] [blame] | 3033 | { |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 3034 | string=GetMagickVersion((size_t *) NULL); |
cristy | 6305474 | 2010-09-20 12:42:28 +0000 | [diff] [blame] | 3035 | break; |
| 3036 | } |
| 3037 | break; |
| 3038 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3039 | case 'w': |
| 3040 | { |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 3041 | if (LocaleCompare("width",property) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3042 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3043 | WarnNoImageReturn("\"%%[%s]\"",property); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 3044 | (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double) |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 3045 | (image->magick_columns != 0 ? image->magick_columns : 256)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3046 | break; |
| 3047 | } |
| 3048 | break; |
| 3049 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3050 | case 'z': |
| 3051 | { |
anthony | db2a1d6 | 2013-04-29 01:34:58 +0000 | [diff] [blame] | 3052 | if (LocaleCompare("zero",property) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3053 | { |
anthony | db2a1d6 | 2013-04-29 01:34:58 +0000 | [diff] [blame] | 3054 | WarnNoImageInfoReturn("\"%%[%s]\"",property); |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 3055 | string=image_info->zero; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3056 | break; |
| 3057 | } |
| 3058 | break; |
| 3059 | } |
| 3060 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3061 | if (string != (char *) NULL) |
| 3062 | return(string); |
anthony | 2cfa1a1 | 2012-05-12 05:18:07 +0000 | [diff] [blame] | 3063 | if (*value != '\0') |
anthony | db2a1d6 | 2013-04-29 01:34:58 +0000 | [diff] [blame] | 3064 | { |
| 3065 | /* create a cloned copy of result, that will get cleaned up, eventually */ |
cristy | f432c63 | 2014-12-07 15:11:28 +0000 | [diff] [blame] | 3066 | if (image != (Image *) NULL) |
anthony | db2a1d6 | 2013-04-29 01:34:58 +0000 | [diff] [blame] | 3067 | { |
| 3068 | (void) SetImageArtifact(image,"get-property",value); |
| 3069 | return(GetImageArtifact(image,"get-property")); |
| 3070 | } |
| 3071 | else |
| 3072 | { |
| 3073 | (void) SetImageOption(image_info,"get-property",value); |
| 3074 | return(GetImageOption(image_info,"get-property")); |
| 3075 | } |
| 3076 | } |
cristy | f432c63 | 2014-12-07 15:11:28 +0000 | [diff] [blame] | 3077 | return((char *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3078 | } |
dirk | 6015d44 | 2013-10-19 15:07:40 +0000 | [diff] [blame] | 3079 | #undef WarnNoImageReturn |
cristy | f516f2f | 2014-01-07 01:29:28 +0000 | [diff] [blame] | 3080 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3081 | /* |
| 3082 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3083 | % % |
| 3084 | % % |
| 3085 | % % |
| 3086 | % G e t N e x t I m a g e P r o p e r t y % |
| 3087 | % % |
| 3088 | % % |
| 3089 | % % |
| 3090 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3091 | % |
cristy | 97fc9f3 | 2012-06-13 21:04:44 +0000 | [diff] [blame] | 3092 | % GetNextImageProperty() gets the next free-form string property name. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3093 | % |
| 3094 | % The format of the GetNextImageProperty method is: |
| 3095 | % |
| 3096 | % char *GetNextImageProperty(const Image *image) |
| 3097 | % |
| 3098 | % A description of each parameter follows: |
| 3099 | % |
| 3100 | % o image: the image. |
| 3101 | % |
| 3102 | */ |
dirk | 0d819b6 | 2015-07-15 11:34:05 +0000 | [diff] [blame] | 3103 | MagickExport const char *GetNextImageProperty(const Image *image) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3104 | { |
| 3105 | assert(image != (Image *) NULL); |
cristy | e1c94d9 | 2015-06-28 12:16:33 +0000 | [diff] [blame] | 3106 | assert(image->signature == MagickCoreSignature); |
cristy | cb190b7 | 2014-08-31 20:04:42 +0000 | [diff] [blame] | 3107 | if (image->debug != MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3108 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 3109 | image->filename); |
| 3110 | if (image->properties == (void *) NULL) |
dirk | 0d819b6 | 2015-07-15 11:34:05 +0000 | [diff] [blame] | 3111 | return((const char *) NULL); |
| 3112 | return((const char *) GetNextKeyInSplayTree( |
| 3113 | (SplayTreeInfo *) image->properties)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3114 | } |
cristy | cef1ea0 | 2014-01-07 00:39:10 +0000 | [diff] [blame] | 3115 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3116 | /* |
| 3117 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3118 | % % |
| 3119 | % % |
| 3120 | % % |
| 3121 | % I n t e r p r e t I m a g e P r o p e r t i e s % |
| 3122 | % % |
| 3123 | % % |
| 3124 | % % |
| 3125 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3126 | % |
| 3127 | % InterpretImageProperties() replaces any embedded formatting characters with |
anthony | 0676223 | 2012-04-29 11:45:40 +0000 | [diff] [blame] | 3128 | % the appropriate image property and returns the interpreted text. |
| 3129 | % |
| 3130 | % This searches for and replaces |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3131 | % \n \r \% replaced by newline, return, and percent resp. |
| 3132 | % < > & replaced by '<', '>', '&' resp. |
| 3133 | % %% replaced by percent |
anthony | 0676223 | 2012-04-29 11:45:40 +0000 | [diff] [blame] | 3134 | % |
anthony | d2f39e0 | 2012-08-20 12:29:28 +0000 | [diff] [blame] | 3135 | % %x %[x] where 'x' is a single letter properity, case sensitive). |
| 3136 | % %[type:name] where 'type' a is special and known prefix. |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3137 | % %[name] where 'name' is a specifically known attribute, calculated |
cristy | 97fc9f3 | 2012-06-13 21:04:44 +0000 | [diff] [blame] | 3138 | % value, or a per-image property string name, or a per-image |
anthony | d2f39e0 | 2012-08-20 12:29:28 +0000 | [diff] [blame] | 3139 | % 'artifact' (as generated from a global option). |
| 3140 | % It may contain ':' as long as the prefix is not special. |
anthony | 0676223 | 2012-04-29 11:45:40 +0000 | [diff] [blame] | 3141 | % |
anthony | d2f39e0 | 2012-08-20 12:29:28 +0000 | [diff] [blame] | 3142 | % Single letter % substitutions will only happen if the character before the |
| 3143 | % percent is NOT a number. But braced substitutions will always be performed. |
| 3144 | % This prevents the typical usage of percent in a interpreted geometry |
| 3145 | % argument from being substituted when the percent is a geometry flag. |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3146 | % |
| 3147 | % If 'glob-expresions' ('*' or '?' characters) is used for 'name' it may be |
| 3148 | % used as a search pattern to print multiple lines of "name=value\n" pairs of |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3149 | % the associacted set of properties. |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3150 | % |
anthony | d2f39e0 | 2012-08-20 12:29:28 +0000 | [diff] [blame] | 3151 | % The returned string must be freed using DestoryString() by the caller. |
anthony | f68116b | 2012-04-14 12:54:41 +0000 | [diff] [blame] | 3152 | % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3153 | % The format of the InterpretImageProperties method is: |
| 3154 | % |
anthony | db2a1d6 | 2013-04-29 01:34:58 +0000 | [diff] [blame] | 3155 | % char *InterpretImageProperties(ImageInfo *image_info, |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3156 | % Image *image,const char *embed_text,ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3157 | % |
| 3158 | % A description of each parameter follows: |
| 3159 | % |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3160 | % o image_info: the image info. (required) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3161 | % |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3162 | % o image: the image. (optional) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3163 | % |
| 3164 | % o embed_text: the address of a character string containing the embedded |
| 3165 | % formatting characters. |
| 3166 | % |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 3167 | % o exception: return any errors or warnings in this structure. |
| 3168 | % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3169 | */ |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3170 | |
| 3171 | /* common inline code to expand the interpreted text string */ |
| 3172 | #define ExtendInterpretText(string_length) do { \ |
dirk | 93b02b7 | 2013-11-16 16:03:36 +0000 | [diff] [blame] | 3173 | DisableMSCWarning(4127) \ |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3174 | size_t length=(string_length); \ |
| 3175 | if ((size_t) (q-interpret_text+length+1) >= extent) \ |
| 3176 | { extent+=length; \ |
| 3177 | interpret_text=(char *) ResizeQuantumMemory(interpret_text, \ |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 3178 | extent+MagickPathExtent,sizeof(*interpret_text)); \ |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3179 | if (interpret_text == (char *) NULL) \ |
cristy | f432c63 | 2014-12-07 15:11:28 +0000 | [diff] [blame] | 3180 | return((char *) NULL); \ |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3181 | q=interpret_text+strlen(interpret_text); \ |
dirk | 93b02b7 | 2013-11-16 16:03:36 +0000 | [diff] [blame] | 3182 | } } while (0) /* no trailing ; */ \ |
| 3183 | RestoreMSCWarning |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3184 | |
| 3185 | /* same but append the given string */ |
| 3186 | #define AppendString2Text(string) do { \ |
dirk | 93b02b7 | 2013-11-16 16:03:36 +0000 | [diff] [blame] | 3187 | DisableMSCWarning(4127) \ |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3188 | size_t length=strlen((string)); \ |
| 3189 | if ((size_t) (q-interpret_text+length+1) >= extent) \ |
| 3190 | { extent+=length; \ |
| 3191 | interpret_text=(char *) ResizeQuantumMemory(interpret_text, \ |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 3192 | extent+MagickPathExtent,sizeof(*interpret_text)); \ |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3193 | if (interpret_text == (char *) NULL) \ |
cristy | f432c63 | 2014-12-07 15:11:28 +0000 | [diff] [blame] | 3194 | return((char *) NULL); \ |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3195 | q=interpret_text+strlen(interpret_text); \ |
| 3196 | } \ |
| 3197 | (void) CopyMagickString(q,(string),extent); \ |
| 3198 | q+=length; \ |
dirk | 93b02b7 | 2013-11-16 16:03:36 +0000 | [diff] [blame] | 3199 | } while (0) /* no trailing ; */ \ |
| 3200 | RestoreMSCWarning |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3201 | |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3202 | /* same but append a 'key' and 'string' pair */ |
| 3203 | #define AppendKeyValue2Text(key,string) do { \ |
dirk | 93b02b7 | 2013-11-16 16:03:36 +0000 | [diff] [blame] | 3204 | DisableMSCWarning(4127) \ |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3205 | size_t length=strlen(key)+strlen(string)+2; \ |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3206 | if ((size_t) (q-interpret_text+length+1) >= extent) \ |
| 3207 | { extent+=length; \ |
| 3208 | interpret_text=(char *) ResizeQuantumMemory(interpret_text, \ |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 3209 | extent+MagickPathExtent,sizeof(*interpret_text)); \ |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3210 | if (interpret_text == (char *) NULL) \ |
cristy | f432c63 | 2014-12-07 15:11:28 +0000 | [diff] [blame] | 3211 | return((char *) NULL); \ |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3212 | q=interpret_text+strlen(interpret_text); \ |
| 3213 | } \ |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3214 | q+=FormatLocaleString(q,extent,"%s=%s\n",(key),(string)); \ |
dirk | 93b02b7 | 2013-11-16 16:03:36 +0000 | [diff] [blame] | 3215 | } while (0) /* no trailing ; */ \ |
| 3216 | RestoreMSCWarning |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3217 | |
anthony | db2a1d6 | 2013-04-29 01:34:58 +0000 | [diff] [blame] | 3218 | MagickExport char *InterpretImageProperties(ImageInfo *image_info, |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 3219 | Image *image,const char *embed_text,ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3220 | { |
| 3221 | char |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3222 | *interpret_text; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3223 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3224 | register char |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3225 | *q; /* current position in interpret_text */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3226 | |
| 3227 | register const char |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3228 | *p; /* position in embed_text string being expanded */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3229 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3230 | size_t |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3231 | extent; /* allocated length of interpret_text */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3232 | |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3233 | MagickBooleanType |
| 3234 | number; |
| 3235 | |
cristy | e1c94d9 | 2015-06-28 12:16:33 +0000 | [diff] [blame] | 3236 | assert(image == NULL || image->signature == MagickCoreSignature); |
| 3237 | assert(image_info == NULL || image_info->signature == MagickCoreSignature); |
anthony | db2a1d6 | 2013-04-29 01:34:58 +0000 | [diff] [blame] | 3238 | |
| 3239 | if (image != (Image *) NULL && IfMagickTrue(image->debug)) |
| 3240 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 3241 | else if( image_info != (ImageInfo *) NULL && IfMagickTrue(image_info->debug)) |
| 3242 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s","no-image"); |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 3243 | |
glennrp | a22b265 | 2013-01-05 12:37:21 +0000 | [diff] [blame] | 3244 | if (embed_text == (const char *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3245 | return((char *) NULL); |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3246 | p=embed_text; |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 3247 | |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 3248 | if (*p == '\0') |
| 3249 | return(ConstantString("")); |
| 3250 | |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 3251 | /* handle a '@' replace string from file */ |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3252 | if (*p == '@') { |
| 3253 | p++; |
| 3254 | if (*p != '-' && IfMagickFalse(IsPathAccessible(p)) ) { |
cristy | 6cad6a5 | 2015-01-06 00:54:19 +0000 | [diff] [blame] | 3255 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, |
| 3256 | "UnableToAccessPath","%s",p); |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3257 | return((char *) NULL); |
| 3258 | } |
cristy | 3a5987c | 2013-11-07 14:18:46 +0000 | [diff] [blame] | 3259 | return(FileToString(p,~0UL,exception)); |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3260 | } |
| 3261 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3262 | /* |
| 3263 | Translate any embedded format characters. |
| 3264 | */ |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3265 | interpret_text=AcquireString(embed_text); /* new string with extra space */ |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 3266 | extent=MagickPathExtent; /* allocated space in string */ |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3267 | number=MagickFalse; /* is last char a number? */ |
dirk | b9dbc29 | 2015-07-26 09:50:00 +0000 | [diff] [blame] | 3268 | for (q=interpret_text; *p!='\0'; number=isdigit(*p) ? MagickTrue : MagickFalse,p++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3269 | { |
| 3270 | *q='\0'; |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 3271 | ExtendInterpretText(MagickPathExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3272 | /* |
anthony | d2f39e0 | 2012-08-20 12:29:28 +0000 | [diff] [blame] | 3273 | Look for the various escapes, (and handle other specials) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3274 | */ |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3275 | switch (*p) { |
| 3276 | case '\\': |
| 3277 | switch (*(p+1)) { |
| 3278 | case '\0': |
| 3279 | continue; |
| 3280 | case 'r': /* convert to RETURN */ |
| 3281 | *q++='\r'; |
| 3282 | p++; |
| 3283 | continue; |
| 3284 | case 'n': /* convert to NEWLINE */ |
| 3285 | *q++='\n'; |
| 3286 | p++; |
| 3287 | continue; |
| 3288 | case '\n': /* EOL removal UNIX,MacOSX */ |
| 3289 | p++; |
| 3290 | continue; |
| 3291 | case '\r': /* EOL removal DOS,Windows */ |
| 3292 | p++; |
| 3293 | if (*p == '\n') /* return-newline EOL */ |
| 3294 | p++; |
| 3295 | continue; |
| 3296 | default: |
| 3297 | p++; |
| 3298 | *q++=(*p); |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3299 | } |
cristy | 2867b87 | 2014-05-17 11:53:50 +0000 | [diff] [blame] | 3300 | continue; |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3301 | case '&': |
anthony | 104f893 | 2012-05-13 01:54:53 +0000 | [diff] [blame] | 3302 | if (LocaleNCompare("<",p,4) == 0) |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3303 | *q++='<', p+=3; |
anthony | 104f893 | 2012-05-13 01:54:53 +0000 | [diff] [blame] | 3304 | else if (LocaleNCompare(">",p,4) == 0) |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3305 | *q++='>', p+=3; |
anthony | 104f893 | 2012-05-13 01:54:53 +0000 | [diff] [blame] | 3306 | else if (LocaleNCompare("&",p,5) == 0) |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3307 | *q++='&', p+=4; |
| 3308 | else |
| 3309 | *q++=(*p); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3310 | continue; |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3311 | case '%': |
| 3312 | break; /* continue to next set of handlers */ |
| 3313 | default: |
| 3314 | *q++=(*p); /* any thing else is 'as normal' */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3315 | continue; |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3316 | } |
anthony | 104f893 | 2012-05-13 01:54:53 +0000 | [diff] [blame] | 3317 | p++; /* advance beyond the percent */ |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 3318 | |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3319 | /* |
anthony | 2ec9bd9 | 2012-05-20 05:43:24 +0000 | [diff] [blame] | 3320 | Doubled Percent - or percent at end of string |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3321 | */ |
cristy | 6cad6a5 | 2015-01-06 00:54:19 +0000 | [diff] [blame] | 3322 | if ((*p == '\0') || (*p == '\'') || (*p == '"')) |
| 3323 | p--; |
| 3324 | if (*p == '%') { |
anthony | 89075d0 | 2012-05-18 03:40:40 +0000 | [diff] [blame] | 3325 | *q++='%'; |
anthony | 104f893 | 2012-05-13 01:54:53 +0000 | [diff] [blame] | 3326 | continue; |
| 3327 | } |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3328 | /* |
anthony | d2f39e0 | 2012-08-20 12:29:28 +0000 | [diff] [blame] | 3329 | Single letter escapes %c |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3330 | */ |
anthony | 104f893 | 2012-05-13 01:54:53 +0000 | [diff] [blame] | 3331 | if ( *p != '[' ) { |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3332 | const char |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3333 | *string; |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3334 | |
| 3335 | /* But only if not preceeded by a number! */ |
dirk | b9dbc29 | 2015-07-26 09:50:00 +0000 | [diff] [blame] | 3336 | if (number != MagickFalse) { |
anthony | 104f893 | 2012-05-13 01:54:53 +0000 | [diff] [blame] | 3337 | *q++='%'; /* do NOT substitute the percent */ |
| 3338 | p--; /* back up one */ |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3339 | continue; |
| 3340 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3341 | string=GetMagickPropertyLetter(image_info,image,*p, exception); |
| 3342 | if (string != (char *) NULL) |
cristy | f57e548 | 2013-02-17 22:11:27 +0000 | [diff] [blame] | 3343 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3344 | AppendString2Text(string); |
anthony | db2a1d6 | 2013-04-29 01:34:58 +0000 | [diff] [blame] | 3345 | if (image != (Image *) NULL) |
| 3346 | (void)DeleteImageArtifact(image,"get-property"); |
| 3347 | if (image_info != (ImageInfo *) NULL) |
| 3348 | (void)DeleteImageOption(image_info,"get-property"); |
cristy | f57e548 | 2013-02-17 22:11:27 +0000 | [diff] [blame] | 3349 | continue; |
| 3350 | } |
| 3351 | (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning, |
| 3352 | "UnknownImageProperty","\"%%%c\"",*p); |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3353 | continue; |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 3354 | } |
anthony | 2fbb595 | 2012-05-05 12:35:30 +0000 | [diff] [blame] | 3355 | |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3356 | /* |
anthony | d2f39e0 | 2012-08-20 12:29:28 +0000 | [diff] [blame] | 3357 | Braced Percent Escape %[...] |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3358 | */ |
| 3359 | { |
| 3360 | char |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 3361 | pattern[2*MagickPathExtent]; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3362 | |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3363 | const char |
| 3364 | *key, |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3365 | *string; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3366 | |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3367 | register ssize_t |
| 3368 | len; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3369 | |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3370 | ssize_t |
| 3371 | depth; |
| 3372 | |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3373 | /* get the property name framed by the %[...] */ |
anthony | 104f893 | 2012-05-13 01:54:53 +0000 | [diff] [blame] | 3374 | p++; /* advance p to just inside the opening brace */ |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3375 | depth=1; |
| 3376 | if ( *p == ']' ) { |
cristy | f2a82ee | 2014-05-26 17:49:54 +0000 | [diff] [blame] | 3377 | (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning, |
| 3378 | "UnknownImageProperty","\"%%[]\""); |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3379 | break; |
| 3380 | } |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 3381 | for (len=0; len<(MagickPathExtent-1L) && (*p != '\0');) |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3382 | { |
| 3383 | /* skip escaped braces within braced pattern */ |
| 3384 | if ( (*p == '\\') && (*(p+1) != '\0') ) { |
| 3385 | pattern[len++]=(*p++); |
| 3386 | pattern[len++]=(*p++); |
| 3387 | continue; |
| 3388 | } |
| 3389 | if (*p == '[') |
| 3390 | depth++; |
| 3391 | if (*p == ']') |
| 3392 | depth--; |
| 3393 | if (depth <= 0) |
| 3394 | break; |
| 3395 | pattern[len++]=(*p++); |
| 3396 | } |
| 3397 | pattern[len]='\0'; |
| 3398 | /* Check for unmatched final ']' for "%[...]" */ |
| 3399 | if ( depth != 0 ) { |
| 3400 | if (len >= 64) { /* truncate string for error message */ |
| 3401 | pattern[61] = '.'; |
| 3402 | pattern[62] = '.'; |
| 3403 | pattern[63] = '.'; |
| 3404 | pattern[64] = '\0'; |
| 3405 | } |
| 3406 | (void) ThrowMagickException(exception,GetMagickModule(), |
anthony | 104f893 | 2012-05-13 01:54:53 +0000 | [diff] [blame] | 3407 | OptionError,"UnbalancedBraces","\"%%[%s\"",pattern); |
| 3408 | interpret_text=DestroyString(interpret_text); |
cristy | f432c63 | 2014-12-07 15:11:28 +0000 | [diff] [blame] | 3409 | return((char *) NULL); |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3410 | } |
| 3411 | |
| 3412 | /* |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3413 | Special Lookup Prefixes %[prefix:...] |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3414 | */ |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3415 | /* fx - value calculator */ |
| 3416 | if (LocaleNCompare("fx:",pattern,3) == 0) |
| 3417 | { |
| 3418 | FxInfo |
| 3419 | *fx_info; |
| 3420 | |
| 3421 | double |
| 3422 | value; |
| 3423 | |
| 3424 | MagickBooleanType |
| 3425 | status; |
| 3426 | |
| 3427 | if (image == (Image *) NULL ) { |
| 3428 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 3429 | OptionWarning,"NoImageForProperty","\"%%[%s]\"",pattern); |
| 3430 | continue; /* else no image to retrieve artifact */ |
| 3431 | } |
| 3432 | fx_info=AcquireFxInfo(image,pattern+3,exception); |
| 3433 | status=FxEvaluateChannelExpression(fx_info,IntensityPixelChannel,0,0, |
| 3434 | &value,exception); |
| 3435 | fx_info=DestroyFxInfo(fx_info); |
dirk | b9dbc29 | 2015-07-26 09:50:00 +0000 | [diff] [blame] | 3436 | if (status != MagickFalse) |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3437 | { |
| 3438 | char |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 3439 | result[MagickPathExtent]; |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3440 | |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 3441 | (void) FormatLocaleString(result,MagickPathExtent,"%.*g", |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3442 | GetMagickPrecision(),(double) value); |
anthony | ec26e25 | 2013-04-28 12:18:12 +0000 | [diff] [blame] | 3443 | AppendString2Text(result); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3444 | } |
anthony | ec26e25 | 2013-04-28 12:18:12 +0000 | [diff] [blame] | 3445 | continue; |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3446 | } |
| 3447 | /* pixel - color value calculator */ |
| 3448 | if (LocaleNCompare("pixel:",pattern,6) == 0) |
| 3449 | { |
| 3450 | FxInfo |
| 3451 | *fx_info; |
| 3452 | |
| 3453 | double |
| 3454 | value; |
| 3455 | |
cristy | ee1bdaa | 2013-07-16 16:45:03 +0000 | [diff] [blame] | 3456 | MagickStatusType |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3457 | status; |
| 3458 | |
| 3459 | PixelInfo |
| 3460 | pixel; |
| 3461 | |
| 3462 | if (image == (Image *) NULL ) { |
| 3463 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 3464 | OptionWarning,"NoImageForProperty","\"%%[%s]\"",pattern); |
| 3465 | continue; /* else no image to retrieve artifact */ |
| 3466 | } |
| 3467 | GetPixelInfo(image,&pixel); |
| 3468 | fx_info=AcquireFxInfo(image,pattern+6,exception); |
cristy | ee1bdaa | 2013-07-16 16:45:03 +0000 | [diff] [blame] | 3469 | status=FxEvaluateChannelExpression(fx_info,RedPixelChannel,0,0, |
| 3470 | &value,exception); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3471 | pixel.red=(double) QuantumRange*value; |
cristy | aae13f6 | 2013-08-15 14:41:32 +0000 | [diff] [blame] | 3472 | status&=FxEvaluateChannelExpression(fx_info,GreenPixelChannel,0,0, |
cristy | ee1bdaa | 2013-07-16 16:45:03 +0000 | [diff] [blame] | 3473 | &value,exception); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3474 | pixel.green=(double) QuantumRange*value; |
cristy | aae13f6 | 2013-08-15 14:41:32 +0000 | [diff] [blame] | 3475 | status&=FxEvaluateChannelExpression(fx_info,BluePixelChannel,0,0, |
cristy | ee1bdaa | 2013-07-16 16:45:03 +0000 | [diff] [blame] | 3476 | &value,exception); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3477 | pixel.blue=(double) QuantumRange*value; |
| 3478 | if (image->colorspace == CMYKColorspace) |
| 3479 | { |
cristy | aae13f6 | 2013-08-15 14:41:32 +0000 | [diff] [blame] | 3480 | status&=FxEvaluateChannelExpression(fx_info,BlackPixelChannel,0,0, |
cristy | ee1bdaa | 2013-07-16 16:45:03 +0000 | [diff] [blame] | 3481 | &value,exception); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3482 | pixel.black=(double) QuantumRange*value; |
| 3483 | } |
cristy | aae13f6 | 2013-08-15 14:41:32 +0000 | [diff] [blame] | 3484 | status&=FxEvaluateChannelExpression(fx_info,AlphaPixelChannel,0,0, |
cristy | ee1bdaa | 2013-07-16 16:45:03 +0000 | [diff] [blame] | 3485 | &value,exception); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3486 | pixel.alpha=(double) QuantumRange*value; |
| 3487 | fx_info=DestroyFxInfo(fx_info); |
dirk | b9dbc29 | 2015-07-26 09:50:00 +0000 | [diff] [blame] | 3488 | if (status != MagickFalse) |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3489 | { |
| 3490 | char |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 3491 | name[MagickPathExtent]; |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3492 | |
| 3493 | (void) QueryColorname(image,&pixel,SVGCompliance,name, |
| 3494 | exception); |
| 3495 | AppendString2Text(name); |
| 3496 | } |
anthony | ec26e25 | 2013-04-28 12:18:12 +0000 | [diff] [blame] | 3497 | continue; |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3498 | } |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3499 | /* option - direct global option lookup (with globbing) */ |
| 3500 | if (LocaleNCompare("option:",pattern,7) == 0) |
| 3501 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3502 | if (image_info == (ImageInfo *) NULL ) { |
| 3503 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 3504 | OptionWarning,"NoImageForProperty","\"%%[%s]\"",pattern); |
| 3505 | continue; /* else no image to retrieve artifact */ |
| 3506 | } |
dirk | b9dbc29 | 2015-07-26 09:50:00 +0000 | [diff] [blame] | 3507 | if (IsGlob(pattern+7) != MagickFalse) |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3508 | { |
| 3509 | ResetImageOptionIterator(image_info); |
| 3510 | while ((key=GetNextImageOption(image_info)) != (const char *) NULL) |
dirk | b9dbc29 | 2015-07-26 09:50:00 +0000 | [diff] [blame] | 3511 | if (GlobExpression(key,pattern+7,MagickTrue) != MagickFalse) |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3512 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3513 | string=GetImageOption(image_info,key); |
| 3514 | if (string != (const char *) NULL) |
| 3515 | AppendKeyValue2Text(key,string); |
| 3516 | /* else - assertion failure? key found but no string value! */ |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3517 | } |
| 3518 | continue; |
| 3519 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3520 | string=GetImageOption(image_info,pattern+7); |
| 3521 | if (string == (char *) NULL) |
| 3522 | goto PropertyLookupFailure; /* no artifact of this specifc name */ |
| 3523 | AppendString2Text(string); |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3524 | continue; |
| 3525 | } |
| 3526 | /* artifact - direct image artifact lookup (with glob) */ |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 3527 | if (LocaleNCompare("artifact:",pattern,9) == 0) |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3528 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3529 | if (image == (Image *) NULL ) { |
| 3530 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 3531 | OptionWarning,"NoImageForProperty","\"%%[%s]\"",pattern); |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 3532 | continue; /* else no image to retrieve artifact */ |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3533 | } |
dirk | b9dbc29 | 2015-07-26 09:50:00 +0000 | [diff] [blame] | 3534 | if (IsGlob(pattern+9) != MagickFalse) |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3535 | { |
| 3536 | ResetImageArtifactIterator(image); |
| 3537 | while ((key=GetNextImageArtifact(image)) != (const char *) NULL) |
dirk | b9dbc29 | 2015-07-26 09:50:00 +0000 | [diff] [blame] | 3538 | if (GlobExpression(key,pattern+9,MagickTrue) != MagickFalse) |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3539 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3540 | string=GetImageArtifact(image,key); |
| 3541 | if (string != (const char *) NULL) |
| 3542 | AppendKeyValue2Text(key,string); |
| 3543 | /* else - assertion failure? key found but no string value! */ |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3544 | } |
| 3545 | continue; |
| 3546 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3547 | string=GetImageArtifact(image,pattern+9); |
| 3548 | if (string == (char *) NULL) |
| 3549 | goto PropertyLookupFailure; /* no artifact of this specifc name */ |
| 3550 | AppendString2Text(string); |
anthony | c799467 | 2012-11-17 05:33:27 +0000 | [diff] [blame] | 3551 | continue; |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3552 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3553 | /* property - direct image property lookup (with glob) */ |
| 3554 | if (LocaleNCompare("property:",pattern,9) == 0) |
| 3555 | { |
| 3556 | if (image == (Image *) NULL ) { |
| 3557 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 3558 | OptionWarning,"NoImageForProperty","\"%%[%s]\"",pattern); |
| 3559 | continue; /* else no image to retrieve artifact */ |
| 3560 | } |
dirk | b9dbc29 | 2015-07-26 09:50:00 +0000 | [diff] [blame] | 3561 | if (IsGlob(pattern+9) != MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3562 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3563 | ResetImagePropertyIterator(image); |
| 3564 | while ((key=GetNextImageProperty(image)) != (const char *) NULL) |
dirk | b9dbc29 | 2015-07-26 09:50:00 +0000 | [diff] [blame] | 3565 | if (GlobExpression(key,pattern,MagickTrue) != MagickFalse) |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3566 | { |
| 3567 | string=GetImageProperty(image,key,exception); |
| 3568 | if (string != (const char *) NULL) |
| 3569 | AppendKeyValue2Text(key,string); |
| 3570 | /* else - assertion failure? */ |
| 3571 | } |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3572 | continue; |
| 3573 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3574 | string=GetImageProperty(image,pattern+9,exception); |
| 3575 | if (string == (char *) NULL) |
| 3576 | goto PropertyLookupFailure; /* no artifact of this specifc name */ |
| 3577 | AppendString2Text(string); |
| 3578 | continue; |
| 3579 | } |
| 3580 | /* Properties without special prefix. |
| 3581 | This handles attributes, properties, and profiles such as %[exif:...] |
| 3582 | Note the profile properties may also include a glob expansion pattern. |
| 3583 | */ |
dirk | b9dbc29 | 2015-07-26 09:50:00 +0000 | [diff] [blame] | 3584 | if (image != (Image *) NULL) |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3585 | { |
| 3586 | string=GetImageProperty(image,pattern,exception); |
| 3587 | if (string != (const char *) NULL) |
| 3588 | { |
| 3589 | AppendString2Text(string); |
anthony | db2a1d6 | 2013-04-29 01:34:58 +0000 | [diff] [blame] | 3590 | if (image != (Image *) NULL) |
| 3591 | (void)DeleteImageArtifact(image,"get-property"); |
| 3592 | if (image_info != (ImageInfo *) NULL) |
| 3593 | (void)DeleteImageOption(image_info,"get-property"); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3594 | continue; |
| 3595 | } |
| 3596 | } |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3597 | /* |
cristy | 97fc9f3 | 2012-06-13 21:04:44 +0000 | [diff] [blame] | 3598 | Handle property 'glob' patterns |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3599 | Such as: %[*] %[user:array_??] %[filename:e*] |
| 3600 | */ |
dirk | b9dbc29 | 2015-07-26 09:50:00 +0000 | [diff] [blame] | 3601 | if (IsGlob(pattern) != MagickFalse) |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3602 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3603 | if (image == (Image *) NULL) |
| 3604 | continue; /* else no image to retrieve proprty - no list */ |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3605 | ResetImagePropertyIterator(image); |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3606 | while ((key=GetNextImageProperty(image)) != (const char *) NULL) |
dirk | b9dbc29 | 2015-07-26 09:50:00 +0000 | [diff] [blame] | 3607 | if (GlobExpression(key,pattern,MagickTrue) != MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3608 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3609 | string=GetImageProperty(image,key,exception); |
| 3610 | if (string != (const char *) NULL) |
| 3611 | AppendKeyValue2Text(key,string); |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3612 | /* else - assertion failure? */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3613 | } |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3614 | continue; |
| 3615 | } |
| 3616 | /* |
| 3617 | Look for a known property or image attribute |
| 3618 | Such as %[basename] %[denisty] %[delay] |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3619 | Also handles a braced single letter: %[b] %[G] %[g] |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3620 | */ |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3621 | string=GetMagickProperty(image_info,image,pattern,exception); |
| 3622 | if (string != (const char *) NULL) |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3623 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3624 | AppendString2Text(string); |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3625 | continue; |
| 3626 | } |
| 3627 | /* |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3628 | Look for a per-image Artifact |
| 3629 | This includes option lookup (FUTURE: interpreted according to image) |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3630 | */ |
cristy | f432c63 | 2014-12-07 15:11:28 +0000 | [diff] [blame] | 3631 | if (image != (Image *) NULL) |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3632 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3633 | string=GetImageArtifact(image,pattern); |
| 3634 | if (string != (char *) NULL) |
| 3635 | { |
| 3636 | AppendString2Text(string); |
| 3637 | continue; |
| 3638 | } |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3639 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3640 | else |
| 3641 | /* no image, so direct 'option' lookup (no delayed percent escapes) */ |
| 3642 | if (image_info != (ImageInfo *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3643 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3644 | string=GetImageOption(image_info,pattern); |
| 3645 | if (string != (char *) NULL) |
| 3646 | { |
| 3647 | AppendString2Text(string); |
| 3648 | continue; |
| 3649 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3650 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3651 | PropertyLookupFailure: |
anthony | 003f899 | 2012-05-11 12:50:07 +0000 | [diff] [blame] | 3652 | /* |
| 3653 | Failed to find any match anywhere! |
| 3654 | */ |
| 3655 | if (len >= 64) { /* truncate string for error message */ |
| 3656 | pattern[61] = '.'; |
| 3657 | pattern[62] = '.'; |
| 3658 | pattern[63] = '.'; |
| 3659 | pattern[64] = '\0'; |
| 3660 | } |
| 3661 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 3662 | OptionWarning,"UnknownImageProperty","\"%%[%s]\"",pattern); |
| 3663 | /* continue */ |
| 3664 | } /* Braced Percent Escape */ |
| 3665 | |
| 3666 | } /* for each char in 'embed_text' */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3667 | *q='\0'; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3668 | return(interpret_text); |
| 3669 | } |
cristy | cef1ea0 | 2014-01-07 00:39:10 +0000 | [diff] [blame] | 3670 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3671 | /* |
| 3672 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3673 | % % |
| 3674 | % % |
| 3675 | % % |
| 3676 | % R e m o v e I m a g e P r o p e r t y % |
| 3677 | % % |
| 3678 | % % |
| 3679 | % % |
| 3680 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3681 | % |
| 3682 | % RemoveImageProperty() removes a property from the image and returns its |
| 3683 | % value. |
| 3684 | % |
anthony | d2f39e0 | 2012-08-20 12:29:28 +0000 | [diff] [blame] | 3685 | % In this case the ConstantString() value returned should be freed by the |
| 3686 | % caller when finished. |
| 3687 | % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3688 | % The format of the RemoveImageProperty method is: |
| 3689 | % |
| 3690 | % char *RemoveImageProperty(Image *image,const char *property) |
| 3691 | % |
| 3692 | % A description of each parameter follows: |
| 3693 | % |
| 3694 | % o image: the image. |
| 3695 | % |
| 3696 | % o property: the image property. |
| 3697 | % |
| 3698 | */ |
| 3699 | MagickExport char *RemoveImageProperty(Image *image, |
| 3700 | const char *property) |
| 3701 | { |
| 3702 | char |
| 3703 | *value; |
| 3704 | |
| 3705 | assert(image != (Image *) NULL); |
cristy | e1c94d9 | 2015-06-28 12:16:33 +0000 | [diff] [blame] | 3706 | assert(image->signature == MagickCoreSignature); |
cristy | cb190b7 | 2014-08-31 20:04:42 +0000 | [diff] [blame] | 3707 | if (image->debug != MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3708 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 3709 | image->filename); |
| 3710 | if (image->properties == (void *) NULL) |
| 3711 | return((char *) NULL); |
| 3712 | value=(char *) RemoveNodeFromSplayTree((SplayTreeInfo *) image->properties, |
| 3713 | property); |
| 3714 | return(value); |
| 3715 | } |
cristy | f516f2f | 2014-01-07 01:29:28 +0000 | [diff] [blame] | 3716 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3717 | /* |
| 3718 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3719 | % % |
| 3720 | % % |
| 3721 | % % |
| 3722 | % R e s e t I m a g e P r o p e r t y I t e r a t o r % |
| 3723 | % % |
| 3724 | % % |
| 3725 | % % |
| 3726 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3727 | % |
| 3728 | % ResetImagePropertyIterator() resets the image properties iterator. Use it |
| 3729 | % in conjunction with GetNextImageProperty() to iterate over all the values |
| 3730 | % associated with an image property. |
| 3731 | % |
| 3732 | % The format of the ResetImagePropertyIterator method is: |
| 3733 | % |
| 3734 | % ResetImagePropertyIterator(Image *image) |
| 3735 | % |
| 3736 | % A description of each parameter follows: |
| 3737 | % |
| 3738 | % o image: the image. |
| 3739 | % |
| 3740 | */ |
| 3741 | MagickExport void ResetImagePropertyIterator(const Image *image) |
| 3742 | { |
| 3743 | assert(image != (Image *) NULL); |
cristy | e1c94d9 | 2015-06-28 12:16:33 +0000 | [diff] [blame] | 3744 | assert(image->signature == MagickCoreSignature); |
cristy | cb190b7 | 2014-08-31 20:04:42 +0000 | [diff] [blame] | 3745 | if (image->debug != MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3746 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 3747 | image->filename); |
| 3748 | if (image->properties == (void *) NULL) |
| 3749 | return; |
| 3750 | ResetSplayTreeIterator((SplayTreeInfo *) image->properties); |
| 3751 | } |
cristy | f516f2f | 2014-01-07 01:29:28 +0000 | [diff] [blame] | 3752 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3753 | /* |
| 3754 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3755 | % % |
| 3756 | % % |
| 3757 | % % |
| 3758 | % S e t I m a g e P r o p e r t y % |
| 3759 | % % |
| 3760 | % % |
| 3761 | % % |
| 3762 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3763 | % |
anthony | 104f893 | 2012-05-13 01:54:53 +0000 | [diff] [blame] | 3764 | % SetImageProperty() saves the given string value either to specific known |
cristy | 97fc9f3 | 2012-06-13 21:04:44 +0000 | [diff] [blame] | 3765 | % attribute or to a freeform property string. |
anthony | 6e2e073 | 2012-05-06 12:22:43 +0000 | [diff] [blame] | 3766 | % |
cristy | 97fc9f3 | 2012-06-13 21:04:44 +0000 | [diff] [blame] | 3767 | % Attempting to set a property that is normally calculated will produce |
anthony | 6e2e073 | 2012-05-06 12:22:43 +0000 | [diff] [blame] | 3768 | % an exception. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3769 | % |
| 3770 | % The format of the SetImageProperty method is: |
| 3771 | % |
| 3772 | % MagickBooleanType SetImageProperty(Image *image,const char *property, |
cristy | d15e659 | 2011-10-15 00:13:06 +0000 | [diff] [blame] | 3773 | % const char *value,ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3774 | % |
| 3775 | % A description of each parameter follows: |
| 3776 | % |
| 3777 | % o image: the image. |
| 3778 | % |
| 3779 | % o property: the image property. |
| 3780 | % |
| 3781 | % o values: the image property values. |
| 3782 | % |
cristy | d15e659 | 2011-10-15 00:13:06 +0000 | [diff] [blame] | 3783 | % o exception: return any errors or warnings in this structure. |
| 3784 | % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3785 | */ |
| 3786 | MagickExport MagickBooleanType SetImageProperty(Image *image, |
cristy | d15e659 | 2011-10-15 00:13:06 +0000 | [diff] [blame] | 3787 | const char *property,const char *value,ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3788 | { |
| 3789 | MagickBooleanType |
| 3790 | status; |
| 3791 | |
| 3792 | MagickStatusType |
| 3793 | flags; |
| 3794 | |
| 3795 | assert(image != (Image *) NULL); |
cristy | e1c94d9 | 2015-06-28 12:16:33 +0000 | [diff] [blame] | 3796 | assert(image->signature == MagickCoreSignature); |
cristy | cb190b7 | 2014-08-31 20:04:42 +0000 | [diff] [blame] | 3797 | if (image->debug != MagickFalse) |
anthony | 6e2e073 | 2012-05-06 12:22:43 +0000 | [diff] [blame] | 3798 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3799 | if (image->properties == (void *) NULL) |
| 3800 | image->properties=NewSplayTree(CompareSplayTreeString, |
cristy | 8c8d3f5 | 2014-02-14 02:22:14 +0000 | [diff] [blame] | 3801 | RelinquishMagickMemory,RelinquishMagickMemory); /* create splay-tree */ |
glennrp | 9831cc4 | 2013-01-08 19:08:31 +0000 | [diff] [blame] | 3802 | if (value == (const char *) NULL) |
cristy | 8c8d3f5 | 2014-02-14 02:22:14 +0000 | [diff] [blame] | 3803 | return(DeleteImageProperty(image,property)); /* delete if NULL */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3804 | status=MagickTrue; |
anthony | 6e2e073 | 2012-05-06 12:22:43 +0000 | [diff] [blame] | 3805 | if (strlen(property) <= 1) |
| 3806 | { |
cristy | 8c8d3f5 | 2014-02-14 02:22:14 +0000 | [diff] [blame] | 3807 | /* |
| 3808 | Do not 'set' single letter properties - read only shorthand. |
| 3809 | */ |
| 3810 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, |
| 3811 | "SetReadOnlyProperty","`%s'",property); |
anthony | 6e2e073 | 2012-05-06 12:22:43 +0000 | [diff] [blame] | 3812 | return(MagickFalse); |
| 3813 | } |
anthony | 7bb7aee | 2012-05-15 00:09:16 +0000 | [diff] [blame] | 3814 | |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3815 | /* FUTURE: binary chars or quotes in key should produce a error */ |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3816 | /* Set attributes with known names or special prefixes |
| 3817 | return result is found, or break to set a free form properity |
| 3818 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3819 | switch (*property) |
| 3820 | { |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3821 | #if 0 /* Percent escape's sets values with this prefix: for later use |
| 3822 | Throwing an exception causes this setting to fail */ |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3823 | case '8': |
| 3824 | { |
| 3825 | if (LocaleNCompare("8bim:",property,5) == 0) |
| 3826 | { |
| 3827 | (void) ThrowMagickException(exception,GetMagickModule(), |
cristy | efe601c | 2013-01-05 17:51:12 +0000 | [diff] [blame] | 3828 | OptionError,"SetReadOnlyProperty","`%s'",property); |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3829 | return(MagickFalse); |
| 3830 | } |
| 3831 | break; |
| 3832 | } |
anthony | c99875a | 2012-11-14 05:22:17 +0000 | [diff] [blame] | 3833 | #endif |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3834 | case 'B': |
| 3835 | case 'b': |
| 3836 | { |
anthony | 2f7f9ca | 2012-05-14 06:33:53 +0000 | [diff] [blame] | 3837 | if (LocaleCompare("background",property) == 0) |
cristy | c6c08ab | 2010-07-24 23:50:09 +0000 | [diff] [blame] | 3838 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 3839 | (void) QueryColorCompliance(value,AllCompliance, |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3840 | &image->background_color,exception); |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3841 | /* check for FUTURE: value exception?? */ |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3842 | /* also add user input to splay tree */ |
cristy | c6c08ab | 2010-07-24 23:50:09 +0000 | [diff] [blame] | 3843 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3844 | break; /* not an attribute, add as a property */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3845 | } |
| 3846 | case 'C': |
| 3847 | case 'c': |
| 3848 | { |
anthony | 2f7f9ca | 2012-05-14 06:33:53 +0000 | [diff] [blame] | 3849 | if (LocaleCompare("channels",property) == 0) |
anthony | 6e2e073 | 2012-05-06 12:22:43 +0000 | [diff] [blame] | 3850 | { |
cristy | 8c8d3f5 | 2014-02-14 02:22:14 +0000 | [diff] [blame] | 3851 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, |
| 3852 | "SetReadOnlyProperty","`%s'",property); |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3853 | return(MagickFalse); |
anthony | 6e2e073 | 2012-05-06 12:22:43 +0000 | [diff] [blame] | 3854 | } |
anthony | 2f7f9ca | 2012-05-14 06:33:53 +0000 | [diff] [blame] | 3855 | if (LocaleCompare("colorspace",property) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3856 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3857 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3858 | colorspace; |
| 3859 | |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3860 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3861 | value); |
| 3862 | if (colorspace < 0) |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3863 | return(MagickFalse); /* FUTURE: value exception?? */ |
cristy | 220c4d5 | 2013-11-27 19:31:32 +0000 | [diff] [blame] | 3864 | return(SetImageColorspace(image,(ColorspaceType) colorspace,exception)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3865 | } |
anthony | 2f7f9ca | 2012-05-14 06:33:53 +0000 | [diff] [blame] | 3866 | if (LocaleCompare("compose",property) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3867 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3868 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3869 | compose; |
| 3870 | |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3871 | compose=ParseCommandOption(MagickComposeOptions,MagickFalse,value); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3872 | if (compose < 0) |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3873 | return(MagickFalse); /* FUTURE: value exception?? */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3874 | image->compose=(CompositeOperator) compose; |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3875 | return(MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3876 | } |
anthony | 2f7f9ca | 2012-05-14 06:33:53 +0000 | [diff] [blame] | 3877 | if (LocaleCompare("compress",property) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3878 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3879 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3880 | compression; |
| 3881 | |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3882 | compression=ParseCommandOption(MagickCompressOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3883 | value); |
| 3884 | if (compression < 0) |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3885 | return(MagickFalse); /* FUTURE: value exception?? */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3886 | image->compression=(CompressionType) compression; |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3887 | return(MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3888 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3889 | break; /* not an attribute, add as a property */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3890 | } |
| 3891 | case 'D': |
| 3892 | case 'd': |
| 3893 | { |
anthony | 2f7f9ca | 2012-05-14 06:33:53 +0000 | [diff] [blame] | 3894 | if (LocaleCompare("delay",property) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3895 | { |
| 3896 | GeometryInfo |
| 3897 | geometry_info; |
| 3898 | |
| 3899 | flags=ParseGeometry(value,&geometry_info); |
| 3900 | if ((flags & GreaterValue) != 0) |
| 3901 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3902 | if (image->delay > (size_t) floor(geometry_info.rho+0.5)) |
| 3903 | image->delay=(size_t) floor(geometry_info.rho+0.5); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3904 | } |
| 3905 | else |
| 3906 | if ((flags & LessValue) != 0) |
| 3907 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3908 | if (image->delay < (size_t) floor(geometry_info.rho+0.5)) |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3909 | image->delay=(ssize_t) |
cristy | c6c08ab | 2010-07-24 23:50:09 +0000 | [diff] [blame] | 3910 | floor(geometry_info.sigma+0.5); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3911 | } |
| 3912 | else |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3913 | image->delay=(size_t) floor(geometry_info.rho+0.5); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3914 | if ((flags & SigmaValue) != 0) |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3915 | image->ticks_per_second=(ssize_t) floor(geometry_info.sigma+0.5); |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3916 | return(MagickTrue); |
| 3917 | } |
| 3918 | if (LocaleCompare("delay_units",property) == 0) |
| 3919 | { |
| 3920 | (void) ThrowMagickException(exception,GetMagickModule(), |
cristy | efe601c | 2013-01-05 17:51:12 +0000 | [diff] [blame] | 3921 | OptionError,"SetReadOnlyProperty","`%s'",property); |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3922 | return(MagickFalse); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3923 | } |
anthony | 2f7f9ca | 2012-05-14 06:33:53 +0000 | [diff] [blame] | 3924 | if (LocaleCompare("density",property) == 0) |
cristy | fbb5684 | 2010-08-02 11:26:33 +0000 | [diff] [blame] | 3925 | { |
| 3926 | GeometryInfo |
| 3927 | geometry_info; |
| 3928 | |
| 3929 | flags=ParseGeometry(value,&geometry_info); |
cristy | 2a11bef | 2011-10-28 18:33:11 +0000 | [diff] [blame] | 3930 | image->resolution.x=geometry_info.rho; |
| 3931 | image->resolution.y=geometry_info.sigma; |
cristy | fbb5684 | 2010-08-02 11:26:33 +0000 | [diff] [blame] | 3932 | if ((flags & SigmaValue) == 0) |
cristy | 2a11bef | 2011-10-28 18:33:11 +0000 | [diff] [blame] | 3933 | image->resolution.y=image->resolution.x; |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3934 | return(MagickTrue); |
cristy | fbb5684 | 2010-08-02 11:26:33 +0000 | [diff] [blame] | 3935 | } |
anthony | 2f7f9ca | 2012-05-14 06:33:53 +0000 | [diff] [blame] | 3936 | if (LocaleCompare("depth",property) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3937 | { |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 3938 | image->depth=StringToUnsignedLong(value); |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3939 | return(MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3940 | } |
anthony | 2f7f9ca | 2012-05-14 06:33:53 +0000 | [diff] [blame] | 3941 | if (LocaleCompare("dispose",property) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3942 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3943 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3944 | dispose; |
| 3945 | |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3946 | dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,value); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3947 | if (dispose < 0) |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3948 | return(MagickFalse); /* FUTURE: value exception?? */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3949 | image->dispose=(DisposeType) dispose; |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3950 | return(MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3951 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3952 | break; /* not an attribute, add as a property */ |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3953 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3954 | #if 0 /* Percent escape's sets values with this prefix: for later use |
| 3955 | Throwing an exception causes this setting to fail */ |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3956 | case 'E': |
| 3957 | case 'e': |
| 3958 | { |
| 3959 | if (LocaleNCompare("exif:",property,5) == 0) |
| 3960 | { |
| 3961 | (void) ThrowMagickException(exception,GetMagickModule(), |
cristy | efe601c | 2013-01-05 17:51:12 +0000 | [diff] [blame] | 3962 | OptionError,"SetReadOnlyProperty","`%s'",property); |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3963 | return(MagickFalse); |
| 3964 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3965 | break; /* not an attribute, add as a property */ |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3966 | } |
| 3967 | case 'F': |
| 3968 | case 'f': |
| 3969 | { |
| 3970 | if (LocaleNCompare("fx:",property,3) == 0) |
| 3971 | { |
| 3972 | (void) ThrowMagickException(exception,GetMagickModule(), |
cristy | efe601c | 2013-01-05 17:51:12 +0000 | [diff] [blame] | 3973 | OptionError,"SetReadOnlyProperty","`%s'",property); |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3974 | return(MagickFalse); |
| 3975 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3976 | break; /* not an attribute, add as a property */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3977 | } |
anthony | c99875a | 2012-11-14 05:22:17 +0000 | [diff] [blame] | 3978 | #endif |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3979 | case 'G': |
| 3980 | case 'g': |
| 3981 | { |
anthony | 2f7f9ca | 2012-05-14 06:33:53 +0000 | [diff] [blame] | 3982 | if (LocaleCompare("gamma",property) == 0) |
| 3983 | { |
| 3984 | image->gamma=StringToDouble(value,(char **) NULL); |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3985 | return(MagickTrue); |
anthony | 2f7f9ca | 2012-05-14 06:33:53 +0000 | [diff] [blame] | 3986 | } |
| 3987 | if (LocaleCompare("gravity",property) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3988 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3989 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3990 | gravity; |
| 3991 | |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3992 | gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3993 | if (gravity < 0) |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3994 | return(MagickFalse); /* FUTURE: value exception?? */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3995 | image->gravity=(GravityType) gravity; |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 3996 | return(MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3997 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 3998 | break; /* not an attribute, add as a property */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3999 | } |
anthony | 6e2e073 | 2012-05-06 12:22:43 +0000 | [diff] [blame] | 4000 | case 'H': |
| 4001 | case 'h': |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 4002 | { |
anthony | 2f7f9ca | 2012-05-14 06:33:53 +0000 | [diff] [blame] | 4003 | if (LocaleCompare("height",property) == 0) |
anthony | 6e2e073 | 2012-05-06 12:22:43 +0000 | [diff] [blame] | 4004 | { |
| 4005 | (void) ThrowMagickException(exception,GetMagickModule(), |
cristy | efe601c | 2013-01-05 17:51:12 +0000 | [diff] [blame] | 4006 | OptionError,"SetReadOnlyProperty","`%s'",property); |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 4007 | return(MagickFalse); |
anthony | 6e2e073 | 2012-05-06 12:22:43 +0000 | [diff] [blame] | 4008 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4009 | break; /* not an attribute, add as a property */ |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 4010 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4011 | case 'I': |
| 4012 | case 'i': |
| 4013 | { |
cristy | 70e9f68 | 2013-03-12 22:31:22 +0000 | [diff] [blame] | 4014 | if (LocaleCompare("intensity",property) == 0) |
| 4015 | { |
| 4016 | ssize_t |
| 4017 | intensity; |
| 4018 | |
| 4019 | intensity=ParseCommandOption(MagickIntentOptions,MagickFalse, |
| 4020 | value); |
| 4021 | if (intensity < 0) |
| 4022 | return(MagickFalse); |
| 4023 | image->intensity=(PixelIntensityMethod) intensity; |
| 4024 | return(MagickTrue); |
| 4025 | } |
anthony | 2f7f9ca | 2012-05-14 06:33:53 +0000 | [diff] [blame] | 4026 | if (LocaleCompare("intent",property) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4027 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4028 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4029 | rendering_intent; |
| 4030 | |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4031 | rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4032 | value); |
| 4033 | if (rendering_intent < 0) |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4034 | return(MagickFalse); /* FUTURE: value exception?? */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4035 | image->rendering_intent=(RenderingIntent) rendering_intent; |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 4036 | return(MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4037 | } |
anthony | 2f7f9ca | 2012-05-14 06:33:53 +0000 | [diff] [blame] | 4038 | if (LocaleCompare("interpolate",property) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4039 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4040 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4041 | interpolate; |
| 4042 | |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4043 | interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4044 | value); |
| 4045 | if (interpolate < 0) |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4046 | return(MagickFalse); /* FUTURE: value exception?? */ |
cristy | 5c4e258 | 2011-09-11 19:21:03 +0000 | [diff] [blame] | 4047 | image->interpolate=(PixelInterpolateMethod) interpolate; |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 4048 | return(MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4049 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4050 | #if 0 /* Percent escape's sets values with this prefix: for later use |
| 4051 | Throwing an exception causes this setting to fail */ |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 4052 | if (LocaleNCompare("iptc:",property,5) == 0) |
| 4053 | { |
| 4054 | (void) ThrowMagickException(exception,GetMagickModule(), |
cristy | efe601c | 2013-01-05 17:51:12 +0000 | [diff] [blame] | 4055 | OptionError,"SetReadOnlyProperty","`%s'",property); |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 4056 | return(MagickFalse); |
| 4057 | } |
anthony | c99875a | 2012-11-14 05:22:17 +0000 | [diff] [blame] | 4058 | #endif |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4059 | break; /* not an attribute, add as a property */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4060 | } |
anthony | 6e2e073 | 2012-05-06 12:22:43 +0000 | [diff] [blame] | 4061 | case 'K': |
| 4062 | case 'k': |
anthony | 2f7f9ca | 2012-05-14 06:33:53 +0000 | [diff] [blame] | 4063 | if (LocaleCompare("kurtosis",property) == 0) |
anthony | 6e2e073 | 2012-05-06 12:22:43 +0000 | [diff] [blame] | 4064 | { |
| 4065 | (void) ThrowMagickException(exception,GetMagickModule(), |
cristy | efe601c | 2013-01-05 17:51:12 +0000 | [diff] [blame] | 4066 | OptionError,"SetReadOnlyProperty","`%s'",property); |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 4067 | return(MagickFalse); |
anthony | 6e2e073 | 2012-05-06 12:22:43 +0000 | [diff] [blame] | 4068 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4069 | break; /* not an attribute, add as a property */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4070 | case 'L': |
| 4071 | case 'l': |
| 4072 | { |
anthony | 2f7f9ca | 2012-05-14 06:33:53 +0000 | [diff] [blame] | 4073 | if (LocaleCompare("loop",property) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4074 | { |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 4075 | image->iterations=StringToUnsignedLong(value); |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 4076 | return(MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4077 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4078 | break; /* not an attribute, add as a property */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4079 | } |
anthony | 6e2e073 | 2012-05-06 12:22:43 +0000 | [diff] [blame] | 4080 | case 'M': |
| 4081 | case 'm': |
anthony | 2f7f9ca | 2012-05-14 06:33:53 +0000 | [diff] [blame] | 4082 | if ( (LocaleCompare("magick",property) == 0) || |
| 4083 | (LocaleCompare("max",property) == 0) || |
| 4084 | (LocaleCompare("mean",property) == 0) || |
| 4085 | (LocaleCompare("min",property) == 0) || |
| 4086 | (LocaleCompare("min",property) == 0) ) |
anthony | 6e2e073 | 2012-05-06 12:22:43 +0000 | [diff] [blame] | 4087 | { |
cristy | 5048d30 | 2012-08-07 01:05:16 +0000 | [diff] [blame] | 4088 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, |
cristy | efe601c | 2013-01-05 17:51:12 +0000 | [diff] [blame] | 4089 | "SetReadOnlyProperty","`%s'",property); |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 4090 | return(MagickFalse); |
anthony | 6e2e073 | 2012-05-06 12:22:43 +0000 | [diff] [blame] | 4091 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4092 | break; /* not an attribute, add as a property */ |
anthony | 6e2e073 | 2012-05-06 12:22:43 +0000 | [diff] [blame] | 4093 | case 'O': |
| 4094 | case 'o': |
anthony | 2f7f9ca | 2012-05-14 06:33:53 +0000 | [diff] [blame] | 4095 | if (LocaleCompare("opaque",property) == 0) |
anthony | 6e2e073 | 2012-05-06 12:22:43 +0000 | [diff] [blame] | 4096 | { |
| 4097 | (void) ThrowMagickException(exception,GetMagickModule(), |
cristy | efe601c | 2013-01-05 17:51:12 +0000 | [diff] [blame] | 4098 | OptionError,"SetReadOnlyProperty","`%s'",property); |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 4099 | return(MagickFalse); |
anthony | 6e2e073 | 2012-05-06 12:22:43 +0000 | [diff] [blame] | 4100 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4101 | break; /* not an attribute, add as a property */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4102 | case 'P': |
| 4103 | case 'p': |
| 4104 | { |
anthony | 2f7f9ca | 2012-05-14 06:33:53 +0000 | [diff] [blame] | 4105 | if (LocaleCompare("page",property) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4106 | { |
| 4107 | char |
| 4108 | *geometry; |
| 4109 | |
| 4110 | geometry=GetPageGeometry(value); |
| 4111 | flags=ParseAbsoluteGeometry(geometry,&image->page); |
| 4112 | geometry=DestroyString(geometry); |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 4113 | return(MagickTrue); |
| 4114 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4115 | #if 0 /* Percent escape's sets values with this prefix: for later use |
| 4116 | Throwing an exception causes this setting to fail */ |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 4117 | if (LocaleNCompare("pixel:",property,6) == 0) |
| 4118 | { |
| 4119 | (void) ThrowMagickException(exception,GetMagickModule(), |
cristy | efe601c | 2013-01-05 17:51:12 +0000 | [diff] [blame] | 4120 | OptionError,"SetReadOnlyProperty","`%s'",property); |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 4121 | return(MagickFalse); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4122 | } |
anthony | c99875a | 2012-11-14 05:22:17 +0000 | [diff] [blame] | 4123 | #endif |
anthony | 2f7f9ca | 2012-05-14 06:33:53 +0000 | [diff] [blame] | 4124 | if (LocaleCompare("profile",property) == 0) |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 4125 | { |
| 4126 | ImageInfo |
| 4127 | *image_info; |
| 4128 | |
| 4129 | StringInfo |
| 4130 | *profile; |
| 4131 | |
| 4132 | image_info=AcquireImageInfo(); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 4133 | (void) CopyMagickString(image_info->filename,value,MagickPathExtent); |
cristy | c6c08ab | 2010-07-24 23:50:09 +0000 | [diff] [blame] | 4134 | (void) SetImageInfo(image_info,1,exception); |
| 4135 | profile=FileToStringInfo(image_info->filename,~0UL,exception); |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 4136 | if (profile != (StringInfo *) NULL) |
cristy | d15e659 | 2011-10-15 00:13:06 +0000 | [diff] [blame] | 4137 | status=SetImageProfile(image,image_info->magick,profile,exception); |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 4138 | image_info=DestroyImageInfo(image_info); |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 4139 | return(MagickTrue); |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 4140 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4141 | break; /* not an attribute, add as a property */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4142 | } |
| 4143 | case 'R': |
| 4144 | case 'r': |
| 4145 | { |
anthony | 2f7f9ca | 2012-05-14 06:33:53 +0000 | [diff] [blame] | 4146 | if (LocaleCompare("rendering-intent",property) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4147 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4148 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4149 | rendering_intent; |
| 4150 | |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4151 | rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4152 | value); |
| 4153 | if (rendering_intent < 0) |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4154 | return(MagickFalse); /* FUTURE: value exception?? */ |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 4155 | image->rendering_intent=(RenderingIntent) rendering_intent; |
| 4156 | return(MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4157 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4158 | break; /* not an attribute, add as a property */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4159 | } |
anthony | 6e2e073 | 2012-05-06 12:22:43 +0000 | [diff] [blame] | 4160 | case 'S': |
| 4161 | case 's': |
anthony | 2f7f9ca | 2012-05-14 06:33:53 +0000 | [diff] [blame] | 4162 | if ( (LocaleCompare("size",property) == 0) || |
| 4163 | (LocaleCompare("skewness",property) == 0) || |
| 4164 | (LocaleCompare("scenes",property) == 0) || |
| 4165 | (LocaleCompare("standard-deviation",property) == 0) ) |
anthony | 6e2e073 | 2012-05-06 12:22:43 +0000 | [diff] [blame] | 4166 | { |
| 4167 | (void) ThrowMagickException(exception,GetMagickModule(), |
cristy | efe601c | 2013-01-05 17:51:12 +0000 | [diff] [blame] | 4168 | OptionError,"SetReadOnlyProperty","`%s'",property); |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 4169 | return(MagickFalse); |
anthony | 6e2e073 | 2012-05-06 12:22:43 +0000 | [diff] [blame] | 4170 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4171 | break; /* not an attribute, add as a property */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4172 | case 'T': |
| 4173 | case 't': |
| 4174 | { |
anthony | 2f7f9ca | 2012-05-14 06:33:53 +0000 | [diff] [blame] | 4175 | if (LocaleCompare("tile-offset",property) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4176 | { |
| 4177 | char |
| 4178 | *geometry; |
| 4179 | |
| 4180 | geometry=GetPageGeometry(value); |
| 4181 | flags=ParseAbsoluteGeometry(geometry,&image->tile_offset); |
| 4182 | geometry=DestroyString(geometry); |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 4183 | return(MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4184 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4185 | break; /* not an attribute, add as a property */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4186 | } |
cristy | fbb5684 | 2010-08-02 11:26:33 +0000 | [diff] [blame] | 4187 | case 'U': |
| 4188 | case 'u': |
| 4189 | { |
anthony | 2f7f9ca | 2012-05-14 06:33:53 +0000 | [diff] [blame] | 4190 | if (LocaleCompare("units",property) == 0) |
cristy | fbb5684 | 2010-08-02 11:26:33 +0000 | [diff] [blame] | 4191 | { |
| 4192 | ssize_t |
| 4193 | units; |
| 4194 | |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4195 | units=ParseCommandOption(MagickResolutionOptions,MagickFalse,value); |
cristy | fbb5684 | 2010-08-02 11:26:33 +0000 | [diff] [blame] | 4196 | if (units < 0) |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4197 | return(MagickFalse); /* FUTURE: value exception?? */ |
cristy | fbb5684 | 2010-08-02 11:26:33 +0000 | [diff] [blame] | 4198 | image->units=(ResolutionType) units; |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 4199 | return(MagickTrue); |
cristy | fbb5684 | 2010-08-02 11:26:33 +0000 | [diff] [blame] | 4200 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4201 | break; /* not an attribute, add as a property */ |
cristy | fbb5684 | 2010-08-02 11:26:33 +0000 | [diff] [blame] | 4202 | } |
anthony | 6e2e073 | 2012-05-06 12:22:43 +0000 | [diff] [blame] | 4203 | case 'V': |
| 4204 | case 'v': |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 4205 | { |
anthony | 2f7f9ca | 2012-05-14 06:33:53 +0000 | [diff] [blame] | 4206 | if (LocaleCompare("version",property) == 0) |
anthony | 6e2e073 | 2012-05-06 12:22:43 +0000 | [diff] [blame] | 4207 | { |
| 4208 | (void) ThrowMagickException(exception,GetMagickModule(), |
cristy | efe601c | 2013-01-05 17:51:12 +0000 | [diff] [blame] | 4209 | OptionError,"SetReadOnlyProperty","`%s'",property); |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 4210 | return(MagickFalse); |
anthony | 6e2e073 | 2012-05-06 12:22:43 +0000 | [diff] [blame] | 4211 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4212 | break; /* not an attribute, add as a property */ |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 4213 | } |
anthony | 6e2e073 | 2012-05-06 12:22:43 +0000 | [diff] [blame] | 4214 | case 'W': |
| 4215 | case 'w': |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 4216 | { |
anthony | 2f7f9ca | 2012-05-14 06:33:53 +0000 | [diff] [blame] | 4217 | if (LocaleCompare("width",property) == 0) |
anthony | 6e2e073 | 2012-05-06 12:22:43 +0000 | [diff] [blame] | 4218 | { |
| 4219 | (void) ThrowMagickException(exception,GetMagickModule(), |
cristy | efe601c | 2013-01-05 17:51:12 +0000 | [diff] [blame] | 4220 | OptionError,"SetReadOnlyProperty","`%s'",property); |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 4221 | return(MagickFalse); |
anthony | 6e2e073 | 2012-05-06 12:22:43 +0000 | [diff] [blame] | 4222 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4223 | break; /* not an attribute, add as a property */ |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 4224 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4225 | #if 0 /* Percent escape's sets values with this prefix: for later use |
| 4226 | Throwing an exception causes this setting to fail */ |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 4227 | case 'X': |
| 4228 | case 'x': |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4229 | { |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 4230 | if (LocaleNCompare("xmp:",property,4) == 0) |
| 4231 | { |
| 4232 | (void) ThrowMagickException(exception,GetMagickModule(), |
cristy | efe601c | 2013-01-05 17:51:12 +0000 | [diff] [blame] | 4233 | OptionError,"SetReadOnlyProperty","`%s'",property); |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 4234 | return(MagickFalse); |
| 4235 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4236 | break; /* not an attribute, add as a property */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4237 | } |
anthony | c99875a | 2012-11-14 05:22:17 +0000 | [diff] [blame] | 4238 | #endif |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4239 | } |
anthony | a322a83 | 2013-04-27 06:28:03 +0000 | [diff] [blame] | 4240 | /* Default: not an attribute, add as a property */ |
anthony | 643c613 | 2012-11-07 14:50:28 +0000 | [diff] [blame] | 4241 | status=AddValueToSplayTree((SplayTreeInfo *) image->properties, |
| 4242 | ConstantString(property),ConstantString(value)); |
| 4243 | /* FUTURE: error if status is bad? */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4244 | return(status); |
| 4245 | } |