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