MagickCore  7.0.3
constitute.c
Go to the documentation of this file.
1 /*
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 % %
4 % %
5 % %
6 % CCCC OOO N N SSSSS TTTTT IIIII TTTTT U U TTTTT EEEEE %
7 % C O O NN N SS T I T U U T E %
8 % C O O N N N ESSS T I T U U T EEE %
9 % C O O N NN SS T I T U U T E %
10 % CCCC OOO N N SSSSS T IIIII T UUU T EEEEE %
11 % %
12 % %
13 % MagickCore Methods to Consitute an Image %
14 % %
15 % Software Design %
16 % Cristy %
17 % October 1998 %
18 % %
19 % %
20 % Copyright 1999-2019 ImageMagick Studio LLC, a non-profit organization %
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 % https://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 
39 /*
40  Include declarations.
41 */
42 #include "MagickCore/studio.h"
43 #include "MagickCore/attribute.h"
44 #include "MagickCore/blob.h"
46 #include "MagickCore/exception.h"
48 #include "MagickCore/cache.h"
49 #include "MagickCore/client.h"
52 #include "MagickCore/constitute.h"
54 #include "MagickCore/delegate.h"
55 #include "MagickCore/geometry.h"
56 #include "MagickCore/identify.h"
58 #include "MagickCore/list.h"
59 #include "MagickCore/magick.h"
60 #include "MagickCore/memory_.h"
61 #include "MagickCore/monitor.h"
63 #include "MagickCore/option.h"
64 #include "MagickCore/pixel.h"
66 #include "MagickCore/policy.h"
67 #include "MagickCore/profile.h"
69 #include "MagickCore/property.h"
70 #include "MagickCore/quantum.h"
71 #include "MagickCore/resize.h"
72 #include "MagickCore/resource_.h"
73 #include "MagickCore/semaphore.h"
74 #include "MagickCore/statistic.h"
75 #include "MagickCore/stream.h"
76 #include "MagickCore/string_.h"
78 #include "MagickCore/timer.h"
79 #include "MagickCore/token.h"
80 #include "MagickCore/transform.h"
81 #include "MagickCore/utility.h"
83 
84 /*
85 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
86 % %
87 % %
88 % %
89 % C o n s t i t u t e I m a g e %
90 % %
91 % %
92 % %
93 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
94 %
95 % ConstituteImage() returns an image from the pixel data you supply.
96 % The pixel data must be in scanline order top-to-bottom. The data can be
97 % char, short int, int, float, or double. Float and double require the
98 % pixels to be normalized [0..1], otherwise [0..QuantumRange]. For example, to
99 % create a 640x480 image from unsigned red-green-blue character data, use:
100 %
101 % image = ConstituteImage(640,480,"RGB",CharPixel,pixels,&exception);
102 %
103 % The format of the ConstituteImage method is:
104 %
105 % Image *ConstituteImage(const size_t columns,const size_t rows,
106 % const char *map,const StorageType storage,const void *pixels,
107 % ExceptionInfo *exception)
108 %
109 % A description of each parameter follows:
110 %
111 % o columns: width in pixels of the image.
112 %
113 % o rows: height in pixels of the image.
114 %
115 % o map: This string reflects the expected ordering of the pixel array.
116 % It can be any combination or order of R = red, G = green, B = blue,
117 % A = alpha (0 is transparent), O = opacity (0 is opaque), C = cyan,
118 % Y = yellow, M = magenta, K = black, I = intensity (for grayscale),
119 % P = pad.
120 %
121 % o storage: Define the data type of the pixels. Float and double types are
122 % expected to be normalized [0..1] otherwise [0..QuantumRange]. Choose
123 % from these types: CharPixel, DoublePixel, FloatPixel, IntegerPixel,
124 % LongPixel, QuantumPixel, or ShortPixel.
125 %
126 % o pixels: This array of values contain the pixel components as defined by
127 % map and type. You must preallocate this array where the expected
128 % length varies depending on the values of width, height, map, and type.
129 %
130 % o exception: return any errors or warnings in this structure.
131 %
132 */
133 MagickExport Image *ConstituteImage(const size_t columns,const size_t rows,
134  const char *map,const StorageType storage,const void *pixels,
135  ExceptionInfo *exception)
136 {
137  Image
138  *image;
139 
141  status;
142 
143  register ssize_t
144  i;
145 
146  size_t
147  length;
148 
149  /*
150  Allocate image structure.
151  */
152  assert(map != (const char *) NULL);
153  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",map);
154  assert(pixels != (void *) NULL);
155  assert(exception != (ExceptionInfo *) NULL);
156  assert(exception->signature == MagickCoreSignature);
157  image=AcquireImage((ImageInfo *) NULL,exception);
158  if (image == (Image *) NULL)
159  return((Image *) NULL);
160  length=strlen(map);
161  for (i=0; i < (ssize_t) length; i++)
162  {
163  switch (map[i])
164  {
165  case 'a':
166  case 'A':
167  case 'O':
168  case 'o':
169  {
171  break;
172  }
173  case 'C':
174  case 'c':
175  case 'm':
176  case 'M':
177  case 'Y':
178  case 'y':
179  case 'K':
180  case 'k':
181  {
182  image->colorspace=CMYKColorspace;
183  break;
184  }
185  case 'I':
186  case 'i':
187  {
188  image->colorspace=GRAYColorspace;
189  break;
190  }
191  default:
192  {
193  if (length == 1)
194  image->colorspace=GRAYColorspace;
195  break;
196  }
197  }
198  }
199  status=SetImageExtent(image,columns,rows,exception);
200  if (status == MagickFalse)
201  return(DestroyImageList(image));
202  status=ResetImagePixels(image,exception);
203  if (status == MagickFalse)
204  return(DestroyImageList(image));
205  status=ImportImagePixels(image,0,0,columns,rows,map,storage,pixels,exception);
206  if (status == MagickFalse)
207  image=DestroyImage(image);
208  return(image);
209 }
210 
211 /*
212 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
213 % %
214 % %
215 % %
216 % P i n g I m a g e %
217 % %
218 % %
219 % %
220 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
221 %
222 % PingImage() returns all the properties of an image or image sequence
223 % except for the pixels. It is much faster and consumes far less memory
224 % than ReadImage(). On failure, a NULL image is returned and exception
225 % describes the reason for the failure.
226 %
227 % The format of the PingImage method is:
228 %
229 % Image *PingImage(const ImageInfo *image_info,ExceptionInfo *exception)
230 %
231 % A description of each parameter follows:
232 %
233 % o image_info: Ping the image defined by the file or filename members of
234 % this structure.
235 %
236 % o exception: return any errors or warnings in this structure.
237 %
238 */
239 
240 #if defined(__cplusplus) || defined(c_plusplus)
241 extern "C" {
242 #endif
243 
244 static size_t PingStream(const Image *magick_unused(image),
245  const void *magick_unused(pixels),const size_t columns)
246 {
247  magick_unreferenced(image);
248  magick_unreferenced(pixels);
249  return(columns);
250 }
251 
252 #if defined(__cplusplus) || defined(c_plusplus)
253 }
254 #endif
255 
257  ExceptionInfo *exception)
258 {
259  Image
260  *image;
261 
262  ImageInfo
263  *ping_info;
264 
265  assert(image_info != (ImageInfo *) NULL);
266  assert(image_info->signature == MagickCoreSignature);
267  if (image_info->debug != MagickFalse)
269  image_info->filename);
270  assert(exception != (ExceptionInfo *) NULL);
271  ping_info=CloneImageInfo(image_info);
272  ping_info->ping=MagickTrue;
273  image=ReadStream(ping_info,&PingStream,exception);
274  if (image != (Image *) NULL)
275  {
276  ResetTimer(&image->timer);
277  if (ping_info->verbose != MagickFalse)
278  (void) IdentifyImage(image,stdout,MagickFalse,exception);
279  }
280  ping_info=DestroyImageInfo(ping_info);
281  return(image);
282 }
283 
284 /*
285 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
286 % %
287 % %
288 % %
289 % P i n g I m a g e s %
290 % %
291 % %
292 % %
293 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
294 %
295 % PingImages() pings one or more images and returns them as an image list.
296 %
297 % The format of the PingImage method is:
298 %
299 % Image *PingImages(ImageInfo *image_info,const char *filename,
300 % ExceptionInfo *exception)
301 %
302 % A description of each parameter follows:
303 %
304 % o image_info: the image info.
305 %
306 % o filename: the image filename.
307 %
308 % o exception: return any errors or warnings in this structure.
309 %
310 */
311 MagickExport Image *PingImages(ImageInfo *image_info,const char *filename,
312  ExceptionInfo *exception)
313 {
314  char
315  ping_filename[MagickPathExtent];
316 
317  Image
318  *image,
319  *images;
320 
321  ImageInfo
322  *read_info;
323 
324  /*
325  Ping image list from a file.
326  */
327  assert(image_info != (ImageInfo *) NULL);
328  assert(image_info->signature == MagickCoreSignature);
329  if (image_info->debug != MagickFalse)
331  image_info->filename);
332  assert(exception != (ExceptionInfo *) NULL);
333  (void) SetImageOption(image_info,"filename",filename);
334  (void) CopyMagickString(image_info->filename,filename,MagickPathExtent);
335  (void) InterpretImageFilename(image_info,(Image *) NULL,image_info->filename,
336  (int) image_info->scene,ping_filename,exception);
337  if (LocaleCompare(ping_filename,image_info->filename) != 0)
338  {
340  *sans;
341 
342  ssize_t
343  extent,
344  scene;
345 
346  /*
347  Images of the form image-%d.png[1-5].
348  */
349  read_info=CloneImageInfo(image_info);
350  sans=AcquireExceptionInfo();
351  (void) SetImageInfo(read_info,0,sans);
352  sans=DestroyExceptionInfo(sans);
353  if (read_info->number_scenes == 0)
354  {
355  read_info=DestroyImageInfo(read_info);
356  return(PingImage(image_info,exception));
357  }
358  (void) CopyMagickString(ping_filename,read_info->filename,
360  images=NewImageList();
361  extent=(ssize_t) (read_info->scene+read_info->number_scenes);
362  for (scene=(ssize_t) read_info->scene; scene < (ssize_t) extent; scene++)
363  {
364  (void) InterpretImageFilename(image_info,(Image *) NULL,ping_filename,
365  (int) scene,read_info->filename,exception);
366  image=PingImage(read_info,exception);
367  if (image == (Image *) NULL)
368  continue;
369  AppendImageToList(&images,image);
370  }
371  read_info=DestroyImageInfo(read_info);
372  return(images);
373  }
374  return(PingImage(image_info,exception));
375 }
376 
377 /*
378 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
379 % %
380 % %
381 % %
382 % R e a d I m a g e %
383 % %
384 % %
385 % %
386 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
387 %
388 % ReadImage() reads an image or image sequence from a file or file handle.
389 % The method returns a NULL if there is a memory shortage or if the image
390 % cannot be read. On failure, a NULL image is returned and exception
391 % describes the reason for the failure.
392 %
393 % The format of the ReadImage method is:
394 %
395 % Image *ReadImage(const ImageInfo *image_info,ExceptionInfo *exception)
396 %
397 % A description of each parameter follows:
398 %
399 % o image_info: Read the image defined by the file or filename members of
400 % this structure.
401 %
402 % o exception: return any errors or warnings in this structure.
403 %
404 */
405 
406 static MagickBooleanType IsCoderAuthorized(const char *coder,
407  const PolicyRights rights,ExceptionInfo *exception)
408 {
409  if (IsRightsAuthorized(CoderPolicyDomain,rights,coder) == MagickFalse)
410  {
411  errno=EPERM;
413  "NotAuthorized","`%s'",coder);
414  return(MagickFalse);
415  }
416  return(MagickTrue);
417 }
418 
420  ExceptionInfo *exception)
421 {
422  char
423  filename[MagickPathExtent],
424  magick[MagickPathExtent],
425  magick_filename[MagickPathExtent];
426 
427  const char
428  *value;
429 
430  const DelegateInfo
431  *delegate_info;
432 
433  const MagickInfo
434  *magick_info;
435 
437  *decoder;
438 
440  *sans_exception;
441 
443  geometry_info;
444 
445  Image
446  *image,
447  *next;
448 
449  ImageInfo
450  *read_info;
451 
453  status;
454 
456  flags;
457 
458  /*
459  Determine image type from filename prefix or suffix (e.g. image.jpg).
460  */
461  assert(image_info != (ImageInfo *) NULL);
462  assert(image_info->signature == MagickCoreSignature);
463  assert(image_info->filename != (char *) NULL);
464  if (image_info->debug != MagickFalse)
466  image_info->filename);
467  assert(exception != (ExceptionInfo *) NULL);
468  read_info=CloneImageInfo(image_info);
469  (void) CopyMagickString(magick_filename,read_info->filename,MagickPathExtent);
470  (void) SetImageInfo(read_info,0,exception);
471  (void) CopyMagickString(filename,read_info->filename,MagickPathExtent);
472  (void) CopyMagickString(magick,read_info->magick,MagickPathExtent);
473  /*
474  Call appropriate image reader based on image type.
475  */
476  sans_exception=AcquireExceptionInfo();
477  magick_info=GetMagickInfo(read_info->magick,sans_exception);
478  sans_exception=DestroyExceptionInfo(sans_exception);
479  if (magick_info != (const MagickInfo *) NULL)
480  {
481  if (GetMagickEndianSupport(magick_info) == MagickFalse)
482  read_info->endian=UndefinedEndian;
483  else
484  if ((image_info->endian == UndefinedEndian) &&
485  (GetMagickRawSupport(magick_info) != MagickFalse))
486  {
487  unsigned long
488  lsb_first;
489 
490  lsb_first=1;
491  read_info->endian=(*(char *) &lsb_first) == 1 ? LSBEndian :
492  MSBEndian;
493  }
494  }
495  if ((magick_info != (const MagickInfo *) NULL) &&
497  {
498  image=AcquireImage(read_info,exception);
499  (void) CopyMagickString(image->filename,read_info->filename,
501  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
502  if (status == MagickFalse)
503  {
504  read_info=DestroyImageInfo(read_info);
505  image=DestroyImage(image);
506  return((Image *) NULL);
507  }
508  if (IsBlobSeekable(image) == MagickFalse)
509  {
510  /*
511  Coder requires a seekable stream.
512  */
513  *read_info->filename='\0';
514  status=ImageToFile(image,read_info->filename,exception);
515  if (status == MagickFalse)
516  {
517  (void) CloseBlob(image);
518  read_info=DestroyImageInfo(read_info);
519  image=DestroyImage(image);
520  return((Image *) NULL);
521  }
522  read_info->temporary=MagickTrue;
523  }
524  (void) CloseBlob(image);
525  image=DestroyImage(image);
526  }
527  image=NewImageList();
528  decoder=GetImageDecoder(magick_info);
529  if (decoder == (DecodeImageHandler *) NULL)
530  {
531  delegate_info=GetDelegateInfo(read_info->magick,(char *) NULL,exception);
532  if (delegate_info == (const DelegateInfo *) NULL)
533  {
534  (void) SetImageInfo(read_info,0,exception);
535  (void) CopyMagickString(read_info->filename,filename,
537  magick_info=GetMagickInfo(read_info->magick,exception);
538  decoder=GetImageDecoder(magick_info);
539  }
540  }
541  if (decoder != (DecodeImageHandler *) NULL)
542  {
543  /*
544  Call appropriate image reader based on image type.
545  */
546  if (GetMagickDecoderThreadSupport(magick_info) == MagickFalse)
547  LockSemaphoreInfo(magick_info->semaphore);
548  status=IsCoderAuthorized(read_info->magick,ReadPolicyRights,exception);
549  image=(Image *) NULL;
550  if (status != MagickFalse)
551  image=decoder(read_info,exception);
552  if (GetMagickDecoderThreadSupport(magick_info) == MagickFalse)
553  UnlockSemaphoreInfo(magick_info->semaphore);
554  }
555  else
556  {
557  delegate_info=GetDelegateInfo(read_info->magick,(char *) NULL,exception);
558  if (delegate_info == (const DelegateInfo *) NULL)
559  {
560  (void) ThrowMagickException(exception,GetMagickModule(),
561  MissingDelegateError,"NoDecodeDelegateForThisImageFormat","`%s'",
562  read_info->magick);
563  if (read_info->temporary != MagickFalse)
564  (void) RelinquishUniqueFileResource(read_info->filename);
565  read_info=DestroyImageInfo(read_info);
566  return((Image *) NULL);
567  }
568  /*
569  Let our decoding delegate process the image.
570  */
571  image=AcquireImage(read_info,exception);
572  if (image == (Image *) NULL)
573  {
574  read_info=DestroyImageInfo(read_info);
575  return((Image *) NULL);
576  }
577  (void) CopyMagickString(image->filename,read_info->filename,
579  *read_info->filename='\0';
580  if (GetDelegateThreadSupport(delegate_info) == MagickFalse)
581  LockSemaphoreInfo(delegate_info->semaphore);
582  status=InvokeDelegate(read_info,image,read_info->magick,(char *) NULL,
583  exception);
584  if (GetDelegateThreadSupport(delegate_info) == MagickFalse)
585  UnlockSemaphoreInfo(delegate_info->semaphore);
586  image=DestroyImageList(image);
587  read_info->temporary=MagickTrue;
588  if (status != MagickFalse)
589  (void) SetImageInfo(read_info,0,exception);
590  magick_info=GetMagickInfo(read_info->magick,exception);
591  decoder=GetImageDecoder(magick_info);
592  if (decoder == (DecodeImageHandler *) NULL)
593  {
594  if (IsPathAccessible(read_info->filename) != MagickFalse)
595  (void) ThrowMagickException(exception,GetMagickModule(),
596  MissingDelegateError,"NoDecodeDelegateForThisImageFormat","`%s'",
597  read_info->magick);
598  else
599  ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
600  read_info->filename);
601  read_info=DestroyImageInfo(read_info);
602  return((Image *) NULL);
603  }
604  /*
605  Call appropriate image reader based on image type.
606  */
607  if (GetMagickDecoderThreadSupport(magick_info) == MagickFalse)
608  LockSemaphoreInfo(magick_info->semaphore);
609  status=IsCoderAuthorized(read_info->magick,ReadPolicyRights,exception);
610  image=(Image *) NULL;
611  if (status != MagickFalse)
612  image=(decoder)(read_info,exception);
613  if (GetMagickDecoderThreadSupport(magick_info) == MagickFalse)
614  UnlockSemaphoreInfo(magick_info->semaphore);
615  }
616  if (read_info->temporary != MagickFalse)
617  {
618  (void) RelinquishUniqueFileResource(read_info->filename);
619  read_info->temporary=MagickFalse;
620  if (image != (Image *) NULL)
621  (void) CopyMagickString(image->filename,filename,MagickPathExtent);
622  }
623  if (image == (Image *) NULL)
624  {
625  read_info=DestroyImageInfo(read_info);
626  return(image);
627  }
628  if (exception->severity >= ErrorException)
630  "Coder (%s) generated an image despite an error (%d), "
631  "notify the developers",image->magick,exception->severity);
632  if (IsBlobTemporary(image) != MagickFalse)
633  (void) RelinquishUniqueFileResource(read_info->filename);
634  if ((IsSceneGeometry(read_info->scenes,MagickFalse) != MagickFalse) &&
635  (GetImageListLength(image) != 1))
636  {
637  Image
638  *clones;
639 
640  clones=CloneImages(image,read_info->scenes,exception);
641  if (clones != (Image *) NULL)
642  {
643  image=DestroyImageList(image);
644  image=GetFirstImageInList(clones);
645  }
646  }
647  for (next=image; next != (Image *) NULL; next=GetNextImageInList(next))
648  {
649  char
650  magick_path[MagickPathExtent],
651  *property,
652  timestamp[MagickPathExtent];
653 
654  const char
655  *option;
656 
657  const StringInfo
658  *profile;
659 
660  ssize_t
661  option_type;
662 
663  next->taint=MagickFalse;
664  GetPathComponent(magick_filename,MagickPath,magick_path);
665  if (*magick_path == '\0' && *next->magick == '\0')
666  (void) CopyMagickString(next->magick,magick,MagickPathExtent);
667  (void) CopyMagickString(next->magick_filename,magick_filename,
669  if (IsBlobTemporary(image) != MagickFalse)
670  (void) CopyMagickString(next->filename,filename,MagickPathExtent);
671  if (next->magick_columns == 0)
672  next->magick_columns=next->columns;
673  if (next->magick_rows == 0)
674  next->magick_rows=next->rows;
675  value=GetImageProperty(next,"exif:Orientation",exception);
676  if (value == (char *) NULL)
677  value=GetImageProperty(next,"tiff:Orientation",exception);
678  if (value != (char *) NULL)
679  {
681  (void) DeleteImageProperty(next,"tiff:Orientation");
682  (void) DeleteImageProperty(next,"exif:Orientation");
683  }
684  value=GetImageProperty(next,"exif:XResolution",exception);
685  if (value != (char *) NULL)
686  {
687  geometry_info.rho=next->resolution.x;
688  geometry_info.sigma=1.0;
689  flags=ParseGeometry(value,&geometry_info);
690  if (geometry_info.sigma != 0)
691  next->resolution.x=geometry_info.rho/geometry_info.sigma;
692  if (strchr(value,',') != (char *) NULL)
693  next->resolution.x=geometry_info.rho+geometry_info.sigma/1000.0;
694  (void) DeleteImageProperty(next,"exif:XResolution");
695  }
696  value=GetImageProperty(next,"exif:YResolution",exception);
697  if (value != (char *) NULL)
698  {
699  geometry_info.rho=next->resolution.y;
700  geometry_info.sigma=1.0;
701  flags=ParseGeometry(value,&geometry_info);
702  if (geometry_info.sigma != 0)
703  next->resolution.y=geometry_info.rho/geometry_info.sigma;
704  if (strchr(value,',') != (char *) NULL)
705  next->resolution.y=geometry_info.rho+geometry_info.sigma/1000.0;
706  (void) DeleteImageProperty(next,"exif:YResolution");
707  }
708  value=GetImageProperty(next,"exif:ResolutionUnit",exception);
709  if (value == (char *) NULL)
710  value=GetImageProperty(next,"tiff:ResolutionUnit",exception);
711  if (value != (char *) NULL)
712  {
714  value);
715  if (option_type >= 0)
716  next->units=(ResolutionType) option_type;
717  (void) DeleteImageProperty(next,"exif:ResolutionUnit");
718  (void) DeleteImageProperty(next,"tiff:ResolutionUnit");
719  }
720  if (next->page.width == 0)
721  next->page.width=next->columns;
722  if (next->page.height == 0)
723  next->page.height=next->rows;
724  option=GetImageOption(read_info,"caption");
725  if (option != (const char *) NULL)
726  {
727  property=InterpretImageProperties(read_info,next,option,exception);
728  (void) SetImageProperty(next,"caption",property,exception);
729  property=DestroyString(property);
730  }
731  option=GetImageOption(read_info,"comment");
732  if (option != (const char *) NULL)
733  {
734  property=InterpretImageProperties(read_info,next,option,exception);
735  (void) SetImageProperty(next,"comment",property,exception);
736  property=DestroyString(property);
737  }
738  option=GetImageOption(read_info,"label");
739  if (option != (const char *) NULL)
740  {
741  property=InterpretImageProperties(read_info,next,option,exception);
742  (void) SetImageProperty(next,"label",property,exception);
743  property=DestroyString(property);
744  }
745  if (LocaleCompare(next->magick,"TEXT") == 0)
746  (void) ParseAbsoluteGeometry("0x0+0+0",&next->page);
747  if ((read_info->extract != (char *) NULL) &&
748  (read_info->stream == (StreamHandler) NULL))
749  {
751  geometry;
752 
753  SetGeometry(next,&geometry);
754  flags=ParseAbsoluteGeometry(read_info->extract,&geometry);
755  if ((next->columns != geometry.width) ||
756  (next->rows != geometry.height))
757  {
758  if (((flags & XValue) != 0) || ((flags & YValue) != 0))
759  {
760  Image
761  *crop_image;
762 
763  crop_image=CropImage(next,&geometry,exception);
764  if (crop_image != (Image *) NULL)
765  ReplaceImageInList(&next,crop_image);
766  }
767  else
768  if (((flags & WidthValue) != 0) || ((flags & HeightValue) != 0))
769  {
770  Image
771  *size_image;
772 
773  flags=ParseRegionGeometry(next,read_info->extract,&geometry,
774  exception);
775  size_image=ResizeImage(next,geometry.width,geometry.height,
776  next->filter,exception);
777  if (size_image != (Image *) NULL)
778  ReplaceImageInList(&next,size_image);
779  }
780  }
781  }
782  profile=GetImageProfile(next,"icc");
783  if (profile == (const StringInfo *) NULL)
784  profile=GetImageProfile(next,"icm");
785  profile=GetImageProfile(next,"iptc");
786  if (profile == (const StringInfo *) NULL)
787  profile=GetImageProfile(next,"8bim");
788  (void) FormatMagickTime((time_t) GetBlobProperties(next)->st_mtime,
789  MagickPathExtent,timestamp);
790  (void) SetImageProperty(next,"date:modify",timestamp,exception);
791  (void) FormatMagickTime((time_t) GetBlobProperties(next)->st_ctime,
792  MagickPathExtent,timestamp);
793  (void) SetImageProperty(next,"date:create",timestamp,exception);
794  option=GetImageOption(image_info,"delay");
795  if (option != (const char *) NULL)
796  {
797  flags=ParseGeometry(option,&geometry_info);
798  if ((flags & GreaterValue) != 0)
799  {
800  if (next->delay > (size_t) floor(geometry_info.rho+0.5))
801  next->delay=(size_t) floor(geometry_info.rho+0.5);
802  }
803  else
804  if ((flags & LessValue) != 0)
805  {
806  if (next->delay < (size_t) floor(geometry_info.rho+0.5))
807  next->ticks_per_second=(ssize_t) floor(geometry_info.sigma+0.5);
808  }
809  else
810  next->delay=(size_t) floor(geometry_info.rho+0.5);
811  if ((flags & SigmaValue) != 0)
812  next->ticks_per_second=(ssize_t) floor(geometry_info.sigma+0.5);
813  }
814  option=GetImageOption(image_info,"dispose");
815  if (option != (const char *) NULL)
816  {
818  option);
819  if (option_type >= 0)
820  next->dispose=(DisposeType) option_type;
821  }
822  if (read_info->verbose != MagickFalse)
823  (void) IdentifyImage(next,stderr,MagickFalse,exception);
824  image=next;
825  }
826  read_info=DestroyImageInfo(read_info);
827  return(GetFirstImageInList(image));
828 }
829 
830 /*
831 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
832 % %
833 % %
834 % %
835 % R e a d I m a g e s %
836 % %
837 % %
838 % %
839 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
840 %
841 % ReadImages() reads one or more images and returns them as an image list.
842 %
843 % The format of the ReadImage method is:
844 %
845 % Image *ReadImages(ImageInfo *image_info,const char *filename,
846 % ExceptionInfo *exception)
847 %
848 % A description of each parameter follows:
849 %
850 % o image_info: the image info.
851 %
852 % o filename: the image filename.
853 %
854 % o exception: return any errors or warnings in this structure.
855 %
856 */
857 MagickExport Image *ReadImages(ImageInfo *image_info,const char *filename,
858  ExceptionInfo *exception)
859 {
860  char
861  read_filename[MagickPathExtent];
862 
863  Image
864  *image,
865  *images;
866 
867  ImageInfo
868  *read_info;
869 
870  /*
871  Read image list from a file.
872  */
873  assert(image_info != (ImageInfo *) NULL);
874  assert(image_info->signature == MagickCoreSignature);
875  if (image_info->debug != MagickFalse)
877  image_info->filename);
878  assert(exception != (ExceptionInfo *) NULL);
879  read_info=CloneImageInfo(image_info);
880  *read_info->magick='\0';
881  (void) SetImageOption(read_info,"filename",filename);
882  (void) CopyMagickString(read_info->filename,filename,MagickPathExtent);
883  (void) InterpretImageFilename(read_info,(Image *) NULL,filename,
884  (int) read_info->scene,read_filename,exception);
885  if (LocaleCompare(read_filename,read_info->filename) != 0)
886  {
888  *sans;
889 
890  ssize_t
891  extent,
892  scene;
893 
894  /*
895  Images of the form image-%d.png[1-5].
896  */
897  sans=AcquireExceptionInfo();
898  (void) SetImageInfo(read_info,0,sans);
899  sans=DestroyExceptionInfo(sans);
900  if (read_info->number_scenes != 0)
901  {
902  (void) CopyMagickString(read_filename,read_info->filename,
904  images=NewImageList();
905  extent=(ssize_t) (read_info->scene+read_info->number_scenes);
906  scene=(ssize_t) read_info->scene;
907  for ( ; scene < (ssize_t) extent; scene++)
908  {
909  (void) InterpretImageFilename(image_info,(Image *) NULL,
910  read_filename,(int) scene,read_info->filename,exception);
911  image=ReadImage(read_info,exception);
912  if (image == (Image *) NULL)
913  continue;
914  AppendImageToList(&images,image);
915  }
916  read_info=DestroyImageInfo(read_info);
917  return(images);
918  }
919  }
920  (void) CopyMagickString(read_info->filename,filename,MagickPathExtent);
921  image=ReadImage(read_info,exception);
922  read_info=DestroyImageInfo(read_info);
923  return(image);
924 }
925 
926 /*
927 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
928 % %
929 % %
930 % %
931 + R e a d I n l i n e I m a g e %
932 % %
933 % %
934 % %
935 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
936 %
937 % ReadInlineImage() reads a Base64-encoded inline image or image sequence.
938 % The method returns a NULL if there is a memory shortage or if the image
939 % cannot be read. On failure, a NULL image is returned and exception
940 % describes the reason for the failure.
941 %
942 % The format of the ReadInlineImage method is:
943 %
944 % Image *ReadInlineImage(const ImageInfo *image_info,const char *content,
945 % ExceptionInfo *exception)
946 %
947 % A description of each parameter follows:
948 %
949 % o image_info: the image info.
950 %
951 % o content: the image encoded in Base64.
952 %
953 % o exception: return any errors or warnings in this structure.
954 %
955 */
957  const char *content,ExceptionInfo *exception)
958 {
959  Image
960  *image;
961 
962  ImageInfo
963  *read_info;
964 
965  unsigned char
966  *blob;
967 
968  size_t
969  length;
970 
971  register const char
972  *p;
973 
974  /*
975  Skip over header (e.g. data:image/gif;base64,).
976  */
977  image=NewImageList();
978  for (p=content; (*p != ',') && (*p != '\0'); p++) ;
979  if (*p == '\0')
980  ThrowReaderException(CorruptImageError,"CorruptImage");
981  p++;
982  length=0;
983  blob=Base64Decode(p,&length);
984  if (length == 0)
985  {
986  blob=(unsigned char *) RelinquishMagickMemory(blob);
987  ThrowReaderException(CorruptImageError,"CorruptImage");
988  }
989  read_info=CloneImageInfo(image_info);
990  (void) SetImageInfoProgressMonitor(read_info,(MagickProgressMonitor) NULL,
991  (void *) NULL);
992  *read_info->filename='\0';
993  *read_info->magick='\0';
994  image=BlobToImage(read_info,blob,length,exception);
995  blob=(unsigned char *) RelinquishMagickMemory(blob);
996  read_info=DestroyImageInfo(read_info);
997  return(image);
998 }
999 
1000 /*
1001 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1002 % %
1003 % %
1004 % %
1005 % W r i t e I m a g e %
1006 % %
1007 % %
1008 % %
1009 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1010 %
1011 % WriteImage() writes an image or an image sequence to a file or file handle.
1012 % If writing to a file is on disk, the name is defined by the filename member
1013 % of the image structure. WriteImage() returns MagickFalse is there is a
1014 % memory shortage or if the image cannot be written. Check the exception
1015 % member of image to determine the cause for any failure.
1016 %
1017 % The format of the WriteImage method is:
1018 %
1019 % MagickBooleanType WriteImage(const ImageInfo *image_info,Image *image,
1020 % ExceptionInfo *exception)
1021 %
1022 % A description of each parameter follows:
1023 %
1024 % o image_info: the image info.
1025 %
1026 % o image: the image.
1027 %
1028 % o exception: return any errors or warnings in this structure.
1029 %
1030 */
1032  Image *image,ExceptionInfo *exception)
1033 {
1034  char
1035  filename[MagickPathExtent];
1036 
1037  const char
1038  *option;
1039 
1040  const DelegateInfo
1041  *delegate_info;
1042 
1043  const MagickInfo
1044  *magick_info;
1045 
1047  *encoder;
1048 
1050  *sans_exception;
1051 
1052  ImageInfo
1053  *write_info;
1054 
1056  status,
1057  temporary;
1058 
1059  /*
1060  Determine image type from filename prefix or suffix (e.g. image.jpg).
1061  */
1062  assert(image_info != (ImageInfo *) NULL);
1063  assert(image_info->signature == MagickCoreSignature);
1064  assert(image != (Image *) NULL);
1065  if (image->debug != MagickFalse)
1067  image_info->filename);
1068  assert(image->signature == MagickCoreSignature);
1069  assert(exception != (ExceptionInfo *) NULL);
1070  sans_exception=AcquireExceptionInfo();
1071  write_info=CloneImageInfo(image_info);
1072  (void) CopyMagickString(write_info->filename,image->filename,
1074  (void) SetImageInfo(write_info,1,sans_exception);
1075  if (*write_info->magick == '\0')
1076  (void) CopyMagickString(write_info->magick,image->magick,MagickPathExtent);
1077  (void) CopyMagickString(filename,image->filename,MagickPathExtent);
1078  (void) CopyMagickString(image->filename,write_info->filename,
1080  /*
1081  Call appropriate image writer based on image type.
1082  */
1083  magick_info=GetMagickInfo(write_info->magick,sans_exception);
1084  sans_exception=DestroyExceptionInfo(sans_exception);
1085  if (magick_info != (const MagickInfo *) NULL)
1086  {
1087  if (GetMagickEndianSupport(magick_info) == MagickFalse)
1088  image->endian=UndefinedEndian;
1089  else
1090  if ((image_info->endian == UndefinedEndian) &&
1091  (GetMagickRawSupport(magick_info) != MagickFalse))
1092  {
1093  unsigned long
1094  lsb_first;
1095 
1096  lsb_first=1;
1097  image->endian=(*(char *) &lsb_first) == 1 ? LSBEndian : MSBEndian;
1098  }
1099  }
1100  (void) SyncImageProfiles(image);
1101  DisassociateImageStream(image);
1102  option=GetImageOption(image_info,"delegate:bimodal");
1103  if ((IsStringTrue(option) != MagickFalse) &&
1104  (write_info->page == (char *) NULL) &&
1105  (GetPreviousImageInList(image) == (Image *) NULL) &&
1106  (GetNextImageInList(image) == (Image *) NULL) &&
1107  (IsTaintImage(image) == MagickFalse) )
1108  {
1109  delegate_info=GetDelegateInfo(image->magick,write_info->magick,exception);
1110  if ((delegate_info != (const DelegateInfo *) NULL) &&
1111  (GetDelegateMode(delegate_info) == 0) &&
1113  {
1114  /*
1115  Process image with bi-modal delegate.
1116  */
1117  (void) CopyMagickString(image->filename,image->magick_filename,
1119  status=InvokeDelegate(write_info,image,image->magick,
1120  write_info->magick,exception);
1121  write_info=DestroyImageInfo(write_info);
1122  (void) CopyMagickString(image->filename,filename,MagickPathExtent);
1123  return(status);
1124  }
1125  }
1126  status=MagickFalse;
1127  temporary=MagickFalse;
1128  if ((magick_info != (const MagickInfo *) NULL) &&
1129  (GetMagickEncoderSeekableStream(magick_info) != MagickFalse))
1130  {
1131  char
1132  image_filename[MagickPathExtent];
1133 
1134  (void) CopyMagickString(image_filename,image->filename,MagickPathExtent);
1135  status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
1136  (void) CopyMagickString(image->filename, image_filename,MagickPathExtent);
1137  if (status != MagickFalse)
1138  {
1139  if (IsBlobSeekable(image) == MagickFalse)
1140  {
1141  /*
1142  A seekable stream is required by the encoder.
1143  */
1144  write_info->adjoin=MagickTrue;
1145  (void) CopyMagickString(write_info->filename,image->filename,
1147  (void) AcquireUniqueFilename(image->filename);
1148  temporary=MagickTrue;
1149  }
1150  (void) CloseBlob(image);
1151  }
1152  }
1153  encoder=GetImageEncoder(magick_info);
1154  if (encoder != (EncodeImageHandler *) NULL)
1155  {
1156  /*
1157  Call appropriate image writer based on image type.
1158  */
1159  if (GetMagickEncoderThreadSupport(magick_info) == MagickFalse)
1160  LockSemaphoreInfo(magick_info->semaphore);
1161  status=IsCoderAuthorized(write_info->magick,WritePolicyRights,exception);
1162  if (status != MagickFalse)
1163  status=encoder(write_info,image,exception);
1164  if (GetMagickEncoderThreadSupport(magick_info) == MagickFalse)
1165  UnlockSemaphoreInfo(magick_info->semaphore);
1166  }
1167  else
1168  {
1169  delegate_info=GetDelegateInfo((char *) NULL,write_info->magick,exception);
1170  if (delegate_info != (DelegateInfo *) NULL)
1171  {
1172  /*
1173  Process the image with delegate.
1174  */
1175  *write_info->filename='\0';
1176  if (GetDelegateThreadSupport(delegate_info) == MagickFalse)
1177  LockSemaphoreInfo(delegate_info->semaphore);
1178  status=InvokeDelegate(write_info,image,(char *) NULL,
1179  write_info->magick,exception);
1180  if (GetDelegateThreadSupport(delegate_info) == MagickFalse)
1181  UnlockSemaphoreInfo(delegate_info->semaphore);
1182  (void) CopyMagickString(image->filename,filename,MagickPathExtent);
1183  }
1184  else
1185  {
1186  sans_exception=AcquireExceptionInfo();
1187  magick_info=GetMagickInfo(write_info->magick,sans_exception);
1188  sans_exception=DestroyExceptionInfo(sans_exception);
1189  if ((write_info->affirm == MagickFalse) &&
1190  (magick_info == (const MagickInfo *) NULL))
1191  {
1192  (void) CopyMagickString(write_info->magick,image->magick,
1194  magick_info=GetMagickInfo(write_info->magick,exception);
1195  }
1196  encoder=GetImageEncoder(magick_info);
1197  if (encoder == (EncodeImageHandler *) NULL)
1198  {
1199  char
1200  extension[MagickPathExtent];
1201 
1202  GetPathComponent(image->filename,ExtensionPath,extension);
1203  if (*extension != '\0')
1204  magick_info=GetMagickInfo(extension,exception);
1205  else
1206  magick_info=GetMagickInfo(image->magick,exception);
1207  (void) CopyMagickString(image->filename,filename,
1209  encoder=GetImageEncoder(magick_info);
1210  }
1211  if (encoder == (EncodeImageHandler *) NULL)
1212  {
1213  magick_info=GetMagickInfo(image->magick,exception);
1214  encoder=GetImageEncoder(magick_info);
1215  if (encoder == (EncodeImageHandler *) NULL)
1216  (void) ThrowMagickException(exception,GetMagickModule(),
1217  MissingDelegateError,"NoEncodeDelegateForThisImageFormat",
1218  "`%s'",write_info->magick);
1219  }
1220  if (encoder != (EncodeImageHandler *) NULL)
1221  {
1222  /*
1223  Call appropriate image writer based on image type.
1224  */
1225  if (GetMagickEncoderThreadSupport(magick_info) == MagickFalse)
1226  LockSemaphoreInfo(magick_info->semaphore);
1227  status=IsCoderAuthorized(write_info->magick,WritePolicyRights,
1228  exception);
1229  if (status != MagickFalse)
1230  status=encoder(write_info,image,exception);
1231  if (GetMagickEncoderThreadSupport(magick_info) == MagickFalse)
1232  UnlockSemaphoreInfo(magick_info->semaphore);
1233  }
1234  }
1235  }
1236  if (temporary != MagickFalse)
1237  {
1238  /*
1239  Copy temporary image file to permanent.
1240  */
1241  status=OpenBlob(write_info,image,ReadBinaryBlobMode,exception);
1242  if (status != MagickFalse)
1243  {
1244  (void) RelinquishUniqueFileResource(write_info->filename);
1245  status=ImageToFile(image,write_info->filename,exception);
1246  }
1247  (void) CloseBlob(image);
1248  (void) RelinquishUniqueFileResource(image->filename);
1249  (void) CopyMagickString(image->filename,write_info->filename,
1251  }
1252  if ((LocaleCompare(write_info->magick,"info") != 0) &&
1253  (write_info->verbose != MagickFalse))
1254  (void) IdentifyImage(image,stdout,MagickFalse,exception);
1255  write_info=DestroyImageInfo(write_info);
1256  return(status);
1257 }
1258 
1259 /*
1260 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1261 % %
1262 % %
1263 % %
1264 % W r i t e I m a g e s %
1265 % %
1266 % %
1267 % %
1268 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1269 %
1270 % WriteImages() writes an image sequence into one or more files. While
1271 % WriteImage() can write an image sequence, it is limited to writing
1272 % the sequence into a single file using a format which supports multiple
1273 % frames. WriteImages(), however, does not have this limitation, instead it
1274 % generates multiple output files if necessary (or when requested). When
1275 % ImageInfo's adjoin flag is set to MagickFalse, the file name is expected
1276 % to include a printf-style formatting string for the frame number (e.g.
1277 % "image%02d.png").
1278 %
1279 % The format of the WriteImages method is:
1280 %
1281 % MagickBooleanType WriteImages(const ImageInfo *image_info,Image *images,
1282 % const char *filename,ExceptionInfo *exception)
1283 %
1284 % A description of each parameter follows:
1285 %
1286 % o image_info: the image info.
1287 %
1288 % o images: the image list.
1289 %
1290 % o filename: the image filename.
1291 %
1292 % o exception: return any errors or warnings in this structure.
1293 %
1294 */
1296  Image *images,const char *filename,ExceptionInfo *exception)
1297 {
1298 #define WriteImageTag "Write/Image"
1299 
1301  *sans_exception;
1302 
1303  ImageInfo
1304  *write_info;
1305 
1307  proceed;
1308 
1310  progress;
1311 
1313  progress_monitor;
1314 
1316  number_images;
1317 
1319  status;
1320 
1321  register Image
1322  *p;
1323 
1324  assert(image_info != (const ImageInfo *) NULL);
1325  assert(image_info->signature == MagickCoreSignature);
1326  assert(images != (Image *) NULL);
1327  assert(images->signature == MagickCoreSignature);
1328  if (images->debug != MagickFalse)
1329  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",images->filename);
1330  assert(exception != (ExceptionInfo *) NULL);
1331  write_info=CloneImageInfo(image_info);
1332  *write_info->magick='\0';
1333  images=GetFirstImageInList(images);
1334  if (filename != (const char *) NULL)
1335  for (p=images; p != (Image *) NULL; p=GetNextImageInList(p))
1336  (void) CopyMagickString(p->filename,filename,MagickPathExtent);
1337  (void) CopyMagickString(write_info->filename,images->filename,
1339  sans_exception=AcquireExceptionInfo();
1340  (void) SetImageInfo(write_info,(unsigned int) GetImageListLength(images),
1341  sans_exception);
1342  sans_exception=DestroyExceptionInfo(sans_exception);
1343  if (*write_info->magick == '\0')
1344  (void) CopyMagickString(write_info->magick,images->magick,MagickPathExtent);
1345  p=images;
1346  for ( ; GetNextImageInList(p) != (Image *) NULL; p=GetNextImageInList(p))
1347  {
1348  register Image
1349  *next;
1350 
1351  next=GetNextImageInList(p);
1352  if (next == (Image *) NULL)
1353  break;
1354  if (p->scene >= next->scene)
1355  {
1356  register ssize_t
1357  i;
1358 
1359  /*
1360  Generate consistent scene numbers.
1361  */
1362  i=(ssize_t) images->scene;
1363  for (p=images; p != (Image *) NULL; p=GetNextImageInList(p))
1364  p->scene=(size_t) i++;
1365  break;
1366  }
1367  }
1368  /*
1369  Write images.
1370  */
1371  status=MagickTrue;
1372  progress_monitor=(MagickProgressMonitor) NULL;
1373  progress=0;
1374  number_images=GetImageListLength(images);
1375  for (p=images; p != (Image *) NULL; p=GetNextImageInList(p))
1376  {
1377  if (number_images != 1)
1378  progress_monitor=SetImageProgressMonitor(p,(MagickProgressMonitor) NULL,
1379  p->client_data);
1380  status&=WriteImage(write_info,p,exception);
1381  if (number_images != 1)
1382  (void) SetImageProgressMonitor(p,progress_monitor,p->client_data);
1383  if (write_info->adjoin != MagickFalse)
1384  break;
1385  if (number_images != 1)
1386  {
1387 #if defined(MAGICKCORE_OPENMP_SUPPORT)
1388  #pragma omp atomic
1389 #endif
1390  progress++;
1391  proceed=SetImageProgress(p,WriteImageTag,progress,number_images);
1392  if (proceed == MagickFalse)
1393  break;
1394  }
1395  }
1396  write_info=DestroyImageInfo(write_info);
1397  return(status != 0 ? MagickTrue : MagickFalse);
1398 }
size_t rows
Definition: image.h:172
MagickExport Image * ResizeImage(const Image *image, const size_t columns, const size_t rows, const FilterType filter, ExceptionInfo *exception)
Definition: resize.c:3700
MagickExport Image * CloneImages(const Image *images, const char *scenes, ExceptionInfo *exception)
Definition: list.c:204
EndianType endian
Definition: image.h:404
size_t signature
Definition: image.h:488
DisposeType dispose
Definition: image.h:237
char magick[MagickPathExtent]
Definition: image.h:480
MagickExport MagickBooleanType GetDelegateThreadSupport(const DelegateInfo *delegate_info)
Definition: delegate.c:1496
char * scenes
Definition: image.h:390
MagickExport MagickBooleanType IsRightsAuthorized(const PolicyDomain domain, const PolicyRights rights, const char *pattern)
Definition: policy.c:595
ssize_t ticks_per_second
Definition: image.h:245
FilterType filter
Definition: image.h:219
MagickExport void UnlockSemaphoreInfo(SemaphoreInfo *semaphore_info)
Definition: semaphore.c:450
MagickExport ssize_t ParseCommandOption(const CommandOption option, const MagickBooleanType list, const char *options)
Definition: option.c:2972
OrientationType
Definition: image.h:76
char * extract
Definition: image.h:390
PolicyRights
Definition: policy.h:41
size_t(* StreamHandler)(const Image *, const void *, const size_t)
Definition: stream.h:31
size_t signature
Definition: exception.h:123
size_t number_scenes
Definition: image.h:396
MagickExport Image * PingImage(const ImageInfo *image_info, ExceptionInfo *exception)
Definition: constitute.c:256
double rho
Definition: geometry.h:106
MagickExport MagickStatusType ParseAbsoluteGeometry(const char *geometry, RectangleInfo *region_info)
Definition: geometry.c:703
EndianType endian
Definition: image.h:228
MagickBooleanType taint
Definition: image.h:169
StorageType
Definition: pixel.h:142
MagickExport MagickBooleanType IdentifyImage(Image *image, FILE *file, const MagickBooleanType verbose, ExceptionInfo *exception)
Definition: identify.c:469
MagickBooleanType debug
Definition: image.h:485
MagickExport MagickBooleanType GetMagickEncoderThreadSupport(const MagickInfo *magick_info)
Definition: magick.c:546
MagickExport const DelegateInfo * GetDelegateInfo(const char *decode, const char *encode, ExceptionInfo *exception)
Definition: delegate.c:1181
MagickExport Image * ReadInlineImage(const ImageInfo *image_info, const char *content, ExceptionInfo *exception)
Definition: constitute.c:956
MagickExport ExceptionInfo * AcquireExceptionInfo(void)
Definition: exception.c:115
static MagickBooleanType IsCoderAuthorized(const char *coder, const PolicyRights rights, ExceptionInfo *exception)
Definition: constitute.c:406
MagickExport ssize_t GetDelegateMode(const DelegateInfo *delegate_info)
Definition: delegate.c:1463
MagickBooleanType EncodeImageHandler(const ImageInfo *, Image *, ExceptionInfo *)
Definition: magick.h:62
ResolutionType units
Definition: image.h:198
size_t delay
Definition: image.h:240
#define WriteImageTag
char magick[MagickPathExtent]
Definition: image.h:319
size_t magick_rows
Definition: image.h:324
MagickExport MagickBooleanType ImageToFile(Image *image, char *filename, ExceptionInfo *exception)
Definition: blob.c:2258
MagickBooleanType verbose
Definition: image.h:445
static long StringToLong(const char *magick_restrict value)
MagickExport const char * GetImageOption(const ImageInfo *image_info, const char *option)
Definition: option.c:2303
double sigma
Definition: geometry.h:106
size_t width
Definition: geometry.h:130
MagickExport MagickBooleanType AcquireUniqueFilename(char *path)
Definition: utility.c:111
Definition: log.h:52
ssize_t MagickOffsetType
Definition: magick-type.h:129
MagickExport MagickBooleanType SetImageOption(ImageInfo *image_info, const char *option, const char *value)
Definition: option.c:3242
Definition: image.h:151
MagickExport Image * GetPreviousImageInList(const Image *images)
Definition: list.c:803
SemaphoreInfo * semaphore
Definition: delegate.h:45
StreamHandler stream
Definition: image.h:468
MagickExport MagickBooleanType GetMagickRawSupport(const MagickInfo *magick_info)
Definition: magick.c:973
MagickExport Image * CropImage(const Image *image, const RectangleInfo *geometry, ExceptionInfo *exception)
Definition: transform.c:535
double x
Definition: geometry.h:123
MagickExport Image * PingImages(ImageInfo *image_info, const char *filename, ExceptionInfo *exception)
Definition: constitute.c:311
#define MagickCoreSignature
MagickExport MagickBooleanType ImportImagePixels(Image *image, const ssize_t x, const ssize_t y, const size_t width, const size_t height, const char *map, const StorageType type, const void *pixels, ExceptionInfo *exception)
Definition: pixel.c:4136
MagickExport void LockSemaphoreInfo(SemaphoreInfo *semaphore_info)
Definition: semaphore.c:293
MagickExport MagickBooleanType GetMagickDecoderSeekableStream(const MagickInfo *magick_info)
Definition: magick.c:416
MagickExport Image * GetFirstImageInList(const Image *images)
Definition: list.c:561
SemaphoreInfo * semaphore
Definition: magick.h:96
MagickExport Image * BlobToImage(const ImageInfo *image_info, const void *blob, const size_t length, ExceptionInfo *exception)
Definition: blob.c:422
MagickExport void GetPathComponent(const char *path, PathType type, char *component)
Definition: utility.c:1213
MagickBooleanType
Definition: magick-type.h:158
MagickExport Image * NewImageList(void)
Definition: list.c:938
size_t scene
Definition: image.h:240
unsigned int MagickStatusType
Definition: magick-type.h:121
MagickExport MagickBooleanType WriteImage(const ImageInfo *image_info, Image *image, ExceptionInfo *exception)
Definition: constitute.c:1031
MagickExport unsigned char * Base64Decode(const char *source, size_t *length)
Definition: utility.c:346
char filename[MagickPathExtent]
Definition: image.h:480
MagickExport struct stat * GetBlobProperties(const Image *)
Definition: blob.c:1771
double y
Definition: geometry.h:123
MagickExport MagickBooleanType RelinquishUniqueFileResource(const char *path)
Definition: resource.c:1095
MagickExport MagickBooleanType CloseBlob(Image *)
MagickExport MagickBooleanType SetImageProperty(Image *image, const char *property, const char *value, ExceptionInfo *exception)
Definition: property.c:4121
MagickExport const StringInfo * GetImageProfile(const Image *image, const char *name)
Definition: profile.c:284
size_t scene
Definition: image.h:396
#define magick_unused(x)
RectangleInfo page
Definition: image.h:212
size_t magick_columns
Definition: image.h:324
size_t MagickSizeType
Definition: magick-type.h:130
#define MagickPathExtent
MagickExport MagickBooleanType IsStringTrue(const char *value)
Definition: string.c:1425
MagickExport MagickBooleanType IsBlobTemporary(const Image *image)
Definition: blob.c:2928
#define ThrowFileException(exception, severity, tag, context)
PixelTrait alpha_trait
Definition: image.h:280
static size_t PingStream(const Image *magick_unused(image), const void *magick_unused(pixels), const size_t columns)
Definition: constitute.c:244
MagickExport Image * ReadImage(const ImageInfo *image_info, ExceptionInfo *exception)
Definition: constitute.c:419
MagickExport MagickBooleanType SetImageInfo(ImageInfo *image_info, const unsigned int frames, ExceptionInfo *exception)
Definition: image.c:2703
#define ThrowReaderException(severity, tag)
char magick_filename[MagickPathExtent]
Definition: image.h:319
MagickExport DecodeImageHandler * GetImageDecoder(const MagickInfo *magick_info)
Definition: magick.c:226
MagickExport MagickBooleanType ThrowMagickException(ExceptionInfo *exception, const char *module, const char *function, const size_t line, const ExceptionType severity, const char *tag, const char *format,...)
Definition: exception.c:1145
MagickExport MagickBooleanType LogMagickEvent(const LogEventType type, const char *module, const char *function, const size_t line, const char *format,...)
Definition: log.c:1413
MagickExport MagickBooleanType IsPathAccessible(const char *path)
Definition: utility.c:1467
size_t signature
Definition: image.h:354
size_t columns
Definition: image.h:172
MagickExport const MagickInfo * GetMagickInfo(const char *name, ExceptionInfo *exception)
Definition: magick.c:613
MagickExport Image * AcquireImage(const ImageInfo *image_info, ExceptionInfo *exception)
Definition: image.c:156
MagickExport MagickBooleanType OpenBlob(const ImageInfo *, Image *, const BlobMode, ExceptionInfo *)
size_t height
Definition: geometry.h:130
MagickExport void ResetTimer(TimerInfo *time_info)
Definition: timer.c:434
MagickExport EncodeImageHandler * GetImageEncoder(const MagickInfo *magick_info)
Definition: magick.c:256
MagickExport Image * ReadStream(const ImageInfo *image_info, StreamHandler stream, ExceptionInfo *exception)
Definition: stream.c:1002
MagickExport MagickProgressMonitor SetImageProgressMonitor(Image *image, const MagickProgressMonitor progress_monitor, void *client_data)
Definition: monitor.c:194
MagickExport size_t CopyMagickString(char *destination, const char *source, const size_t length)
Definition: string.c:755
MagickExport Image * DestroyImageList(Image *images)
Definition: list.c:462
MagickExport MagickBooleanType GetMagickEndianSupport(const MagickInfo *magick_info)
Definition: magick.c:578
MagickExport size_t InterpretImageFilename(const ImageInfo *image_info, Image *image, const char *format, int value, char *filename, ExceptionInfo *exception)
Definition: image.c:1649
MagickExport MagickBooleanType IsBlobSeekable(const Image *image)
Definition: blob.c:2849
MagickExport MagickBooleanType SetImageExtent(Image *image, const size_t columns, const size_t rows, ExceptionInfo *exception)
Definition: image.c:2657
MagickExport Image * ReadImages(ImageInfo *image_info, const char *filename, ExceptionInfo *exception)
Definition: constitute.c:857
TimerInfo timer
Definition: image.h:300
MagickExport int LocaleCompare(const char *p, const char *q)
Definition: locale.c:1435
MagickExport MagickBooleanType GetMagickDecoderThreadSupport(const MagickInfo *magick_info)
Definition: magick.c:450
DisposeType
Definition: layer.h:27
char filename[MagickPathExtent]
Definition: image.h:319
#define GetMagickModule()
Definition: log.h:28
MagickBooleanType affirm
Definition: image.h:384
MagickExport Image * ConstituteImage(const size_t columns, const size_t rows, const char *map, const StorageType storage, const void *pixels, ExceptionInfo *exception)
Definition: constitute.c:133
MagickExport MagickBooleanType GetMagickEncoderSeekableStream(const MagickInfo *magick_info)
Definition: magick.c:512
MagickExport char * InterpretImageProperties(ImageInfo *image_info, Image *image, const char *embed_text, ExceptionInfo *exception)
Definition: property.c:3396
MagickExport MagickBooleanType ResetImagePixels(Image *image, ExceptionInfo *exception)
Definition: image.c:2241
MagickExport ImageInfo * DestroyImageInfo(ImageInfo *image_info)
Definition: image.c:1252
MagickExport MagickBooleanType IsTaintImage(const Image *image)
Definition: image.c:1940
MagickExport void ReplaceImageInList(Image **images, Image *replace)
Definition: list.c:1166
MagickExport Image * GetNextImageInList(const Image *images)
Definition: list.c:771
MagickExport char * DestroyString(char *string)
Definition: string.c:823
MagickExport MagickBooleanType DeleteImageProperty(Image *image, const char *property)
Definition: property.c:279
MagickExport const char * GetImageProperty(const Image *image, const char *property, ExceptionInfo *exception)
Definition: property.c:2236
MagickExport ImageInfo * CloneImageInfo(const ImageInfo *image_info)
Definition: image.c:940
MagickExport MagickStatusType ParseGeometry(const char *geometry, GeometryInfo *geometry_info)
Definition: geometry.c:853
MagickExport void AppendImageToList(Image **images, const Image *append)
Definition: list.c:78
MagickExport void SetGeometry(const Image *image, RectangleInfo *geometry)
Definition: geometry.c:1683
MagickPrivate MagickBooleanType SyncImageProfiles(Image *)
Definition: profile.c:2255
MagickExport void * RelinquishMagickMemory(void *memory)
Definition: memory.c:1069
PointInfo resolution
Definition: image.h:209
#define magick_unreferenced(x)
MagickExport MagickProgressMonitor SetImageInfoProgressMonitor(ImageInfo *image_info, const MagickProgressMonitor progress_monitor, void *client_data)
Definition: monitor.c:243
MagickBooleanType(* MagickProgressMonitor)(const char *, const MagickOffsetType, const MagickSizeType, void *)
Definition: monitor.h:26
MagickExport MagickBooleanType InvokeDelegate(ImageInfo *image_info, Image *image, const char *decode, const char *encode, ExceptionInfo *exception)
Definition: delegate.c:1646
ResolutionType
Definition: image.h:89
#define MagickExport
OrientationType orientation
Definition: image.h:166
MagickBooleanType adjoin
Definition: image.h:384
char * page
Definition: image.h:390
MagickExport ssize_t FormatMagickTime(const time_t time, const size_t length, char *timestamp)
Definition: timer.c:255
MagickBooleanType ping
Definition: image.h:445
MagickExport MagickBooleanType IsSceneGeometry(const char *geometry, const MagickBooleanType pedantic)
Definition: geometry.c:651
MagickExport size_t GetImageListLength(const Image *images)
Definition: list.c:696
void * client_data
Definition: image.h:306
MagickExport Image * DestroyImage(Image *image)
Definition: image.c:1181
ColorspaceType colorspace
Definition: image.h:157
MagickExport MagickStatusType ParseRegionGeometry(const Image *image, const char *geometry, RectangleInfo *region_info, ExceptionInfo *exception)
Definition: geometry.c:1644
MagickExport void DisassociateImageStream(Image *image)
Definition: image.c:1314
MagickExport MagickBooleanType SetImageProgress(const Image *image, const char *tag, const MagickOffsetType offset, const MagickSizeType extent)
Definition: monitor.c:136
MagickBooleanType temporary
Definition: image.h:384
MagickBooleanType debug
Definition: image.h:334
MagickExport ExceptionInfo * DestroyExceptionInfo(ExceptionInfo *exception)
Definition: exception.c:418
MagickExport MagickBooleanType WriteImages(const ImageInfo *image_info, Image *images, const char *filename, ExceptionInfo *exception)
Definition: constitute.c:1295
ExceptionType severity
Definition: exception.h:104
Image * DecodeImageHandler(const ImageInfo *, ExceptionInfo *)
Definition: magick.h:59