MagickCore  7.0.11
list.c
Go to the documentation of this file.
1 /*
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 % %
4 % %
5 % %
6 % L IIIII SSSSS TTTTT %
7 % L I SS T %
8 % L I SSS T %
9 % L I SS T %
10 % LLLLL IIIII SSSSS T %
11 % %
12 % %
13 % MagickCore Image List Methods %
14 % %
15 % Software Design %
16 % Cristy %
17 % December 2002 %
18 % %
19 % %
20 % Copyright 1999-2021 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 /*
41  Include declarations.
42 */
43 #include "MagickCore/studio.h"
44 #include "MagickCore/artifact.h"
45 #include "MagickCore/blob.h"
47 #include "MagickCore/exception.h"
50 #include "MagickCore/list.h"
51 #include "MagickCore/memory_.h"
52 #include "MagickCore/string_.h"
54 
55 /*
56 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57 % %
58 % %
59 % %
60 % A p p e n d I m a g e T o L i s t %
61 % %
62 % %
63 % %
64 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
65 %
66 % AppendImageToList() appends the second image list to the end of the first
67 % list. The given image list pointer is left unchanged, unless it was empty.
68 %
69 % The format of the AppendImageToList method is:
70 %
71 % AppendImageToList(Image *images,const Image *image)
72 %
73 % A description of each parameter follows:
74 %
75 % o images: the image list to be appended to.
76 %
77 % o image: the appended image or image list.
78 %
79 */
80 MagickExport void AppendImageToList(Image **images,const Image *append)
81 {
82  Image
83  *p,
84  *q;
85 
86  assert(images != (Image **) NULL);
87  if (append == (Image *) NULL)
88  return;
89  assert(append->signature == MagickCoreSignature);
90  if (append->debug != MagickFalse)
91  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",append->filename);
92  if ((*images) == (Image *) NULL)
93  {
94  *images=(Image *) append;
95  return;
96  }
97  assert((*images)->signature == MagickCoreSignature);
98  p=GetLastImageInList(*images);
99  q=GetFirstImageInList(append);
100  p->next=q;
101  q->previous=p;
102 }
103 
104 /*
105 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
106 % %
107 % %
108 % %
109 % C l o n e I m a g e L i s t %
110 % %
111 % %
112 % %
113 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
114 %
115 % CloneImageList() returns a duplicate of the image list.
116 %
117 % The format of the CloneImageList method is:
118 %
119 % Image *CloneImageList(const Image *images,ExceptionInfo *exception)
120 %
121 % A description of each parameter follows:
122 %
123 % o images: the image list.
124 %
125 % o exception: return any errors or warnings in this structure.
126 %
127 */
129 {
130  Image
131  *clone,
132  *image;
133 
134  Image
135  *p;
136 
137  if (images == (Image *) NULL)
138  return((Image *) NULL);
139  assert(images->signature == MagickCoreSignature);
140  while (images->previous != (Image *) NULL)
141  {
142  assert(images != images->previous);
143  images=images->previous;
144  }
145  image=(Image *) NULL;
146  for (p=(Image *) NULL; images != (Image *) NULL; images=images->next)
147  {
148  assert(images != images->next);
149  clone=CloneImage(images,0,0,MagickTrue,exception);
150  if (clone == (Image *) NULL)
151  {
152  if (image != (Image *) NULL)
153  image=DestroyImageList(image);
154  return((Image *) NULL);
155  }
156  if (image == (Image *) NULL)
157  {
158  image=clone;
159  p=image;
160  continue;
161  }
162  p->next=clone;
163  clone->previous=p;
164  p=p->next;
165  }
166  return(image);
167 }
168 
169 /*
170 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
171 % %
172 % %
173 % %
174 % C l o n e I m a g e s %
175 % %
176 % %
177 % %
178 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
179 %
180 % CloneImages() clones one or more images from an image sequence, using a
181 % comma separated list of image numbers or ranges.
182 %
183 % The numbers start at 0 for the first image in the list, while negative
184 % numbers refer to images starting counting from the end of the range. Images
185 % may be referred to multiple times to clone them multiple times. Images
186 % referred beyond the available number of images in list are ignored.
187 %
188 % Images referenced may be reversed, and results in a clone of those images
189 % also being made with a reversed order.
190 %
191 % The format of the CloneImages method is:
192 %
193 % Image *CloneImages(const Image *images,const char *scenes,
194 % ExceptionInfo *exception)
195 %
196 % A description of each parameter follows:
197 %
198 % o images: the image sequence.
199 %
200 % o scenes: This character string specifies which scenes to clone
201 % (e.g. 1,3-5,7-3,2).
202 %
203 % o exception: return any errors or warnings in this structure.
204 %
205 */
206 MagickExport Image *CloneImages(const Image *images,const char *scenes,
207  ExceptionInfo *exception)
208 {
209  char
210  *p;
211 
212  const char
213  *artifact;
214 
215  const Image
216  *next;
217 
218  Image
219  *clone_images,
220  *image;
221 
222  ssize_t
223  i;
224 
225  size_t
226  length;
227 
228  ssize_t
229  first,
230  last,
231  step;
232 
233  assert(images != (const Image *) NULL);
234  assert(images->signature == MagickCoreSignature);
235  assert(scenes != (char *) NULL);
236  if (images->debug != MagickFalse)
237  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",images->filename);
238  assert(exception != (ExceptionInfo *) NULL);
239  assert(exception->signature == MagickCoreSignature);
240  clone_images=NewImageList();
241  images=GetFirstImageInList(images);
242  artifact=GetImageArtifact(images,"frames:step");
243  length=GetImageListLength(images);
244  for (p=(char *) scenes; *p != '\0';)
245  {
247  match;
248 
249  while ((isspace((int) ((unsigned char) *p)) != 0) || (*p == ','))
250  p++;
251  first=(ssize_t) strtol(p,&p,10);
252  if (first < 0)
253  first+=(ssize_t) length;
254  else
255  if (first > (ssize_t) length)
256  first=(ssize_t) length;
257  first%=(length << 1);
258  last=first;
259  while (isspace((int) ((unsigned char) *p)) != 0)
260  p++;
261  if (*p == '-')
262  {
263  last=(ssize_t) strtol(p+1,&p,10);
264  if (last < 0)
265  last+=(ssize_t) length;
266  else
267  if (last > (ssize_t) length)
268  last=(ssize_t) length;
269  }
270  last%=(length << 1);
271  match=MagickFalse;
272  step=1;
273  if (artifact != (const char *) NULL)
274  {
275  step=(ssize_t) StringToLong(artifact);
276  if (step == 0)
277  step=1;
278  }
279  step=(ssize_t) (first > last ? -step : step);
280  for ( ; step > 0 ? (last-first) >= 0 : (last-first) <= 0; first+=step)
281  {
282  i=0;
283  for (next=images; next != (Image *) NULL; next=GetNextImageInList(next))
284  {
285  if (i == (ssize_t) first)
286  {
287  image=CloneImage(next,0,0,MagickTrue,exception);
288  if (image == (Image *) NULL)
289  break;
290  AppendImageToList(&clone_images,image);
291  match=MagickTrue;
292  }
293  i++;
294  }
295  if (match == MagickFalse)
297  "InvalidImageIndex","`%s'",images->filename);
298  }
299  }
300  return(GetFirstImageInList(clone_images));
301 }
302 
303 /*
304 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
305 % %
306 % %
307 % %
308 % D e l e t e I m a g e F r o m L i s t %
309 % %
310 % %
311 % %
312 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
313 %
314 % DeleteImageFromList() deletes an image from the list. List pointer
315 % is moved to the next image, if one is present. See RemoveImageFromList().
316 %
317 % The format of the DeleteImageFromList method is:
318 %
319 % DeleteImageFromList(Image **images)
320 %
321 % A description of each parameter follows:
322 %
323 % o images: the image list.
324 %
325 */
327 {
328  Image
329  *image;
330 
331  image=RemoveImageFromList(images);
332  if (image != (Image *) NULL)
333  (void) DestroyImage(image);
334 }
335 
336 /*
337 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
338 % %
339 % %
340 % %
341 % D e l e t e I m a g e s %
342 % %
343 % %
344 % %
345 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
346 %
347 % DeleteImages() deletes one or more images from an image sequence, using a
348 % comma separated list of image numbers or ranges.
349 %
350 % The numbers start at 0 for the first image, while negative numbers refer to
351 % images starting counting from the end of the range. Images may be referred to
352 % multiple times without problems. Image referred beyond the available number
353 % of images in list are ignored.
354 %
355 % If the referenced images are in the reverse order, that range will be
356 % completely ignored, unlike CloneImages().
357 %
358 % The format of the DeleteImages method is:
359 %
360 % DeleteImages(Image **images,const char *scenes,ExceptionInfo *exception)
361 %
362 % A description of each parameter follows:
363 %
364 % o images: the image sequence.
365 %
366 % o scenes: This character string specifies which scenes to delete
367 % (e.g. 1,3-5,-2-6,2).
368 %
369 % o exception: return any errors or warnings in this structure.
370 %
371 */
372 MagickExport void DeleteImages(Image **images,const char *scenes,
373  ExceptionInfo *exception)
374 {
375  char
376  *p;
377 
378  Image
379  *image;
380 
381  long
382  first,
383  last;
384 
386  *delete_list;
387 
388  ssize_t
389  i;
390 
391  size_t
392  length;
393 
394  assert(images != (Image **) NULL);
395  assert((*images)->signature == MagickCoreSignature);
396  assert(scenes != (char *) NULL);
397  if ((*images)->debug != MagickFalse)
399  (*images)->filename);
400  assert(exception != (ExceptionInfo *) NULL);
401  assert(exception->signature == MagickCoreSignature);
402  *images=GetFirstImageInList(*images);
403  length=GetImageListLength(*images);
404  delete_list=(MagickBooleanType *) AcquireQuantumMemory(length,
405  sizeof(*delete_list));
406  if (delete_list == (MagickBooleanType *) NULL)
407  {
408  (void) ThrowMagickException(exception,GetMagickModule(),
409  ResourceLimitError,"MemoryAllocationFailed","`%s'",(*images)->filename);
410  return;
411  }
412  image=(*images);
413  for (i=0; i < (ssize_t) length; i++)
414  delete_list[i]=MagickFalse;
415  /*
416  Note which images will be deleted, avoid duplicates.
417  */
418  for (p=(char *) scenes; *p != '\0';)
419  {
420  while ((isspace((int) ((unsigned char) *p)) != 0) || (*p == ','))
421  p++;
422  first=strtol(p,&p,10);
423  if (first < 0)
424  first+=(long) length;
425  last=first;
426  while (isspace((int) ((unsigned char) *p)) != 0)
427  p++;
428  if (*p == '-')
429  {
430  last=strtol(p+1,&p,10);
431  if (last < 0)
432  last+=(long) length;
433  }
434  if (first > last)
435  continue;
436  for (i=(ssize_t) first; i <= (ssize_t) last; i++)
437  if ((i >= 0) && (i < (ssize_t) length))
438  delete_list[i]=MagickTrue;
439  }
440  /*
441  Delete images marked for deletion, once only.
442  */
443  image=(*images);
444  for (i=0; i < (ssize_t) length; i++)
445  {
446  *images=image;
447  image=GetNextImageInList(image);
448  if (delete_list[i] != MagickFalse)
449  DeleteImageFromList(images);
450  }
451  (void) RelinquishMagickMemory(delete_list);
452  *images=GetFirstImageInList(*images);
453 }
454 
455 /*
456 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
457 % %
458 % %
459 % %
460 % D e s t r o y I m a g e L i s t %
461 % %
462 % %
463 % %
464 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
465 %
466 % DestroyImageList() destroys an image list.
467 %
468 % The format of the DestroyImageList method is:
469 %
470 % Image *DestroyImageList(Image *image)
471 %
472 % A description of each parameter follows:
473 %
474 % o image: the image sequence.
475 %
476 */
478 {
479  if (images == (Image *) NULL)
480  return((Image *) NULL);
481  assert(images->signature == MagickCoreSignature);
482  if (images->debug != MagickFalse)
483  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",images->filename);
484  while (images != (Image *) NULL)
485  DeleteImageFromList(&images);
486  return((Image *) NULL);
487 }
488 
489 /*
490 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
491 % %
492 % %
493 % %
494 % D u p l i c a t e I m a g e s %
495 % %
496 % %
497 % %
498 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
499 %
500 % DuplicateImages() duplicates one or more images from an image sequence,
501 % using a count and a comma separated list of image numbers or ranges.
502 %
503 % The numbers start at 0 for the first image, while negative numbers refer to
504 % images starting counting from the end of the range. Images may be referred to
505 % multiple times without problems. Image referred beyond the available number
506 % of images in list are ignored.
507 %
508 % The format of the DuplicateImages method is:
509 %
510 % Image *DuplicateImages(Image *images,const size_t number_duplicates,
511 % const char *scenes,ExceptionInfo *exception)
512 %
513 % A description of each parameter follows:
514 %
515 % o images: the image sequence.
516 %
517 % o number_duplicates: duplicate the image sequence this number of times.
518 %
519 % o scenes: This character string specifies which scenes to duplicate (e.g.
520 % 1,3-5,-2-6,2).
521 %
522 % o exception: return any errors or warnings in this structure.
523 %
524 */
526  const size_t number_duplicates,const char *scenes,ExceptionInfo *exception)
527 {
528  Image
529  *clone_images,
530  *duplicate_images;
531 
532  ssize_t
533  i;
534 
535  /*
536  Duplicate images.
537  */
538  assert(images != (Image *) NULL);
539  assert(images->signature == MagickCoreSignature);
540  assert(scenes != (char *) NULL);
541  if (images->debug != MagickFalse)
542  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",images->filename);
543  assert(exception != (ExceptionInfo *) NULL);
544  assert(exception->signature == MagickCoreSignature);
545  duplicate_images=NewImageList();
546  for (i=0; i < (ssize_t) number_duplicates; i++)
547  {
548  clone_images=CloneImages(images,scenes,exception);
549  AppendImageToList(&duplicate_images,clone_images);
550  }
551  return(duplicate_images);
552 }
553 
554 /*
555 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
556 % %
557 % %
558 % %
559 % G e t F i r s t I m a g e I n L i s t %
560 % %
561 % %
562 % %
563 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
564 %
565 % GetFirstImageInList() returns a pointer to the first image in the list.
566 %
567 % The format of the GetFirstImageInList method is:
568 %
569 % Image *GetFirstImageInList(const Image *images)
570 %
571 % A description of each parameter follows:
572 %
573 % o images: the image list.
574 %
575 */
577 {
578  const Image
579  *p;
580 
581  if (images == (Image *) NULL)
582  return((Image *) NULL);
583  assert(images->signature == MagickCoreSignature);
584  for (p=images; p->previous != (Image *) NULL; p=p->previous) ;
585  return((Image *) p);
586 }
587 
588 /*
589 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
590 % %
591 % %
592 % %
593 % G e t I m a g e F r o m L i s t %
594 % %
595 % %
596 % %
597 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
598 %
599 % GetImageFromList() returns an image at the specified index from the image
600 % list. Starting with 0 as the first image in the list.
601 %
602 % A negative offset will return the image from the end of the list, such that
603 % an index of -1 is the last image.
604 %
605 % If no such image exists at the specified offset a NULL image pointer is
606 % returned. This will only happen if index is less that the negative of
607 % the list length, or larger than list length -1. EG: ( -N to N-1 )
608 %
609 % The format of the GetImageFromList method is:
610 %
611 % Image *GetImageFromList(const Image *images,const ssize_t index)
612 %
613 % A description of each parameter follows:
614 %
615 % o images: the image list.
616 %
617 % o index: the position within the list.
618 %
619 */
620 MagickExport Image *GetImageFromList(const Image *images,const ssize_t index)
621 {
622  const Image
623  *p;
624 
625  ssize_t
626  i;
627 
628  if (images == (Image *) NULL)
629  return((Image *) NULL);
630  assert(images->signature == MagickCoreSignature);
631  if (images->debug != MagickFalse)
632  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",images->filename);
633  if (index < 0)
634  {
635  p=GetLastImageInList(images);
636  for (i=(-1); p != (Image *) NULL; p=p->previous)
637  if (i-- == index)
638  break;
639  }
640  else
641  {
642  p=GetFirstImageInList(images);
643  for (i=0; p != (Image *) NULL; p=p->next)
644  if (i++ == index)
645  break;
646  }
647  return((Image *) p);
648 }
649 
650 /*
651 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
652 % %
653 % %
654 % %
655 % G e t I m a g e I n d e x I n L i s t %
656 % %
657 % %
658 % %
659 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
660 %
661 % GetImageIndexInList() returns the offset in the list of the specified image.
662 %
663 % The format of the GetImageIndexInList method is:
664 %
665 % ssize_t GetImageIndexInList(const Image *images)
666 %
667 % A description of each parameter follows:
668 %
669 % o images: the image list.
670 %
671 */
672 MagickExport ssize_t GetImageIndexInList(const Image *images)
673 {
674  ssize_t
675  i;
676 
677  if (images == (const Image *) NULL)
678  return(-1);
679  assert(images->signature == MagickCoreSignature);
680  for (i=0; images->previous != (Image *) NULL; i++)
681  {
682  assert(images != images->previous);
683  images=images->previous;
684  }
685  return(i);
686 }
687 
688 /*
689 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
690 % %
691 % %
692 % %
693 % G e t I m a g e L i s t L e n g t h %
694 % %
695 % %
696 % %
697 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
698 %
699 % GetImageListLength() returns the length of the list (the number of images in
700 % the list).
701 %
702 % The format of the GetImageListLength method is:
703 %
704 % size_t GetImageListLength(const Image *images)
705 %
706 % A description of each parameter follows:
707 %
708 % o images: the image list.
709 %
710 */
711 MagickExport size_t GetImageListLength(const Image *images)
712 {
713  ssize_t
714  i;
715 
716  if (images == (Image *) NULL)
717  return(0);
718  assert(images->signature == MagickCoreSignature);
719  if (images->debug != MagickFalse)
720  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",images->filename);
721  images=GetLastImageInList(images);
722  for (i=0; images != (Image *) NULL; images=images->previous)
723  {
724  assert(images != images->previous);
725  i++;
726  }
727  return((size_t) i);
728 }
729 
730 /*
731 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
732 % %
733 % %
734 % %
735 % G e t L a s t I m a g e I n L i s t %
736 % %
737 % %
738 % %
739 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
740 %
741 % GetLastImageInList() returns a pointer to the last image in the list.
742 %
743 % The format of the GetLastImageInList method is:
744 %
745 % Image *GetLastImageInList(const Image *images)
746 %
747 % A description of each parameter follows:
748 %
749 % o images: the image list.
750 %
751 */
753 {
754  const Image
755  *p;
756 
757  if (images == (Image *) NULL)
758  return((Image *) NULL);
759  assert(images->signature == MagickCoreSignature);
760  for (p=images; p->next != (Image *) NULL; p=p->next) ;
761  return((Image *) p);
762 }
763 
764 /*
765 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
766 % %
767 % %
768 % %
769 % G e t N e x t I m a g e I n L i s t %
770 % %
771 % %
772 % %
773 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
774 %
775 % GetNextImageInList() returns the next image in the list.
776 %
777 % The format of the GetNextImageInList method is:
778 %
779 % Image *GetNextImageInList(const Image *images)
780 %
781 % A description of each parameter follows:
782 %
783 % o images: the image list.
784 %
785 */
787 {
788  if (images == (Image *) NULL)
789  return((Image *) NULL);
790  assert(images->signature == MagickCoreSignature);
791  if (images->debug != MagickFalse)
792  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",images->filename);
793  return(images->next);
794 }
795 
796 /*
797 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
798 % %
799 % %
800 % %
801 % G e t P r e v i o u s I m a g e I n L i s t %
802 % %
803 % %
804 % %
805 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
806 %
807 % GetPreviousImageInList() returns the previous image in the list.
808 %
809 % The format of the GetPreviousImageInList method is:
810 %
811 % Image *GetPreviousImageInList(const Image *images)
812 %
813 % A description of each parameter follows:
814 %
815 % o images: the image list.
816 %
817 */
819 {
820  if (images == (Image *) NULL)
821  return((Image *) NULL);
822  assert(images->signature == MagickCoreSignature);
823  return(images->previous);
824 }
825 
826 /*
827 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
828 % %
829 % %
830 % I m a g e L i s t T o A r r a y %
831 % %
832 % %
833 % %
834 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
835 %
836 % ImageListToArray() is a convenience method that converts an image list to
837 % a sequential array, with a NULL image pointer at the end of the array.
838 %
839 % The images remain part of the original image list, with the array providing
840 % an alternative means of indexing the image array.
841 %
842 % group = ImageListToArray(images, exception);
843 % while (i = 0; group[i] != (Image *) NULL; i++)
844 % printf("%s\n", group[i]->filename);
845 % printf("%d images\n", i);
846 % group = RelinquishMagickMemory(group);
847 %
848 % The format of the ImageListToArray method is:
849 %
850 % Image **ImageListToArray(const Image *images,ExceptionInfo *exception)
851 %
852 % A description of each parameter follows:
853 %
854 % o image: the image list.
855 %
856 % o exception: return any errors or warnings in this structure.
857 %
858 */
860  ExceptionInfo *exception)
861 {
862  Image
863  **group;
864 
865  ssize_t
866  i;
867 
868  if (images == (Image *) NULL)
869  return((Image **) NULL);
870  assert(images->signature == MagickCoreSignature);
871  if (images->debug != MagickFalse)
872  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",images->filename);
873  group=(Image **) AcquireQuantumMemory((size_t) GetImageListLength(images)+1UL,
874  sizeof(*group));
875  if (group == (Image **) NULL)
876  {
877  (void) ThrowMagickException(exception,GetMagickModule(),
878  ResourceLimitError,"MemoryAllocationFailed","`%s'",images->filename);
879  return((Image **) NULL);
880  }
881  images=GetFirstImageInList(images);
882  for (i=0; images != (Image *) NULL; images=images->next)
883  {
884  assert(images != images->next);
885  group[i++]=(Image *) images;
886  }
887  group[i]=(Image *) NULL;
888  return(group);
889 }
890 
891 /*
892 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
893 % %
894 % %
895 % %
896 % I n s e r t I m a g e I n L i s t %
897 % %
898 % %
899 % %
900 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
901 %
902 % InsertImageInList() insert the given image or image list, into the first
903 % image list, immediately AFTER the image pointed to. The given image list
904 % pointer is left unchanged unless previously empty.
905 %
906 % The format of the InsertImageInList method is:
907 %
908 % InsertImageInList(Image **images,Image *insert)
909 %
910 % A description of each parameter follows:
911 %
912 % o images: the image list to insert into.
913 %
914 % o insert: the image list to insert.
915 %
916 */
918 {
919  Image
920  *split;
921 
922  assert(images != (Image **) NULL);
923  assert(insert != (Image *) NULL);
924  assert(insert->signature == MagickCoreSignature);
925  if (insert->debug != MagickFalse)
926  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",insert->filename);
927  if ((*images) == (Image *) NULL)
928  return;
929  assert((*images)->signature == MagickCoreSignature);
930  split=SplitImageList(*images);
931  AppendImageToList(images,insert);
932  AppendImageToList(images,split);
933 }
934 
935 /*
936 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
937 % %
938 % %
939 % %
940 % N e w I m a g e L i s t %
941 % %
942 % %
943 % %
944 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
945 %
946 % NewImageList() creates an empty image list.
947 %
948 % The format of the NewImageList method is:
949 %
950 % Image *NewImageList(void)
951 %
952 */
954 {
955  return((Image *) NULL);
956 }
957 
958 /*
959 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
960 % %
961 % %
962 % %
963 % P r e p e n d I m a g e T o L i s t %
964 % %
965 % %
966 % %
967 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
968 %
969 % PrependImageToList() prepends the image to the beginning of the list.
970 %
971 % The format of the PrependImageToList method is:
972 %
973 % PrependImageToList(Image *images,Image *image)
974 %
975 % A description of each parameter follows:
976 %
977 % o images: the image list.
978 %
979 % o image: the image.
980 %
981 */
983 {
984  if (*images == (Image *) NULL)
985  {
986  *images=prepend;
987  return;
988  }
989  AppendImageToList(&prepend,*images);
990 }
991 
992 /*
993 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
994 % %
995 % %
996 % %
997 % R e m o v e I m a g e F r o m L i s t %
998 % %
999 % %
1000 % %
1001 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1002 %
1003 % RemoveImageFromList() removes and returns the image pointed to.
1004 %
1005 % The given image list pointer is set to point to the next image in list
1006 % if it exists, otherwise it is set to the previous image, or NULL if list
1007 % was emptied.
1008 %
1009 % The format of the RemoveImageFromList method is:
1010 %
1011 % Image *RemoveImageFromList(Image **images)
1012 %
1013 % A description of each parameter follows:
1014 %
1015 % o images: the image list.
1016 %
1017 */
1019 {
1020  Image
1021  *p;
1022 
1023  assert(images != (Image **) NULL);
1024  if ((*images) == (Image *) NULL)
1025  return((Image *) NULL);
1026  assert((*images)->signature == MagickCoreSignature);
1027  if ((*images)->debug != MagickFalse)
1029  (*images)->filename);
1030  p=(*images);
1031  if ((p->previous == (Image *) NULL) && (p->next == (Image *) NULL))
1032  *images=(Image *) NULL;
1033  else
1034  {
1035  if (p->previous != (Image *) NULL)
1036  {
1037  p->previous->next=p->next;
1038  *images=p->previous;
1039  }
1040  if (p->next != (Image *) NULL)
1041  {
1042  p->next->previous=p->previous;
1043  *images=p->next;
1044  }
1045  p->previous=(Image *) NULL;
1046  p->next=(Image *) NULL;
1047  }
1048  return(p);
1049 }
1050 
1051 /*
1052 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1053 % %
1054 % %
1055 % %
1056 % R e m o v e F i r s t I m a g e F r o m L i s t %
1057 % %
1058 % %
1059 % %
1060 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1061 %
1062 % RemoveFirstImageFromList() removes and returns the first image in the list.
1063 %
1064 % If the given image list pointer pointed to the removed first image, it is
1065 % set to the new first image of list, or NULL if list was emptied, otherwise
1066 % it is left as is.
1067 %
1068 % The format of the RemoveFirstImageFromList method is:
1069 %
1070 % Image *RemoveFirstImageFromList(Image **images)
1071 %
1072 % A description of each parameter follows:
1073 %
1074 % o images: the image list.
1075 %
1076 */
1078 {
1079  Image
1080  *image;
1081 
1082  assert(images != (Image **) NULL);
1083  if ((*images) == (Image *) NULL)
1084  return((Image *) NULL);
1085  assert((*images)->signature == MagickCoreSignature);
1086  if ((*images)->debug != MagickFalse)
1088  (*images)->filename);
1089  image=(*images);
1090  while (image->previous != (Image *) NULL)
1091  image=image->previous;
1092  if (image == *images)
1093  *images=(*images)->next;
1094  if (image->next != (Image *) NULL)
1095  {
1096  image->next->previous=(Image *) NULL;
1097  image->next=(Image *) NULL;
1098  }
1099  return(image);
1100 }
1101 
1102 /*
1103 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1104 % %
1105 % %
1106 % %
1107 % R e m o v e L a s t I m a g e F r o m L i s t %
1108 % %
1109 % %
1110 % %
1111 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1112 %
1113 % RemoveLastImageFromList() removes and returns the last image from the list.
1114 %
1115 % If the given image list pointer pointed to the removed last image, it is
1116 % set to the new last image of list, or NULL if list was emptied, otherwise
1117 % it is left as is.
1118 %
1119 % The format of the RemoveLastImageFromList method is:
1120 %
1121 % Image *RemoveLastImageFromList(Image **images)
1122 %
1123 % A description of each parameter follows:
1124 %
1125 % o images: the image list.
1126 %
1127 */
1129 {
1130  Image
1131  *image;
1132 
1133  assert(images != (Image **) NULL);
1134  if ((*images) == (Image *) NULL)
1135  return((Image *) NULL);
1136  assert((*images)->signature == MagickCoreSignature);
1137  if ((*images)->debug != MagickFalse)
1139  (*images)->filename);
1140  image=(*images);
1141  while (image->next != (Image *) NULL)
1142  image=image->next;
1143  if (image == *images)
1144  *images=(*images)->previous;
1145  if (image->previous != (Image *) NULL)
1146  {
1147  image->previous->next=(Image *) NULL;
1148  image->previous=(Image *) NULL;
1149  }
1150  return(image);
1151 }
1152 
1153 /*
1154 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1155 % %
1156 % %
1157 % %
1158 % R e p l a c e I m a g e I n L i s t %
1159 % %
1160 % %
1161 % %
1162 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1163 %
1164 % ReplaceImageInList() replaces an image in the list with the given image, or
1165 % list of images. Old image is destroyed.
1166 %
1167 % The images list pointer is set to point to the first image of the inserted
1168 % list of images.
1169 %
1170 % The format of the ReplaceImageInList method is:
1171 %
1172 % ReplaceImageInList(Image **images,Image *replace)
1173 %
1174 % A description of each parameter follows:
1175 %
1176 % o images: the list and pointer to image to replace
1177 %
1178 % o replace: the image or image list replacing the original
1179 %
1180 */
1182 {
1183  assert(images != (Image **) NULL);
1184  assert(replace != (Image *) NULL);
1185  assert(replace->signature == MagickCoreSignature);
1186  if (replace->debug != MagickFalse)
1187  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",replace->filename);
1188  if ((*images) == (Image *) NULL)
1189  return;
1190  assert((*images)->signature == MagickCoreSignature);
1191  /*
1192  Link next pointer.
1193  */
1194  replace=GetLastImageInList(replace);
1195  replace->next=(*images)->next;
1196  if (replace->next != (Image *) NULL)
1197  replace->next->previous=replace;
1198  /*
1199  Link previous pointer - set images position to first replacement image.
1200  */
1201  replace=GetFirstImageInList(replace);
1202  replace->previous=(*images)->previous;
1203  if (replace->previous != (Image *) NULL)
1204  replace->previous->next=replace;
1205  /*
1206  Destroy the replaced image that was in images.
1207  */
1208  (void) DestroyImage(*images);
1209  (*images)=replace;
1210 }
1211 
1212 /*
1213 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1214 % %
1215 % %
1216 % %
1217 % R e p l a c e I m a g e I n L i s t R e t u r n L a s t %
1218 % %
1219 % %
1220 % %
1221 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1222 %
1223 % ReplaceImageInListReturnLast() is exactly as ReplaceImageInList() except
1224 % the images pointer is set to the last image in the list of replacement
1225 % images.
1226 %
1227 % This allows you to simply use GetNextImageInList() to go to the image
1228 % that follows the just replaced image, even if a list of replacement images
1229 % was inserted.
1230 %
1231 % The format of the ReplaceImageInList method is:
1232 %
1233 % ReplaceImageInListReturnLast(Image **images,Image *replace)
1234 %
1235 % A description of each parameter follows:
1236 %
1237 % o images: the list and pointer to image to replace
1238 %
1239 % o replace: the image or image list replacing the original
1240 %
1241 */
1243 {
1244  assert(images != (Image **) NULL);
1245  assert(replace != (Image *) NULL);
1246  assert(replace->signature == MagickCoreSignature);
1247  if (replace->debug != MagickFalse)
1248  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",replace->filename);
1249  if ((*images) == (Image *) NULL)
1250  return;
1251  assert((*images)->signature == MagickCoreSignature);
1252  /*
1253  Link previous pointer.
1254  */
1255  replace=GetFirstImageInList(replace);
1256  replace->previous=(*images)->previous;
1257  if (replace->previous != (Image *) NULL)
1258  replace->previous->next=replace;
1259  /*
1260  Link next pointer - set images position to last replacement image.
1261  */
1262  replace=GetLastImageInList(replace);
1263  replace->next=(*images)->next;
1264  if (replace->next != (Image *) NULL)
1265  replace->next->previous=replace;
1266  /*
1267  Destroy the replaced image that was in images.
1268  */
1269  (void) DestroyImage(*images);
1270  (*images)=replace;
1271 }
1272 
1273 /*
1274 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1275 % %
1276 % %
1277 % %
1278 % R e v e r s e I m a g e L i s t %
1279 % %
1280 % %
1281 % %
1282 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1283 %
1284 % ReverseImageList() reverses the order of an image list.
1285 % The list pointer is reset to that start of the re-ordered list.
1286 %
1287 % The format of the ReverseImageList method is:
1288 %
1289 % void ReverseImageList(Image **images)
1290 %
1291 % A description of each parameter follows:
1292 %
1293 % o images: the image list.
1294 %
1295 */
1297 {
1298  Image
1299  *next;
1300 
1301  Image
1302  *p;
1303 
1304  assert(images != (Image **) NULL);
1305  if ((*images) == (Image *) NULL)
1306  return;
1307  assert((*images)->signature == MagickCoreSignature);
1308  if ((*images)->debug != MagickFalse)
1310  (*images)->filename);
1311  for (p=(*images); p->next != (Image *) NULL; p=p->next) ;
1312  *images=p;
1313  for ( ; p != (Image *) NULL; p=p->next)
1314  {
1315  next=p->next;
1316  p->next=p->previous;
1317  p->previous=next;
1318  }
1319 }
1320 
1321 /*
1322 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1323 % %
1324 % %
1325 % %
1326 % S p l i c e I m a g e I n t o L i s t %
1327 % %
1328 % %
1329 % %
1330 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1331 %
1332 % SpliceImageIntoList() removes 'length' images from the list and replaces
1333 % them with the specified splice. Removed images are returned.
1334 %
1335 % The format of the SpliceImageIntoList method is:
1336 %
1337 % SpliceImageIntoList(Image **images,const size_t,
1338 % const Image *splice)
1339 %
1340 % A description of each parameter follows:
1341 %
1342 % o images: the image list.
1343 %
1344 % o length: the length of the image list to remove.
1345 %
1346 % o splice: Replace the removed image list with this list.
1347 %
1348 */
1350  const size_t length,const Image *splice)
1351 {
1352  Image
1353  *image,
1354  *split;
1355 
1356  size_t
1357  i;
1358 
1359  assert(images != (Image **) NULL);
1360  assert(splice != (Image *) NULL);
1361  assert(splice->signature == MagickCoreSignature);
1362  if ((*images) == (Image *) NULL)
1363  return((Image *) NULL);
1364  assert((*images)->signature == MagickCoreSignature);
1365  if ((*images)->debug != MagickFalse)
1367  (*images)->filename);
1368  split=SplitImageList(*images);
1369  AppendImageToList(images,splice);
1370  image=(Image *) NULL;
1371  for (i=0; (i < length) && (split != (Image *) NULL); i++)
1372  AppendImageToList(&image,RemoveImageFromList(&split));
1373  AppendImageToList(images,split);
1374  return(image);
1375 }
1376 
1377 /*
1378 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1379 % %
1380 % %
1381 % %
1382 % S p l i t I m a g e L i s t %
1383 % %
1384 % %
1385 % %
1386 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1387 %
1388 % SplitImageList() splits an image into two lists, after given image
1389 % The list that was split off is returned, which may be empty.
1390 %
1391 % The format of the SplitImageList method is:
1392 %
1393 % Image *SplitImageList(Image *images)
1394 %
1395 % A description of each parameter follows:
1396 %
1397 % o images: the image list.
1398 %
1399 */
1401 {
1402  if ((images == (Image *) NULL) || (images->next == (Image *) NULL))
1403  return((Image *) NULL);
1404  images=images->next;
1405  images->previous->next=(Image *) NULL;
1406  images->previous=(Image *) NULL;
1407  return(images);
1408 }
1409 
1410 /*
1411 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1412 % %
1413 % %
1414 % %
1415 + S y n c I m a g e L i s t %
1416 % %
1417 % %
1418 % %
1419 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1420 %
1421 % SyncImageList() synchronizes the scene numbers in an image list.
1422 %
1423 % The format of the SyncImageList method is:
1424 %
1425 % void SyncImageList(Image *images)
1426 %
1427 % A description of each parameter follows:
1428 %
1429 % o images: the image list.
1430 %
1431 */
1433 {
1434  Image
1435  *p,
1436  *q;
1437 
1438  if (images == (Image *) NULL)
1439  return;
1440  assert(images->signature == MagickCoreSignature);
1441  for (p=images; p != (Image *) NULL; p=p->next)
1442  {
1443  for (q=p->next; q != (Image *) NULL; q=q->next)
1444  if (p->scene == q->scene)
1445  break;
1446  if (q != (Image *) NULL)
1447  break;
1448  }
1449  if (p == (Image *) NULL)
1450  return;
1451  for (p=images->next; p != (Image *) NULL; p=p->next)
1452  p->scene=p->previous->scene+1;
1453 }
1454 
1455 /*
1456 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1457 % %
1458 % %
1459 % %
1460 + S y n c N e x t I m a g e I n L i s t %
1461 % %
1462 % %
1463 % %
1464 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1465 %
1466 % SyncNextImageInList() returns the next image in the list after the blob
1467 % referenced is synchronized with the current image.
1468 %
1469 % The format of the SyncNextImageInList method is:
1470 %
1471 % Image *SyncNextImageInList(const Image *images)
1472 %
1473 % A description of each parameter follows:
1474 %
1475 % o images: the image list.
1476 %
1477 */
1479 {
1480  if (images == (Image *) NULL)
1481  return((Image *) NULL);
1482  assert(images->signature == MagickCoreSignature);
1483  if (images->next == (Image *) NULL)
1484  return((Image *) NULL);
1485  if (images->blob != images->next->blob)
1486  {
1487  DestroyBlob(images->next);
1488  images->next->blob=ReferenceBlob(images->blob);
1489  }
1490  if (images->next->compression == UndefinedCompression)
1491  images->next->compression=images->compression;
1492  if (images->next->endian == UndefinedEndian)
1493  images->next->endian=images->endian;
1494  return(images->next);
1495 }
MagickExport Image * CloneImages(const Image *images, const char *scenes, ExceptionInfo *exception)
Definition: list.c:206
MagickExport Image * GetImageFromList(const Image *images, const ssize_t index)
Definition: list.c:620
size_t signature
Definition: exception.h:123
MagickExport Image * RemoveFirstImageFromList(Image **images)
Definition: list.c:1077
EndianType endian
Definition: image.h:228
MagickExport void InsertImageInList(Image **images, Image *insert)
Definition: list.c:917
MagickExport const char * GetImageArtifact(const Image *image, const char *artifact)
Definition: artifact.c:273
static long StringToLong(const char *magick_restrict value)
MagickExport void DeleteImages(Image **images, const char *scenes, ExceptionInfo *exception)
Definition: list.c:372
MagickExport Image * SpliceImageIntoList(Image **images, const size_t length, const Image *splice)
Definition: list.c:1349
CompressionType compression
Definition: image.h:160
MagickExport Image * DuplicateImages(Image *images, const size_t number_duplicates, const char *scenes, ExceptionInfo *exception)
Definition: list.c:525
Definition: log.h:52
Definition: image.h:151
MagickExport Image * GetPreviousImageInList(const Image *images)
Definition: list.c:818
#define MagickCoreSignature
MagickExport Image * GetFirstImageInList(const Image *images)
Definition: list.c:576
MagickExport Image * RemoveImageFromList(Image **images)
Definition: list.c:1018
MagickBooleanType
Definition: magick-type.h:169
MagickExport Image * NewImageList(void)
Definition: list.c:953
size_t scene
Definition: image.h:240
MagickExport void ReplaceImageInListReturnLast(Image **images, Image *replace)
Definition: list.c:1242
MagickExport Image * SplitImageList(Image *images)
Definition: list.c:1400
MagickExport void * AcquireQuantumMemory(const size_t count, const size_t quantum)
Definition: memory.c:665
MagickExport Image * SyncNextImageInList(const Image *images)
Definition: list.c:1478
struct _Image * previous
Definition: image.h:348
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:1660
size_t signature
Definition: image.h:354
struct _Image * next
Definition: image.h:348
MagickExport Image * GetLastImageInList(const Image *images)
Definition: list.c:752
MagickExport Image * DestroyImageList(Image *images)
Definition: list.c:477
MagickExport Image * RemoveLastImageFromList(Image **images)
Definition: list.c:1128
char filename[MagickPathExtent]
Definition: image.h:319
ElementInfo * next
Definition: linked-list.c:75
#define GetMagickModule()
Definition: log.h:28
MagickExport Image * CloneImageList(const Image *images, ExceptionInfo *exception)
Definition: list.c:128
MagickExport Image ** ImageListToArray(const Image *images, ExceptionInfo *exception)
Definition: list.c:859
MagickExport void ReplaceImageInList(Image **images, Image *replace)
Definition: list.c:1181
MagickExport ssize_t GetImageIndexInList(const Image *images)
Definition: list.c:672
MagickExport Image * GetNextImageInList(const Image *images)
Definition: list.c:786
MagickExport void AppendImageToList(Image **images, const Image *append)
Definition: list.c:80
BlobInfo * blob
Definition: image.h:328
MagickExport void SyncImageList(Image *images)
Definition: list.c:1432
MagickExport void * RelinquishMagickMemory(void *memory)
Definition: memory.c:1162
MagickExport BlobInfo * ReferenceBlob(BlobInfo *)
Definition: blob.c:4886
MagickExport void PrependImageToList(Image **images, Image *prepend)
Definition: list.c:982
#define MagickExport
MagickExport void DestroyBlob(Image *image)
Definition: blob.c:933
MagickExport void DeleteImageFromList(Image **images)
Definition: list.c:326
MagickExport size_t GetImageListLength(const Image *images)
Definition: list.c:711
MagickExport void ReverseImageList(Image **images)
Definition: list.c:1296
MagickExport Image * DestroyImage(Image *image)
Definition: image.c:1177
MagickExport Image * CloneImage(const Image *image, const size_t columns, const size_t rows, const MagickBooleanType detach, ExceptionInfo *exception)
Definition: image.c:788
MagickBooleanType debug
Definition: image.h:334