2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 % M M OOO N N TTTTT AAA GGGG EEEEE %
7 % MM MM O O NN N T A A G E %
8 % M M M O O N N N T AAAAA G GG EEE %
9 % M M O O N NN T A A G G E %
10 % M M OOO N N T A A GGG EEEEE %
13 % MagickCore Methods to Create Image Thumbnails %
20 % Copyright 1999-2009 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
26 % http://www.imagemagick.org/script/license.php %
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. %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43 #include "magick/studio.h"
44 #include "magick/annotate.h"
45 #include "magick/client.h"
46 #include "magick/color.h"
47 #include "magick/composite.h"
48 #include "magick/constitute.h"
49 #include "magick/decorate.h"
50 #include "magick/draw.h"
51 #include "magick/effect.h"
52 #include "magick/enhance.h"
53 #include "magick/exception.h"
54 #include "magick/exception-private.h"
55 #include "magick/fx.h"
56 #include "magick/gem.h"
57 #include "magick/geometry.h"
58 #include "magick/image.h"
59 #include "magick/image-private.h"
60 #include "magick/list.h"
61 #include "magick/memory_.h"
62 #include "magick/monitor.h"
63 #include "magick/monitor-private.h"
64 #include "magick/montage.h"
65 #include "magick/option.h"
66 #include "magick/quantize.h"
67 #include "magick/property.h"
68 #include "magick/resize.h"
69 #include "magick/resource_.h"
70 #include "magick/string_.h"
71 #include "magick/utility.h"
72 #include "magick/version.h"
75 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
79 % C l o n e M o n t a g e I n f o %
83 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
85 % CloneMontageInfo() makes a copy of the given montage info structure. If
86 % NULL is specified, a new image info structure is created initialized to
89 % The format of the CloneMontageInfo method is:
91 % MontageInfo *CloneMontageInfo(const ImageInfo *image_info,
92 % const MontageInfo *montage_info)
94 % A description of each parameter follows:
96 % o image_info: the image info.
98 % o montage_info: the montage info.
101 MagickExport MontageInfo *CloneMontageInfo(const ImageInfo *image_info,
102 const MontageInfo *montage_info)
107 clone_info=(MontageInfo *) AcquireMagickMemory(sizeof(*clone_info));
108 if (clone_info == (MontageInfo *) NULL)
109 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
110 GetMontageInfo(image_info,clone_info);
111 if (montage_info == (MontageInfo *) NULL)
113 if (montage_info->geometry != (char *) NULL)
114 clone_info->geometry=AcquireString(montage_info->geometry);
115 if (montage_info->tile != (char *) NULL)
116 clone_info->tile=AcquireString(montage_info->tile);
117 if (montage_info->title != (char *) NULL)
118 clone_info->title=AcquireString(montage_info->title);
119 if (montage_info->frame != (char *) NULL)
120 clone_info->frame=AcquireString(montage_info->frame);
121 if (montage_info->texture != (char *) NULL)
122 clone_info->texture=AcquireString(montage_info->texture);
123 if (montage_info->font != (char *) NULL)
124 clone_info->font=AcquireString(montage_info->font);
125 clone_info->pointsize=montage_info->pointsize;
126 clone_info->border_width=montage_info->border_width;
127 clone_info->shadow=montage_info->shadow;
128 clone_info->fill=montage_info->fill;
129 clone_info->stroke=montage_info->stroke;
130 clone_info->background_color=montage_info->background_color;
131 clone_info->border_color=montage_info->border_color;
132 clone_info->matte_color=montage_info->matte_color;
133 clone_info->gravity=montage_info->gravity;
134 (void) CopyMagickString(clone_info->filename,montage_info->filename,
136 clone_info->debug=IsEventLogging();
141 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
145 % D e s t r o y M o n t a g e I n f o %
149 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
151 % DestroyMontageInfo() deallocates memory associated with montage_info.
153 % The format of the DestroyMontageInfo method is:
155 % MontageInfo *DestroyMontageInfo(MontageInfo *montage_info)
157 % A description of each parameter follows:
159 % o montage_info: Specifies a pointer to an MontageInfo structure.
163 MagickExport MontageInfo *DestroyMontageInfo(MontageInfo *montage_info)
165 if (montage_info->debug != MagickFalse)
166 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
167 assert(montage_info != (MontageInfo *) NULL);
168 assert(montage_info->signature == MagickSignature);
169 if (montage_info->geometry != (char *) NULL)
170 montage_info->geometry=(char *)
171 RelinquishMagickMemory(montage_info->geometry);
172 if (montage_info->tile != (char *) NULL)
173 montage_info->tile=DestroyString(montage_info->tile);
174 if (montage_info->title != (char *) NULL)
175 montage_info->title=DestroyString(montage_info->title);
176 if (montage_info->frame != (char *) NULL)
177 montage_info->frame=DestroyString(montage_info->frame);
178 if (montage_info->texture != (char *) NULL)
179 montage_info->texture=(char *) RelinquishMagickMemory(
180 montage_info->texture);
181 if (montage_info->font != (char *) NULL)
182 montage_info->font=DestroyString(montage_info->font);
183 montage_info->signature=(~MagickSignature);
184 montage_info=(MontageInfo *) RelinquishMagickMemory(montage_info);
185 return(montage_info);
189 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
193 % G e t M o n t a g e I n f o %
197 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
199 % GetMontageInfo() initializes montage_info to default values.
201 % The format of the GetMontageInfo method is:
203 % void GetMontageInfo(const ImageInfo *image_info,
204 % MontageInfo *montage_info)
206 % A description of each parameter follows:
208 % o image_info: a structure of type ImageInfo.
210 % o montage_info: Specifies a pointer to a MontageInfo structure.
213 MagickExport void GetMontageInfo(const ImageInfo *image_info,
214 MontageInfo *montage_info)
216 assert(image_info != (const ImageInfo *) NULL);
217 assert(image_info->signature == MagickSignature);
218 if (image_info->debug != MagickFalse)
219 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
220 image_info->filename);
221 assert(montage_info != (MontageInfo *) NULL);
222 (void) ResetMagickMemory(montage_info,0,sizeof(*montage_info));
223 (void) CopyMagickString(montage_info->filename,image_info->filename,
225 montage_info->geometry=AcquireString(DefaultTileGeometry);
226 if (image_info->font != (char *) NULL)
227 montage_info->font=AcquireString(image_info->font);
228 montage_info->gravity=CenterGravity;
229 montage_info->pointsize=image_info->pointsize;
230 montage_info->fill.opacity=OpaqueOpacity;
231 montage_info->stroke.opacity=(Quantum) TransparentOpacity;
232 montage_info->background_color=image_info->background_color;
233 montage_info->border_color=image_info->border_color;
234 montage_info->matte_color=image_info->matte_color;
235 montage_info->debug=IsEventLogging();
236 montage_info->signature=MagickSignature;
240 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
244 % M o n t a g e I m a g e L i s t %
248 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
250 % MontageImageList() is a layout manager that lets you tile one or more
251 % thumbnails across an image canvas.
253 % The format of the MontageImageList method is:
255 % Image *MontageImageList(const ImageInfo *image_info,
256 % const MontageInfo *montage_info,Image *images,
257 % ExceptionInfo *exception)
259 % A description of each parameter follows:
261 % o image_info: the image info.
263 % o montage_info: Specifies a pointer to a MontageInfo structure.
265 % o images: Specifies a pointer to an array of Image structures.
267 % o exception: return any errors or warnings in this structure.
271 static void GetMontageGeometry(char *geometry,const unsigned long number_images,
272 long *x_offset,long *y_offset,unsigned long *tiles_per_column,
273 unsigned long *tiles_per_row)
277 (void) GetGeometry(geometry,x_offset,y_offset,tiles_per_row,tiles_per_column);
278 if ((*tiles_per_column == 0) && (*tiles_per_row == 0))
279 *tiles_per_column=(unsigned long) sqrt((double) number_images);
280 if (*tiles_per_column == 0)
281 *tiles_per_column=(unsigned long)
282 ceil((double) number_images/(*tiles_per_row));
283 if (*tiles_per_row == 0)
284 *tiles_per_row=(unsigned long)
285 ceil((double) number_images/(*tiles_per_column));
288 static inline long MagickMax(const long x,const long y)
295 static inline long MagickMin(const long x,const long y)
302 #if defined(__cplusplus) || defined(c_plusplus)
306 static int SceneCompare(const void *x,const void *y)
312 image_1=(Image **) x;
313 image_2=(Image **) y;
314 return((int) ((*image_1)->scene-(*image_2)->scene));
317 #if defined(__cplusplus) || defined(c_plusplus)
321 MagickExport Image *MontageImages(const Image *images,
322 const MontageInfo *montage_info,ExceptionInfo *exception)
330 image_info=AcquireImageInfo();
331 montage_image=MontageImageList(image_info,montage_info,images,exception);
332 image_info=DestroyImageInfo(image_info);
333 return(montage_image);
336 MagickExport Image *MontageImageList(const ImageInfo *image_info,
337 const MontageInfo *montage_info,const Image *images,ExceptionInfo *exception)
339 #define MontageImageTag "Montage/Image"
340 #define TileImageTag "Tile/Image"
343 tile_geometry[MaxTextExtent],
385 MagickProgressMonitor
421 assert(images != (Image *) NULL);
422 assert(images->signature == MagickSignature);
423 if (images->debug != MagickFalse)
424 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",images->filename);
425 assert(montage_info != (MontageInfo *) NULL);
426 assert(montage_info->signature == MagickSignature);
427 assert(exception != (ExceptionInfo *) NULL);
428 assert(exception->signature == MagickSignature);
429 number_images=GetImageListLength(images);
430 master_list=ImageListToArray(images,exception);
431 image_list=master_list;
433 if (master_list == (Image **) NULL)
434 ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
435 thumbnail=NewImageList();
436 for (i=0; i < (long) number_images; i++)
438 image=CloneImage(image_list[i],0,0,MagickTrue,exception);
439 if (image == (Image *) NULL)
441 (void) ParseAbsoluteGeometry("0x0+0+0",&image->page);
442 progress_monitor=SetImageProgressMonitor(image,(MagickProgressMonitor) NULL,
444 flags=ParseRegionGeometry(image,montage_info->geometry,&geometry,exception);
445 thumbnail=ThumbnailImage(image,geometry.width,geometry.height,exception);
446 if (thumbnail == (Image *) NULL)
448 image_list[i]=thumbnail;
449 (void) SetImageProgressMonitor(image,progress_monitor,image->client_data);
450 proceed=SetImageProgress(image,TileImageTag,i,number_images);
451 if (proceed == MagickFalse)
453 image=DestroyImage(image);
455 if (i < (long) number_images)
457 if (thumbnail == (Image *) NULL)
459 for (tile=0; (long) tile <= i; tile++)
460 if (image_list[tile] != (Image *) NULL)
461 image_list[tile]=DestroyImage(image_list[tile]);
462 master_list=(Image **) RelinquishMagickMemory(master_list);
463 return((Image *) NULL);
466 Sort image list by increasing tile number.
468 for (i=0; i < (long) number_images; i++)
469 if (image_list[i]->scene == 0)
471 if (i == (long) number_images)
472 qsort((void *) image_list,(size_t) number_images,sizeof(*image_list),
475 Determine tiles per row and column.
477 tiles_per_column=(unsigned long) sqrt((double) number_images);
478 tiles_per_row=(unsigned long) ceil((double) number_images/tiles_per_column);
481 if (montage_info->tile != (char *) NULL)
482 GetMontageGeometry(montage_info->tile,number_images,&x_offset,&y_offset,
483 &tiles_per_column,&tiles_per_row);
485 Determine tile sizes.
487 concatenate=MagickFalse;
488 SetGeometry(image_list[0],&extract_info);
489 extract_info.x=(long) montage_info->border_width;
490 extract_info.y=(long) montage_info->border_width;
491 if (montage_info->geometry != (char *) NULL)
494 Initialize tile geometry.
496 flags=GetGeometry(montage_info->geometry,&extract_info.x,&extract_info.y,
497 &extract_info.width,&extract_info.height);
498 if ((extract_info.x == 0) && (extract_info.y == 0))
499 concatenate=((flags & RhoValue) == 0) && ((flags & SigmaValue) == 0) ?
500 MagickTrue : MagickFalse;
502 border_width=montage_info->border_width;
504 if (montage_info->frame != (char *) NULL)
507 absolute_geometry[MaxTextExtent];
509 (void) ResetMagickMemory(&frame_info,0,sizeof(frame_info));
510 frame_info.width=extract_info.width;
511 frame_info.height=extract_info.height;
512 (void) FormatMagickString(absolute_geometry,MaxTextExtent,"%s!",
513 montage_info->frame);
514 flags=ParseMetaGeometry(absolute_geometry,&frame_info.outer_bevel,
515 &frame_info.inner_bevel,&frame_info.width,&frame_info.height);
516 if ((flags & HeightValue) == 0)
517 frame_info.height=frame_info.width;
518 if ((flags & XiValue) == 0)
519 frame_info.outer_bevel=(long) frame_info.width/2;
520 if ((flags & PsiValue) == 0)
521 frame_info.inner_bevel=frame_info.outer_bevel;
522 frame_info.x=(long) frame_info.width;
523 frame_info.y=(long) frame_info.height;
524 bevel_width=(unsigned long) MagickMax(frame_info.inner_bevel,
525 frame_info.outer_bevel);
526 border_width=(unsigned long) MagickMax((long) frame_info.width,
527 (long) frame_info.height);
529 for (i=0; i < (long) number_images; i++)
531 if (image_list[i]->columns > extract_info.width)
532 extract_info.width=image_list[i]->columns;
533 if (image_list[i]->rows > extract_info.height)
534 extract_info.height=image_list[i]->rows;
537 Initialize draw attributes.
539 clone_info=CloneImageInfo(image_info);
540 clone_info->background_color=montage_info->background_color;
541 clone_info->border_color=montage_info->border_color;
542 draw_info=CloneDrawInfo(clone_info,(DrawInfo *) NULL);
543 if (montage_info->font != (char *) NULL)
544 (void) CloneString(&draw_info->font,montage_info->font);
545 if (montage_info->pointsize != 0.0)
546 draw_info->pointsize=montage_info->pointsize;
547 draw_info->gravity=CenterGravity;
548 draw_info->stroke=montage_info->stroke;
549 draw_info->fill=montage_info->fill;
550 draw_info->text=AcquireString("");
551 (void) GetTypeMetrics(image_list[0],draw_info,&metrics);
552 texture=NewImageList();
553 if (montage_info->texture != (char *) NULL)
555 (void) CopyMagickString(clone_info->filename,montage_info->texture,
557 texture=ReadImage(clone_info,exception);
560 Determine the number of lines in an next label.
562 title=InterpretImageProperties(clone_info,image_list[0],montage_info->title);
564 if (montage_info->title != (char *) NULL)
565 title_offset=(unsigned long) (2*(metrics.ascent-metrics.descent)*
566 MultilineCensus(title)+2*extract_info.y);
568 for (i=0; i < (long) number_images; i++)
570 value=GetImageProperty(image_list[i],"label");
571 if (value == (const char *) NULL)
573 if (MultilineCensus(value) > number_lines)
574 number_lines=MultilineCensus(value);
577 Allocate next structure.
579 tile_image=AcquireImage(NULL);
580 montage=AcquireImage(clone_info);
582 images_per_page=(number_images-1)/(tiles_per_row*tiles_per_column)+1;
584 total_tiles=(unsigned long) number_images;
585 for (i=0; i < (long) images_per_page; i++)
588 Determine bounding box.
590 tiles_per_page=tiles_per_row*tiles_per_column;
593 if (montage_info->tile != (char *) NULL)
594 GetMontageGeometry(montage_info->tile,number_images,&x_offset,&y_offset,
596 tiles_per_page=tiles_per_row*tiles_per_column;
597 y_offset+=(long) title_offset;
602 for (tile=0; tile < (long) tiles_per_page; tile++)
604 if (tile < (long) number_images)
606 width=concatenate != MagickFalse ? image_list[tile]->columns :
608 if (image_list[tile]->rows > max_height)
609 max_height=image_list[tile]->rows;
611 x_offset+=width+(extract_info.x+border_width)*2;
612 if (x_offset > (long) bounds.width)
613 bounds.width=(unsigned long) x_offset;
614 if (((tile+1) == (long) tiles_per_page) ||
615 (((tile+1) % tiles_per_row) == 0))
618 if (montage_info->tile != (char *) NULL)
619 GetMontageGeometry(montage_info->tile,number_images,&x_offset,&y,
621 height=concatenate != MagickFalse ? max_height : extract_info.height;
622 y_offset+=(unsigned long) (height+(extract_info.y+border_width)*2+
623 (metrics.ascent-metrics.descent+4)*number_lines+
624 (montage_info->shadow != MagickFalse ? 4 : 0));
625 if (y_offset > (long) bounds.height)
626 bounds.height=(unsigned long) y_offset;
630 if (montage_info->shadow != MagickFalse)
633 Initialize montage image.
635 (void) CopyMagickString(montage->filename,montage_info->filename,
637 montage->columns=bounds.width;
638 montage->rows=bounds.height;
639 (void) SetImageBackgroundColor(montage);
641 Set montage geometry.
643 montage->montage=AcquireString((char *) NULL);
646 while (tile < MagickMin((long) tiles_per_page,(long) number_images))
648 extent+=strlen(image_list[tile]->filename)+1;
651 montage->directory=(char *) AcquireQuantumMemory(extent,
652 sizeof(*montage->directory));
653 if ((montage->montage == (char *) NULL) ||
654 (montage->directory == (char *) NULL))
655 ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
658 if (montage_info->tile != (char *) NULL)
659 GetMontageGeometry(montage_info->tile,number_images,&x_offset,&y_offset,
661 y_offset+=(long) title_offset;
662 (void) FormatMagickString(montage->montage,MaxTextExtent,"%ldx%ld%+ld%+ld",
663 (long) (extract_info.width+(extract_info.x+border_width)*2),
664 (long) (extract_info.height+(extract_info.y+border_width)*2+
665 (metrics.ascent-metrics.descent+4)*number_lines+
666 (montage_info->shadow != MagickFalse ? 4 : 0)),x_offset,y_offset);
667 *montage->directory='\0';
669 while (tile < MagickMin((long) tiles_per_page,(long) number_images))
671 (void) ConcatenateMagickString(montage->directory,
672 image_list[tile]->filename,extent);
673 (void) ConcatenateMagickString(montage->directory,"\n",extent);
676 progress_monitor=SetImageProgressMonitor(montage,(MagickProgressMonitor)
677 NULL,montage->client_data);
678 if (texture != (Image *) NULL)
679 (void) TextureImage(montage,texture);
680 if (montage_info->title != (char *) NULL)
683 geometry[MaxTextExtent];
692 Annotate composite image with title.
694 clone_info=CloneDrawInfo(image_info,draw_info);
695 clone_info->gravity=CenterGravity;
696 clone_info->pointsize*=2.0;
697 (void) GetTypeMetrics(image_list[0],clone_info,&metrics);
698 (void) FormatMagickString(geometry,MaxTextExtent,"%lux%lu%+ld%+ld",
699 montage->columns,(unsigned long) (metrics.ascent-metrics.descent),
700 0L,(long) extract_info.y+4);
701 (void) CloneString(&clone_info->geometry,geometry);
702 (void) CloneString(&clone_info->text,title);
703 (void) AnnotateImage(montage,clone_info);
704 clone_info=DestroyDrawInfo(clone_info);
706 (void) SetImageProgressMonitor(montage,progress_monitor,
707 montage->client_data);
709 Copy tile to the composite.
713 if (montage_info->tile != (char *) NULL)
714 GetMontageGeometry(montage_info->tile,number_images,&x_offset,&y_offset,
716 x_offset+=extract_info.x;
717 y_offset+=(long) title_offset+extract_info.y;
719 for (tile=0; tile < MagickMin((long) tiles_per_page,(long) number_images); tile++)
722 Copy this tile to the composite.
724 image=CloneImage(image_list[tile],0,0,MagickTrue,exception);
725 progress_monitor=SetImageProgressMonitor(image,
726 (MagickProgressMonitor) NULL,image->client_data);
727 width=concatenate != MagickFalse ? image->columns : extract_info.width;
728 if (image->rows > max_height)
729 max_height=image->rows;
730 height=concatenate != MagickFalse ? max_height : extract_info.height;
731 if (border_width != 0)
740 Put a border around the image.
742 border_info.width=border_width;
743 border_info.height=border_width;
744 if (montage_info->frame != (char *) NULL)
746 border_info.width=(width-image->columns+1)/2;
747 border_info.height=(height-image->rows+1)/2;
749 border_image=BorderImage(image,&border_info,exception);
750 if (border_image != (Image *) NULL)
752 image=DestroyImage(image);
755 if ((montage_info->frame != (char *) NULL) &&
756 (image->compose == DstOutCompositeOp))
757 (void) NegateImageChannel(image,OpacityChannel,MagickFalse);
760 Gravitate as specified by the tile gravity.
762 tile_image->columns=width;
763 tile_image->rows=height;
764 tile_image->gravity=montage_info->gravity;
765 if (image->gravity != UndefinedGravity)
766 tile_image->gravity=image->gravity;
767 (void) FormatMagickString(tile_geometry,MaxTextExtent,"%lux%lu+0+0",
768 image->columns,image->rows);
769 flags=ParseGravityGeometry(tile_image,tile_geometry,&geometry,exception);
770 x=(long) (geometry.x+border_width);
771 y=(long) (geometry.y+border_width);
772 if ((montage_info->frame != (char *) NULL) && (bevel_width != 0))
781 Put an ornamental border around this tile.
783 extract_info=frame_info;
784 extract_info.width=width+2*frame_info.width;
785 extract_info.height=height+2*frame_info.height;
786 value=GetImageProperty(image,"label");
787 if (value != (const char *) NULL)
788 extract_info.height+=(unsigned long) ((metrics.ascent-
789 metrics.descent+4)*MultilineCensus(value));
790 frame_image=FrameImage(image,&extract_info,exception);
791 if (frame_image != (Image *) NULL)
793 image=DestroyImage(image);
799 if (LocaleCompare(image->magick,"NULL") != 0)
802 Composite background with tile.
804 if (montage_info->shadow != MagickFalse)
812 (void) QueryColorDatabase("#000000",&image->background_color,
814 shadow_image=ShadowImage(image,80.0,2.0,5,5,exception);
815 if (shadow_image != (Image *) NULL)
817 InheritException(&shadow_image->exception,exception);
818 (void) CompositeImage(shadow_image,OverCompositeOp,image,0,0);
819 image=DestroyImage(image);
823 (void) CompositeImage(montage,OverCompositeOp,image,x_offset+x,
825 value=GetImageProperty(image,"label");
826 if (value != (const char *) NULL)
829 geometry[MaxTextExtent];
832 Annotate composite tile with label.
834 (void) FormatMagickString(geometry,MaxTextExtent,
835 "%lux%lu%+ld%+ld",(montage_info->frame ? image->columns :
836 width)-2*border_width,(unsigned long) (metrics.ascent-
837 metrics.descent+4)*MultilineCensus(value),x_offset+
838 border_width,(montage_info->frame ? y_offset+height+
839 border_width+4 : y_offset+extract_info.height+border_width+
840 (montage_info->shadow != MagickFalse ? 4 : 0)));
841 (void) CloneString(&draw_info->geometry,geometry);
842 (void) CloneString(&draw_info->text,value);
843 (void) AnnotateImage(montage,draw_info);
846 x_offset+=width+(extract_info.x+border_width)*2;
847 if (((tile+1) == (long) tiles_per_page) ||
848 (((tile+1) % tiles_per_row) == 0))
850 x_offset=extract_info.x;
851 y_offset+=(unsigned long) (height+(extract_info.y+border_width)*2+
852 (metrics.ascent-metrics.descent+4)*number_lines+
853 (montage_info->shadow != MagickFalse ? 4 : 0));
856 if ((images->progress_monitor != (MagickProgressMonitor) NULL) &&
857 (QuantumTick(tiles,total_tiles) != MagickFalse))
859 status=images->progress_monitor(MontageImageTag,tiles,total_tiles,
860 images->client_data);
861 if (status == MagickFalse)
864 image_list[tile]=DestroyImage(image_list[tile]);
865 image=DestroyImage(image);
868 if ((i+1) < (long) images_per_page)
871 Allocate next image structure.
873 AcquireNextImage(clone_info,montage);
874 if (GetNextImageInList(montage) == (Image *) NULL)
876 montage=DestroyImageList(montage);
877 return((Image *) NULL);
879 montage=GetNextImageInList(montage);
880 image_list+=tiles_per_page;
881 number_images-=tiles_per_page;
884 tile_image=DestroyImage(tile_image);
885 if (texture != (Image *) NULL)
886 texture=DestroyImage(texture);
887 master_list=(Image **) RelinquishMagickMemory(master_list);
888 draw_info=DestroyDrawInfo(draw_info);
889 clone_info=DestroyImageInfo(clone_info);
890 while (GetPreviousImageInList(montage) != (Image *) NULL)
891 montage=GetPreviousImageInList(montage);