43 #include "magick/studio.h"
44 #include "magick/animate.h"
45 #include "magick/artifact.h"
46 #include "magick/blob.h"
47 #include "magick/blob-private.h"
48 #include "magick/cache.h"
49 #include "magick/cache-private.h"
50 #include "magick/cache-view.h"
51 #include "magick/channel.h"
52 #include "magick/client.h"
53 #include "magick/color.h"
54 #include "magick/color-private.h"
55 #include "magick/colormap.h"
56 #include "magick/colorspace.h"
57 #include "magick/colorspace-private.h"
58 #include "magick/composite.h"
59 #include "magick/composite-private.h"
60 #include "magick/compress.h"
61 #include "magick/constitute.h"
62 #include "magick/delegate.h"
63 #include "magick/deprecate.h"
64 #include "magick/display.h"
65 #include "magick/draw.h"
66 #include "magick/enhance.h"
67 #include "magick/exception.h"
68 #include "magick/exception-private.h"
69 #include "magick/gem.h"
70 #include "magick/geometry.h"
71 #include "magick/histogram.h"
72 #include "magick/image-private.h"
73 #include "magick/list.h"
74 #include "magick/magic.h"
75 #include "magick/magick.h"
76 #include "magick/memory_.h"
77 #include "magick/memory-private.h"
78 #include "magick/module.h"
79 #include "magick/monitor.h"
80 #include "magick/monitor-private.h"
81 #include "magick/option.h"
82 #include "magick/paint.h"
83 #include "magick/pixel-accessor.h"
84 #include "magick/pixel-private.h"
85 #include "magick/profile.h"
86 #include "magick/property.h"
87 #include "magick/quantize.h"
88 #include "magick/random_.h"
89 #include "magick/resource_.h"
90 #include "magick/segment.h"
91 #include "magick/semaphore.h"
92 #include "magick/signature-private.h"
93 #include "magick/statistic.h"
94 #include "magick/string_.h"
95 #include "magick/string-private.h"
96 #include "magick/thread-private.h"
97 #include "magick/threshold.h"
98 #include "magick/timer.h"
99 #include "magick/timer-private.h"
100 #include "magick/token.h"
101 #include "magick/token-private.h"
102 #include "magick/utility.h"
103 #include "magick/version.h"
104 #include "magick/xwindow-private.h"
145 if (IsEventLogging() != MagickFalse)
146 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
147 image=(
Image *) AcquireCriticalMemory(
sizeof(*image));
148 (void) memset(image,0,
sizeof(*image));
152 (void) CopyMagickString(image->magick,
"MIFF",MaxTextExtent);
153 image->storage_class=DirectClass;
154 image->depth=MAGICKCORE_QUANTUM_DEPTH;
155 image->colorspace=sRGBColorspace;
156 image->rendering_intent=PerceptualIntent;
157 image->gamma=1.000f/2.200f;
158 image->chromaticity.red_primary.x=0.6400f;
159 image->chromaticity.red_primary.y=0.3300f;
160 image->chromaticity.red_primary.z=0.0300f;
161 image->chromaticity.green_primary.x=0.3000f;
162 image->chromaticity.green_primary.y=0.6000f;
163 image->chromaticity.green_primary.z=0.1000f;
164 image->chromaticity.blue_primary.x=0.1500f;
165 image->chromaticity.blue_primary.y=0.0600f;
166 image->chromaticity.blue_primary.z=0.7900f;
167 image->chromaticity.white_point.x=0.3127f;
168 image->chromaticity.white_point.y=0.3290f;
169 image->chromaticity.white_point.z=0.3583f;
170 image->interlace=NoInterlace;
171 image->ticks_per_second=UndefinedTicksPerSecond;
172 image->compose=OverCompositeOp;
174 InitializeExceptionInfo(&image->exception);
175 (void) QueryColorDatabase(BackgroundColor,&image->background_color,
177 (void) QueryColorDatabase(BorderColor,&image->border_color,&image->exception);
178 (void) QueryColorDatabase(MatteColor,&image->matte_color,&image->exception);
179 (void) QueryColorDatabase(TransparentColor,&image->transparent_color,
181 GetTimerInfo(&image->timer);
182 image->ping=MagickFalse;
183 image->cache=AcquirePixelCache(0);
184 image->blob=CloneBlobInfo((
BlobInfo *) NULL);
185 image->timestamp=GetMagickTime();
186 image->debug=(GetLogEventMask() & (ImageEvent | TransformEvent | CoderEvent))
187 != 0 ? MagickTrue : MagickFalse;
188 image->reference_count=1;
189 image->semaphore=AllocateSemaphoreInfo();
190 image->signature=MagickCoreSignature;
196 SetBlobExempt(image,image_info->file != (FILE *) NULL ? MagickTrue :
198 (void) CopyMagickString(image->filename,image_info->filename,MaxTextExtent);
199 (void) CopyMagickString(image->magick_filename,image_info->filename,
201 (void) CopyMagickString(image->magick,image_info->magick,MaxTextExtent);
202 if (image_info->size != (
char *) NULL)
204 (void) ParseAbsoluteGeometry(image_info->size,&image->extract_info);
205 image->columns=image->extract_info.width;
206 image->rows=image->extract_info.height;
207 image->offset=image->extract_info.x;
208 image->extract_info.x=0;
209 image->extract_info.y=0;
211 if (image_info->extract != (
char *) NULL)
216 (void) memset(&geometry,0,
sizeof(geometry));
217 flags=ParseAbsoluteGeometry(image_info->extract,&geometry);
218 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
220 image->extract_info=geometry;
221 Swap(image->columns,image->extract_info.width);
222 Swap(image->rows,image->extract_info.height);
225 image->compression=image_info->compression;
226 image->quality=image_info->quality;
227 image->endian=image_info->endian;
228 image->interlace=image_info->interlace;
229 image->units=image_info->units;
230 if (image_info->density != (
char *) NULL)
235 flags=ParseGeometry(image_info->density,&geometry_info);
236 if ((flags & RhoValue) != 0)
237 image->x_resolution=geometry_info.rho;
238 image->y_resolution=image->x_resolution;
239 if ((flags & SigmaValue) != 0)
240 image->y_resolution=geometry_info.sigma;
242 if (image_info->page != (
char *) NULL)
247 image->page=image->extract_info;
248 geometry=GetPageGeometry(image_info->page);
249 (void) ParseAbsoluteGeometry(geometry,&image->page);
250 geometry=DestroyString(geometry);
252 if (image_info->depth != 0)
253 image->depth=image_info->depth;
254 image->dither=image_info->dither;
255 image->background_color=image_info->background_color;
256 image->border_color=image_info->border_color;
257 image->matte_color=image_info->matte_color;
258 image->transparent_color=image_info->transparent_color;
259 image->ping=image_info->ping;
260 image->progress_monitor=image_info->progress_monitor;
261 image->client_data=image_info->client_data;
262 if (image_info->cache != (
void *) NULL)
263 ClonePixelCacheMethods(image->cache,image_info->cache);
264 (void) SyncImageSettings(image_info,image);
265 option=GetImageOption(image_info,
"delay");
266 if (option != (
const char *) NULL)
271 flags=ParseGeometry(option,&geometry_info);
272 if ((flags & GreaterValue) != 0)
274 if ((
double) image->delay > floor(geometry_info.rho+0.5))
275 image->delay=(size_t) CastDoubleToLong(floor(
276 geometry_info.rho+0.5));
279 if ((flags & LessValue) != 0)
281 if ((
double) image->delay < floor(geometry_info.rho+0.5))
282 image->ticks_per_second=CastDoubleToLong(floor(
283 geometry_info.sigma+0.5));
286 image->delay=(size_t) CastDoubleToLong(floor(
287 geometry_info.rho+0.5));
288 if ((flags & SigmaValue) != 0)
289 image->ticks_per_second=CastDoubleToLong(floor(
290 geometry_info.sigma+0.5));
292 option=GetImageOption(image_info,
"dispose");
293 if (option != (
const char *) NULL)
294 image->dispose=(DisposeType) ParseCommandOption(MagickDisposeOptions,
317 MagickExport
ImageInfo *AcquireImageInfo(
void)
322 image_info=(
ImageInfo *) AcquireMagickMemory(
sizeof(*image_info));
324 ThrowFatalException(ResourceLimitFatalError,
"MemoryAllocationFailed");
325 GetImageInfo(image_info);
357 MagickExport
void AcquireNextImage(
const ImageInfo *image_info,
Image *image)
362 assert(image != (
Image *) NULL);
363 assert(image->signature == MagickCoreSignature);
364 if (IsEventLogging() != MagickFalse)
365 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
366 image->next=AcquireImage(image_info);
367 if (GetNextImageInList(image) == (
Image *) NULL)
369 (void) CopyMagickString(GetNextImageInList(image)->filename,image->filename,
372 (
void) CopyMagickString(GetNextImageInList(image)->filename,
373 image_info->filename,MaxTextExtent);
374 DestroyBlob(GetNextImageInList(image));
375 image->next->blob=ReferenceBlob(image->blob);
376 image->next->endian=image->endian;
377 image->next->scene=image->scene+1;
378 image->next->previous=image;
413 MagickExport
Image *AppendImages(
const Image *images,
416 #define AppendImageTag "Append/Image"
425 homogeneous_colorspace,
452 assert(images != (
Image *) NULL);
453 assert(images->signature == MagickCoreSignature);
455 assert(exception->signature == MagickCoreSignature);
456 if (IsEventLogging() != MagickFalse)
457 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",images->filename);
460 width=images->columns;
463 homogeneous_colorspace=MagickTrue;
464 next=GetNextImageInList(images);
465 for ( ; next != (
Image *) NULL; next=GetNextImageInList(next))
467 if (next->depth > depth)
469 if (next->colorspace != images->colorspace)
470 homogeneous_colorspace=MagickFalse;
471 if (next->matte != MagickFalse)
474 if (stack != MagickFalse)
476 if (next->columns > width)
481 width+=next->columns;
482 if (next->rows > height)
488 append_image=CloneImage(images,width,height,MagickTrue,exception);
489 if (append_image == (
Image *) NULL)
490 return((
Image *) NULL);
491 if (SetImageStorageClass(append_image,DirectClass) == MagickFalse)
493 InheritException(exception,&append_image->exception);
494 append_image=DestroyImage(append_image);
495 return((
Image *) NULL);
497 if (homogeneous_colorspace == MagickFalse)
498 (void) SetImageColorspace(append_image,sRGBColorspace);
499 append_image->depth=depth;
500 append_image->matte=matte;
501 append_image->page=images->page;
502 (void) SetImageBackgroundColor(append_image);
507 append_view=AcquireAuthenticCacheView(append_image,exception);
508 for (n=0; n < (MagickOffsetType) number_images; n++)
516 SetGeometry(append_image,&geometry);
517 GravityAdjustGeometry(next->columns,next->rows,next->gravity,&geometry);
518 if (stack != MagickFalse)
519 x_offset-=geometry.x;
521 y_offset-=geometry.y;
522 image_view=AcquireVirtualCacheView(next,exception);
523 #if defined(MAGICKCORE_OPENMP_SUPPORT)
524 #pragma omp parallel for schedule(static) shared(status) \
525 magick_number_threads(next,next,next->rows,1)
527 for (y=0; y < (ssize_t) next->rows; y++)
533 *magick_restrict indexes;
539 *magick_restrict append_indexes;
547 if (status == MagickFalse)
549 p=GetCacheViewVirtualPixels(image_view,0,y,next->columns,1,exception);
550 q=QueueCacheViewAuthenticPixels(append_view,x_offset,y+y_offset,
551 next->columns,1,exception);
557 indexes=GetCacheViewVirtualIndexQueue(image_view);
558 append_indexes=GetCacheViewAuthenticIndexQueue(append_view);
559 for (x=0; x < (ssize_t) next->columns; x++)
561 SetPixelRed(q,GetPixelRed(p));
562 SetPixelGreen(q,GetPixelGreen(p));
563 SetPixelBlue(q,GetPixelBlue(p));
564 SetPixelOpacity(q,OpaqueOpacity);
565 if (next->matte != MagickFalse)
566 SetPixelOpacity(q,GetPixelOpacity(p));
567 if ((next->colorspace == CMYKColorspace) &&
568 (append_image->colorspace == CMYKColorspace))
569 SetPixelIndex(append_indexes+x,GetPixelIndex(indexes+x));
573 sync=SyncCacheViewAuthenticPixels(append_view,exception);
574 if (sync == MagickFalse)
577 image_view=DestroyCacheView(image_view);
578 if (stack == MagickFalse)
580 x_offset+=(ssize_t) next->columns;
586 y_offset+=(ssize_t) next->rows;
588 proceed=SetImageProgress(append_image,AppendImageTag,n,number_images);
589 if (proceed == MagickFalse)
591 next=GetNextImageInList(next);
593 append_view=DestroyCacheView(append_view);
594 if (status == MagickFalse)
595 append_image=DestroyImage(append_image);
596 return(append_image);
623 MagickExport ExceptionType CatchImageException(
Image *image)
631 assert(image != (
const Image *) NULL);
632 assert(image->signature == MagickCoreSignature);
633 if (IsEventLogging() != MagickFalse)
634 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
635 exception=AcquireExceptionInfo();
636 GetImageException(image,exception);
637 CatchException(exception);
638 severity=exception->severity;
639 exception=DestroyExceptionInfo(exception);
674 MagickExport MagickBooleanType ClipImage(
Image *image)
676 return(ClipImagePath(image,
"#1",MagickTrue));
679 MagickExport MagickBooleanType ClipImagePath(
Image *image,
const char *pathname,
680 const MagickBooleanType inside)
682 #define ClipImagePathTag "ClipPath/Image"
696 assert(image != (
const Image *) NULL);
697 assert(image->signature == MagickCoreSignature);
698 assert(pathname != NULL);
699 if (IsEventLogging() != MagickFalse)
700 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
701 property=AcquireString(pathname);
702 (void) FormatLocaleString(property,MaxTextExtent,
"8BIM:1999,2998:%s",
704 value=GetImageProperty(image,property);
705 property=DestroyString(property);
706 if (value == (
const char *) NULL)
708 ThrowFileException(&image->exception,OptionError,
"NoClipPathDefined",
712 image_info=AcquireImageInfo();
713 (void) CopyMagickString(image_info->filename,image->filename,MaxTextExtent);
714 (void) ConcatenateMagickString(image_info->filename,pathname,MaxTextExtent);
715 clip_mask=BlobToImage(image_info,value,strlen(value),&image->exception);
716 image_info=DestroyImageInfo(image_info);
717 if (clip_mask == (
Image *) NULL)
719 if (clip_mask->storage_class == PseudoClass)
721 (void) SyncImage(clip_mask);
722 if (SetImageStorageClass(clip_mask,DirectClass) == MagickFalse)
725 if (inside == MagickFalse)
726 (void) NegateImage(clip_mask,MagickFalse);
727 (void) FormatLocaleString(clip_mask->magick_filename,MaxTextExtent,
728 "8BIM:1999,2998:%s\nPS",pathname);
729 (void) SetImageClipMask(image,clip_mask);
730 clip_mask=DestroyImage(clip_mask);
773 MagickExport
Image *CloneImage(
const Image *image,
const size_t columns,
774 const size_t rows,
const MagickBooleanType detach,
ExceptionInfo *exception)
789 assert(image != (
const Image *) NULL);
790 assert(image->signature == MagickCoreSignature);
792 assert(exception->signature == MagickCoreSignature);
793 if (IsEventLogging() != MagickFalse)
794 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
795 if ((image->columns == 0) || (image->rows == 0))
797 (void) ThrowMagickException(exception,GetMagickModule(),CorruptImageError,
798 "NegativeOrZeroImageSize",
"`%s'",image->filename);
799 return((
Image *) NULL);
801 clone_image=(
Image *) AcquireCriticalMemory(
sizeof(*clone_image));
802 (void) memset(clone_image,0,
sizeof(*clone_image));
803 clone_image->signature=MagickCoreSignature;
804 clone_image->storage_class=image->storage_class;
805 clone_image->channels=image->channels;
806 clone_image->colorspace=image->colorspace;
807 clone_image->matte=image->matte;
808 clone_image->columns=image->columns;
809 clone_image->rows=image->rows;
810 clone_image->dither=image->dither;
811 (void) CloneImageProfiles(clone_image,image);
812 (void) CloneImageProperties(clone_image,image);
813 (void) CloneImageArtifacts(clone_image,image);
814 GetTimerInfo(&clone_image->timer);
815 InitializeExceptionInfo(&clone_image->exception);
816 InheritException(&clone_image->exception,&image->exception);
817 if (image->ascii85 != (
void *) NULL)
818 Ascii85Initialize(clone_image);
819 clone_image->extent=image->extent;
820 clone_image->magick_columns=image->magick_columns;
821 clone_image->magick_rows=image->magick_rows;
822 clone_image->type=image->type;
823 (void) CopyMagickString(clone_image->magick_filename,image->magick_filename,
825 (void) CopyMagickString(clone_image->magick,image->magick,MaxTextExtent);
826 (void) CopyMagickString(clone_image->filename,image->filename,MaxTextExtent);
827 clone_image->progress_monitor=image->progress_monitor;
828 clone_image->client_data=image->client_data;
829 clone_image->reference_count=1;
830 clone_image->next=image->next;
831 clone_image->previous=image->previous;
832 clone_image->list=NewImageList();
833 clone_image->clip_mask=NewImageList();
834 clone_image->mask=NewImageList();
835 if (detach == MagickFalse)
836 clone_image->blob=ReferenceBlob(image->blob);
839 clone_image->next=NewImageList();
840 clone_image->previous=NewImageList();
841 clone_image->blob=CloneBlobInfo((
BlobInfo *) NULL);
843 clone_image->ping=image->ping;
844 clone_image->debug=image->debug;
845 clone_image->semaphore=AllocateSemaphoreInfo();
851 clone_image->colors=image->colors;
852 length=(size_t) image->colors;
853 clone_image->colormap=(
PixelPacket *) AcquireQuantumMemory(length+1,
854 sizeof(*clone_image->colormap));
857 clone_image=DestroyImage(clone_image);
858 ThrowImageException(ResourceLimitError,
"MemoryAllocationFailed");
860 (void) memcpy(clone_image->colormap,image->colormap,length*
861 sizeof(*clone_image->colormap));
863 if ((columns == 0) || (rows == 0))
865 if (image->montage != (
char *) NULL)
866 (
void) CloneString(&clone_image->montage,image->montage);
867 if (image->directory != (
char *) NULL)
868 (void) CloneString(&clone_image->directory,image->directory);
869 if (image->clip_mask != (
Image *) NULL)
870 clone_image->clip_mask=CloneImage(image->clip_mask,0,0,MagickTrue,
872 if (image->mask != (
Image *) NULL)
873 clone_image->mask=CloneImage(image->mask,0,0,MagickTrue,exception);
874 clone_image->cache=ReferencePixelCache(image->cache);
877 if ((columns == image->columns) && (rows == image->rows))
879 if (image->clip_mask != (
Image *) NULL)
880 clone_image->clip_mask=CloneImage(image->clip_mask,0,0,MagickTrue,
882 if (image->mask != (
Image *) NULL)
883 clone_image->mask=CloneImage(image->mask,0,0,MagickTrue,exception);
887 if (image->columns != 0)
888 scale_x=(double) columns/(
double) image->columns;
889 if (image->rows != 0)
890 scale_y=(double) rows/(
double) image->rows;
891 clone_image->page.width=(size_t) CastDoubleToLong(floor(scale_x*
892 image->page.width+0.5));
893 clone_image->page.height=(size_t) CastDoubleToLong(floor(scale_y*
894 image->page.height+0.5));
895 if (MagickAbsoluteValue(scale_x-scale_y) < 2.0)
896 scale_x=scale_y=MagickMin(scale_x,scale_y);
897 clone_image->page.x=CastDoubleToLong(ceil(scale_x*image->page.x-0.5));
898 clone_image->tile_offset.x=CastDoubleToLong(ceil(scale_x*
899 image->tile_offset.x-0.5));
900 clone_image->page.y=CastDoubleToLong(ceil(scale_y*image->page.y-0.5));
901 clone_image->tile_offset.y=CastDoubleToLong(ceil(scale_y*
902 image->tile_offset.y-0.5));
903 clone_image->cache=ClonePixelCache(image->cache);
904 if (SetImageExtent(clone_image,columns,rows) == MagickFalse)
906 InheritException(exception,&clone_image->exception);
907 clone_image=DestroyImage(clone_image);
941 clone_info=AcquireImageInfo();
944 clone_info->compression=image_info->compression;
945 clone_info->temporary=image_info->temporary;
946 clone_info->adjoin=image_info->adjoin;
947 clone_info->antialias=image_info->antialias;
948 clone_info->scene=image_info->scene;
949 clone_info->number_scenes=image_info->number_scenes;
950 clone_info->depth=image_info->depth;
951 if (image_info->size != (
char *) NULL)
952 (void) CloneString(&clone_info->size,image_info->size);
953 if (image_info->extract != (
char *) NULL)
954 (
void) CloneString(&clone_info->extract,image_info->extract);
955 if (image_info->scenes != (
char *) NULL)
956 (void) CloneString(&clone_info->scenes,image_info->scenes);
957 if (image_info->page != (
char *) NULL)
958 (
void) CloneString(&clone_info->page,image_info->page);
959 clone_info->interlace=image_info->interlace;
960 clone_info->endian=image_info->endian;
961 clone_info->units=image_info->units;
962 clone_info->quality=image_info->quality;
963 if (image_info->sampling_factor != (
char *) NULL)
964 (void) CloneString(&clone_info->sampling_factor,
965 image_info->sampling_factor);
966 if (image_info->server_name != (
char *) NULL)
967 (
void) CloneString(&clone_info->server_name,image_info->server_name);
968 if (image_info->font != (
char *) NULL)
969 (void) CloneString(&clone_info->font,image_info->font);
970 if (image_info->texture != (
char *) NULL)
971 (
void) CloneString(&clone_info->texture,image_info->texture);
972 if (image_info->density != (
char *) NULL)
973 (void) CloneString(&clone_info->density,image_info->density);
974 clone_info->pointsize=image_info->pointsize;
975 clone_info->fuzz=image_info->fuzz;
976 clone_info->pen=image_info->pen;
977 clone_info->background_color=image_info->background_color;
978 clone_info->border_color=image_info->border_color;
979 clone_info->matte_color=image_info->matte_color;
980 clone_info->transparent_color=image_info->transparent_color;
981 clone_info->dither=image_info->dither;
982 clone_info->monochrome=image_info->monochrome;
983 clone_info->colors=image_info->colors;
984 clone_info->colorspace=image_info->colorspace;
985 clone_info->type=image_info->type;
986 clone_info->orientation=image_info->orientation;
987 clone_info->preview_type=image_info->preview_type;
988 clone_info->group=image_info->group;
989 clone_info->ping=image_info->ping;
990 clone_info->verbose=image_info->verbose;
991 if (image_info->view != (
char *) NULL)
992 (
void) CloneString(&clone_info->view,image_info->view);
993 if (image_info->authenticate != (
char *) NULL)
994 (void) CloneString(&clone_info->authenticate,image_info->authenticate);
995 (void) CloneImageOptions(clone_info,image_info);
996 clone_info->progress_monitor=image_info->progress_monitor;
997 clone_info->client_data=image_info->client_data;
998 clone_info->cache=image_info->cache;
999 if (image_info->cache != (
void *) NULL)
1000 clone_info->cache=ReferencePixelCache(image_info->cache);
1001 if (image_info->profile != (
void *) NULL)
1002 clone_info->profile=(
void *) CloneStringInfo((
StringInfo *)
1003 image_info->profile);
1004 SetImageInfoFile(clone_info,image_info->file);
1005 SetImageInfoBlob(clone_info,image_info->blob,image_info->length);
1006 clone_info->stream=image_info->stream;
1007 clone_info->virtual_pixel_method=image_info->virtual_pixel_method;
1008 (void) CopyMagickString(clone_info->magick,image_info->magick,MaxTextExtent);
1009 (void) CopyMagickString(clone_info->unique,image_info->unique,MaxTextExtent);
1010 (void) CopyMagickString(clone_info->zero,image_info->zero,MaxTextExtent);
1011 (void) CopyMagickString(clone_info->filename,image_info->filename,
1013 clone_info->subimage=image_info->scene;
1014 clone_info->subrange=image_info->number_scenes;
1015 clone_info->channel=image_info->channel;
1016 clone_info->debug=image_info->debug;
1017 clone_info->signature=image_info->signature;
1054 MagickExport MagickBooleanType CopyImagePixels(
Image *image,
1058 #define CopyImageTag "Copy/Image"
1073 assert(image != (
Image *) NULL);
1074 assert(source_image != (
Image *) NULL);
1077 if (IsEventLogging() != MagickFalse)
1078 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
1079 if ((offset->x < 0) || (offset->y < 0) ||
1080 ((ssize_t) (offset->x+geometry->width) > (ssize_t) image->columns) ||
1081 ((ssize_t) (offset->y+geometry->height) > (ssize_t) image->rows))
1082 ThrowBinaryException(OptionError,
"GeometryDoesNotContainImage",
1084 if (SetImageStorageClass(image,DirectClass) == MagickFalse)
1085 return(MagickFalse);
1091 source_view=AcquireVirtualCacheView(source_image,exception);
1092 image_view=AcquireAuthenticCacheView(image,exception);
1093 #if defined(MAGICKCORE_OPENMP_SUPPORT)
1094 #pragma omp parallel for schedule(static) shared(progress,status) \
1095 magick_number_threads(source_image,image,geometry->height,1)
1097 for (y=0; y < (ssize_t) geometry->height; y++)
1100 *magick_restrict source_indexes;
1106 *magick_restrict indexes;
1114 if (status == MagickFalse)
1116 p=GetCacheViewVirtualPixels(source_view,geometry->x,y+geometry->y,
1117 geometry->width,1,exception);
1118 q=GetCacheViewAuthenticPixels(image_view,offset->x,y+offset->y,
1119 geometry->width,1,exception);
1125 source_indexes=GetCacheViewVirtualIndexQueue(source_view);
1126 indexes=GetCacheViewAuthenticIndexQueue(image_view);
1127 for (x=0; x < (ssize_t) geometry->width; x++)
1130 if (image->colorspace == CMYKColorspace)
1131 indexes[x]=source_indexes[x];
1135 if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
1137 if (image->progress_monitor != (MagickProgressMonitor) NULL)
1142 #if defined(MAGICKCORE_OPENMP_SUPPORT)
1146 proceed=SetImageProgress(image,CopyImageTag,progress,image->rows);
1147 if (proceed == MagickFalse)
1151 image_view=DestroyCacheView(image_view);
1152 source_view=DestroyCacheView(source_view);
1179 MagickExport
Image *DestroyImage(
Image *image)
1187 assert(image != (
Image *) NULL);
1188 assert(image->signature == MagickCoreSignature);
1189 if (IsEventLogging() != MagickFalse)
1190 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
1191 destroy=MagickFalse;
1192 LockSemaphoreInfo(image->semaphore);
1193 image->reference_count--;
1194 if (image->reference_count == 0)
1196 UnlockSemaphoreInfo(image->semaphore);
1197 if (destroy == MagickFalse)
1198 return((
Image *) NULL);
1202 DestroyImagePixels(image);
1203 if (image->clip_mask != (
Image *) NULL)
1204 image->clip_mask=DestroyImage(image->clip_mask);
1205 if (image->mask != (
Image *) NULL)
1206 image->mask=DestroyImage(image->mask);
1207 if (image->montage != (
char *) NULL)
1208 image->montage=DestroyString(image->montage);
1209 if (image->directory != (
char *) NULL)
1210 image->directory=DestroyString(image->directory);
1212 image->colormap=(
PixelPacket *) RelinquishMagickMemory(image->colormap);
1213 if (image->geometry != (
char *) NULL)
1214 image->geometry=DestroyString(image->geometry);
1215 DestroyImageProfiles(image);
1216 DestroyImageProperties(image);
1217 DestroyImageArtifacts(image);
1219 image->ascii85=(
Ascii85Info *) RelinquishMagickMemory(image->ascii85);
1221 (void) ClearExceptionInfo(&image->exception,MagickTrue);
1223 DestroySemaphoreInfo(&image->semaphore);
1224 image->signature=(~MagickCoreSignature);
1225 image=(
Image *) RelinquishMagickMemory(image);
1254 assert(image_info != (
ImageInfo *) NULL);
1255 assert(image_info->signature == MagickCoreSignature);
1256 if (IsEventLogging() != MagickFalse)
1257 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
1258 image_info->filename);
1259 if (image_info->size != (
char *) NULL)
1260 image_info->size=DestroyString(image_info->size);
1261 if (image_info->extract != (
char *) NULL)
1262 image_info->extract=DestroyString(image_info->extract);
1263 if (image_info->scenes != (
char *) NULL)
1264 image_info->scenes=DestroyString(image_info->scenes);
1265 if (image_info->page != (
char *) NULL)
1266 image_info->page=DestroyString(image_info->page);
1267 if (image_info->sampling_factor != (
char *) NULL)
1268 image_info->sampling_factor=DestroyString(
1269 image_info->sampling_factor);
1270 if (image_info->server_name != (
char *) NULL)
1271 image_info->server_name=DestroyString(
1272 image_info->server_name);
1273 if (image_info->font != (
char *) NULL)
1274 image_info->font=DestroyString(image_info->font);
1275 if (image_info->texture != (
char *) NULL)
1276 image_info->texture=DestroyString(image_info->texture);
1277 if (image_info->density != (
char *) NULL)
1278 image_info->density=DestroyString(image_info->density);
1279 if (image_info->view != (
char *) NULL)
1280 image_info->view=DestroyString(image_info->view);
1281 if (image_info->authenticate != (
char *) NULL)
1282 image_info->authenticate=DestroyString(
1283 image_info->authenticate);
1284 DestroyImageOptions(image_info);
1285 if (image_info->cache != (
void *) NULL)
1286 image_info->cache=DestroyPixelCache(image_info->cache);
1287 if (image_info->profile != (
StringInfo *) NULL)
1288 image_info->profile=(
void *) DestroyStringInfo((
StringInfo *)
1289 image_info->profile);
1290 image_info->signature=(~MagickCoreSignature);
1291 image_info=(
ImageInfo *) RelinquishMagickMemory(image_info);
1319 MagickExport
void DisassociateImageStream(
Image *image)
1321 assert(image != (
Image *) NULL);
1322 assert(image->signature == MagickCoreSignature);
1323 if (IsEventLogging() != MagickFalse)
1324 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
1325 DisassociateBlob(image);
1350 MagickExport
Image *GetImageClipMask(
const Image *image,
1353 assert(image != (
const Image *) NULL);
1354 assert(image->signature == MagickCoreSignature);
1355 if (IsEventLogging() != MagickFalse)
1356 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
1357 if (image->clip_mask == (
Image *) NULL)
1358 return((
Image *) NULL);
1359 return(CloneImage(image->clip_mask,0,0,MagickTrue,exception));
1392 assert(image != (
Image *) NULL);
1393 assert(image->signature == MagickCoreSignature);
1395 assert(exception->signature == MagickCoreSignature);
1396 if (IsEventLogging() != MagickFalse)
1397 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
1398 for (next=image; next != (
Image *) NULL; next=GetNextImageInList(next))
1400 if (next->exception.severity == UndefinedException)
1402 if (next->exception.severity > exception->severity)
1403 InheritException(exception,&next->exception);
1404 next->exception.severity=UndefinedException;
1430 MagickExport
void GetImageInfo(
ImageInfo *image_info)
1441 assert(image_info != (
ImageInfo *) NULL);
1442 if (IsEventLogging() != MagickFalse)
1443 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
1444 (void) memset(image_info,0,
sizeof(*image_info));
1445 image_info->adjoin=MagickTrue;
1446 image_info->interlace=NoInterlace;
1447 image_info->channel=DefaultChannels;
1448 image_info->quality=UndefinedCompressionQuality;
1449 image_info->antialias=MagickTrue;
1450 image_info->dither=MagickTrue;
1451 synchronize=GetEnvironmentValue(
"MAGICK_SYNCHRONIZE");
1452 if (synchronize != (
const char *) NULL)
1454 image_info->synchronize=IsStringTrue(synchronize);
1455 synchronize=DestroyString(synchronize);
1457 exception=AcquireExceptionInfo();
1458 (void) QueryColorDatabase(BackgroundColor,&image_info->background_color,
1460 (void) QueryColorDatabase(BorderColor,&image_info->border_color,exception);
1461 (void) QueryColorDatabase(MatteColor,&image_info->matte_color,exception);
1462 (void) QueryColorDatabase(TransparentColor,&image_info->transparent_color,
1464 exception=DestroyExceptionInfo(exception);
1465 image_info->debug=(GetLogEventMask() & ImageEvent) != 0 ? MagickTrue :
1467 image_info->signature=MagickCoreSignature;
1492 MagickExport FILE *GetImageInfoFile(
const ImageInfo *image_info)
1494 return(image_info->file);
1521 assert(image != (
const Image *) NULL);
1522 assert(image->signature == MagickCoreSignature);
1523 if (IsEventLogging() != MagickFalse)
1524 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
1525 if (image->mask == (
Image *) NULL)
1526 return((
Image *) NULL);
1527 return(CloneImage(image->mask,0,0,MagickTrue,exception));
1553 MagickExport
size_t GetImageChannels(
Image *image)
1555 assert(image != (
Image *) NULL);
1556 assert(image->signature == MagickCoreSignature);
1557 if (IsEventLogging() != MagickFalse)
1558 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
1559 return(image->channels);
1584 MagickExport ssize_t GetImageReferenceCount(
Image *image)
1589 assert(image != (
Image *) NULL);
1590 assert(image->signature == MagickCoreSignature);
1591 if (IsEventLogging() != MagickFalse)
1592 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
1593 LockSemaphoreInfo(image->semaphore);
1594 reference_count=image->reference_count;
1595 UnlockSemaphoreInfo(image->semaphore);
1596 return(reference_count);
1623 MagickExport VirtualPixelMethod GetImageVirtualPixelMethod(
const Image *image)
1625 assert(image != (
Image *) NULL);
1626 assert(image->signature == MagickCoreSignature);
1627 if (IsEventLogging() != MagickFalse)
1628 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
1629 return(GetPixelCacheVirtualMethod(image));
1665 MagickExport
size_t InterpretImageFilename(
const ImageInfo *image_info,
1666 Image *image,
const char *format,
int value,
char *filename)
1684 canonical=MagickFalse;
1686 (void) CopyMagickString(filename,format,MaxTextExtent);
1687 if (IsStringTrue(GetImageOption(image_info,
"filename:literal")) != MagickFalse)
1688 return(strlen(filename));
1689 for (p=strchr(format,
'%'); p != (
char *) NULL; p=strchr(p+1,
'%'))
1699 field_width=(ssize_t) strtol(q,&q,10);
1709 (void) FormatLocaleString(filename+(p-format-offset),(size_t)
1710 (MaxTextExtent-(p-format-offset)),p,value);
1711 offset+=(4-field_width);
1713 (void) ConcatenateMagickString(filename,q,MaxTextExtent);
1714 canonical=MagickTrue;
1723 pattern[MaxTextExtent];
1740 if (strchr(p,
']') == (
char *) NULL)
1744 for (i=0; (i < (MaxTextExtent-1L)) && (*r !=
'\0'); i++)
1755 if (LocaleNCompare(pattern,
"filename:",9) != 0)
1757 value=(
const char *) NULL;
1758 if (image != (
Image *) NULL)
1759 value=GetImageProperty(image,pattern);
1760 if ((value == (
const char *) NULL) &&
1761 (image != (
Image *) NULL))
1762 value=GetImageArtifact(image,pattern);
1763 if ((value == (
const char *) NULL) &&
1765 value=GetImageOption(image_info,pattern);
1766 if (value == (
const char *) NULL)
1771 (void) CopyMagickString(filename+(p-format-offset),value,(size_t)
1772 (MaxTextExtent-(p-format-offset)));
1773 offset+=strlen(pattern)-strlen(value)+3;
1775 (void) ConcatenateMagickString(filename,r+1,MaxTextExtent);
1776 canonical=MagickTrue;
1786 if (canonical == MagickFalse)
1787 (void) CopyMagickString(filename,format,MaxTextExtent);
1789 for (q=filename; *q !=
'\0'; q++)
1790 if ((*q ==
'%') && (*(q+1) ==
'%'))
1791 (
void) CopyMagickString(q,q+1,(
size_t) (MaxTextExtent-(q-filename)));
1792 return(strlen(filename));
1822 MagickExport MagickBooleanType IsHighDynamicRangeImage(
const Image *image,
1825 #if !defined(MAGICKCORE_HDRI_SUPPORT)
1828 return(MagickFalse);
1842 assert(image != (
Image *) NULL);
1843 assert(image->signature == MagickCoreSignature);
1844 if (IsEventLogging() != MagickFalse)
1845 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
1847 GetMagickPixelPacket(image,&zero);
1848 image_view=AcquireVirtualCacheView(image,exception);
1849 #if defined(MAGICKCORE_OPENMP_SUPPORT)
1850 #pragma omp parallel for schedule(static) shared(status) \
1851 magick_number_threads(image,image,image->rows,1)
1853 for (y=0; y < (ssize_t) image->rows; y++)
1867 if (status == MagickFalse)
1869 p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
1875 indexes=GetCacheViewVirtualIndexQueue(image_view);
1877 for (x=0; x < (ssize_t) image->columns; x++)
1879 SetMagickPixelPacket(image,p,indexes+x,&pixel);
1880 if ((pixel.red < 0.0) || (pixel.red > QuantumRange) ||
1881 (pixel.red != (QuantumAny) pixel.red))
1883 if ((pixel.green < 0.0) || (pixel.green > QuantumRange) ||
1884 (pixel.green != (QuantumAny) pixel.green))
1886 if ((pixel.blue < 0.0) || (pixel.blue > QuantumRange) ||
1887 (pixel.blue != (QuantumAny) pixel.blue))
1889 if (pixel.matte != MagickFalse)
1891 if ((pixel.opacity < 0.0) || (pixel.opacity > QuantumRange) ||
1892 (pixel.opacity != (QuantumAny) pixel.opacity))
1895 if (pixel.colorspace == CMYKColorspace)
1897 if ((pixel.index < 0.0) || (pixel.index > QuantumRange) ||
1898 (pixel.index != (QuantumAny) pixel.index))
1903 if (x < (ssize_t) image->columns)
1906 image_view=DestroyCacheView(image_view);
1907 return(status != MagickFalse ? MagickFalse : MagickTrue);
1934 MagickExport MagickBooleanType IsImageObject(
const Image *image)
1939 assert(image != (
Image *) NULL);
1940 if (IsEventLogging() != MagickFalse)
1941 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
1942 for (p=image; p != (
Image *) NULL; p=GetNextImageInList(p))
1943 if (p->signature != MagickCoreSignature)
1944 return(MagickFalse);
1971 MagickExport MagickBooleanType IsTaintImage(
const Image *image)
1974 magick[MaxTextExtent],
1975 filename[MaxTextExtent];
1980 assert(image != (
Image *) NULL);
1981 assert(image->signature == MagickCoreSignature);
1982 if (IsEventLogging() != MagickFalse)
1983 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
1984 (void) CopyMagickString(magick,image->magick,MaxTextExtent);
1985 (void) CopyMagickString(filename,image->filename,MaxTextExtent);
1986 for (p=image; p != (
Image *) NULL; p=GetNextImageInList(p))
1988 if (p->taint != MagickFalse)
1990 if (LocaleCompare(p->magick,magick) != 0)
1992 if (LocaleCompare(p->filename,filename) != 0)
1995 return(MagickFalse);
2024 MagickExport MagickBooleanType ModifyImage(
Image **image,
2030 assert(image != (
Image **) NULL);
2031 assert(*image != (
Image *) NULL);
2032 assert((*image)->signature == MagickCoreSignature);
2033 if (IsEventLogging() != MagickFalse)
2034 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",(*image)->filename);
2035 if (GetImageReferenceCount(*image) <= 1)
2037 clone_image=CloneImage(*image,0,0,MagickTrue,exception);
2038 LockSemaphoreInfo((*image)->semaphore);
2039 (*image)->reference_count--;
2040 UnlockSemaphoreInfo((*image)->semaphore);
2093 assert(image_info != (
const ImageInfo *) NULL);
2094 assert(image_info->signature == MagickCoreSignature);
2096 if (IsEventLogging() != MagickFalse)
2097 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
2098 image=AcquireImage(image_info);
2099 image->columns=width;
2101 image->colorspace=background->colorspace;
2102 image->matte=background->matte;
2103 image->fuzz=background->fuzz;
2104 image->depth=background->depth;
2106 exception=(&image->exception);
2107 image_view=AcquireAuthenticCacheView(image,exception);
2108 #if defined(MAGICKCORE_OPENMP_SUPPORT)
2109 #pragma omp parallel for schedule(static) shared(status) \
2110 magick_number_threads(image,image,image->rows,1)
2112 for (y=0; y < (ssize_t) image->rows; y++)
2115 *magick_restrict indexes;
2123 if (status == MagickFalse)
2125 q=QueueCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
2131 indexes=GetCacheViewAuthenticIndexQueue(image_view);
2132 for (x=0; x < (ssize_t) image->columns; x++)
2134 SetPixelPacket(image,background,q,indexes+x);
2137 if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2140 image_view=DestroyCacheView(image_view);
2141 if (status == MagickFalse)
2142 image=DestroyImage(image);
2169 MagickExport
Image *ReferenceImage(
Image *image)
2171 assert(image != (
Image *) NULL);
2172 assert(image->signature == MagickCoreSignature);
2173 if (IsEventLogging() != MagickFalse)
2174 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
2175 LockSemaphoreInfo(image->semaphore);
2176 image->reference_count++;
2177 UnlockSemaphoreInfo(image->semaphore);
2205 MagickExport MagickBooleanType ResetImagePage(
Image *image,
const char *page)
2213 assert(image != (
Image *) NULL);
2214 assert(image->signature == MagickCoreSignature);
2215 if (IsEventLogging() != MagickFalse)
2216 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
2217 flags=ParseAbsoluteGeometry(page,&geometry);
2218 if ((flags & WidthValue) != 0)
2220 if ((flags & HeightValue) == 0)
2221 geometry.height=geometry.width;
2222 image->page.width=geometry.width;
2223 image->page.height=geometry.height;
2225 if ((flags & AspectValue) != 0)
2227 if ((flags & XValue) != 0)
2228 image->page.x+=geometry.x;
2229 if ((flags & YValue) != 0)
2230 image->page.y+=geometry.y;
2234 if ((flags & XValue) != 0)
2236 image->page.x=geometry.x;
2237 if ((image->page.width == 0) && (geometry.x > 0))
2238 image->page.width=image->columns+geometry.x;
2240 if ((flags & YValue) != 0)
2242 image->page.y=geometry.y;
2243 if ((image->page.height == 0) && (geometry.y > 0))
2244 image->page.height=image->rows+geometry.y;
2276 MagickExport MagickBooleanType ResetImagePixels(
Image *image,
2294 assert(image != (
Image *) NULL);
2295 assert(image->signature == MagickCoreSignature);
2296 if (IsEventLogging() != MagickFalse)
2297 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
2298 pixels=AcquirePixelCachePixels(image,&length,exception);
2299 if (pixels != (
void *) NULL)
2304 (void) memset((
void *) pixels,0,(size_t) length);
2311 image_view=AcquireAuthenticCacheView(image,exception);
2312 #if defined(MAGICKCORE_OPENMP_SUPPORT)
2313 #pragma omp parallel for schedule(static) shared(status) \
2314 magick_number_threads(image,image,image->rows,1)
2316 for (y=0; y < (ssize_t) image->rows; y++)
2319 *magick_restrict indexes;
2327 if (status == MagickFalse)
2329 q=QueueCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
2335 indexes=GetCacheViewAuthenticIndexQueue(image_view);
2336 for (x=0; x < (ssize_t) image->columns; x++)
2339 if ((image->storage_class == PseudoClass) ||
2340 (image->colorspace == CMYKColorspace))
2344 if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2347 image_view=DestroyCacheView(image_view);
2375 MagickExport MagickBooleanType SetImageBackgroundColor(
Image *image)
2398 assert(image != (
Image *) NULL);
2399 assert(image->signature == MagickCoreSignature);
2400 if (IsEventLogging() != MagickFalse)
2401 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
2402 if (SetImageStorageClass(image,DirectClass) == MagickFalse)
2403 return(MagickFalse);
2404 if ((IsPixelGray(&image->background_color) == MagickFalse) &&
2405 (IsGrayColorspace(image->colorspace) != MagickFalse))
2406 (void) TransformImageColorspace(image,RGBColorspace);
2407 if ((image->background_color.opacity != OpaqueOpacity) &&
2408 (image->matte == MagickFalse))
2409 (void) SetImageAlphaChannel(image,OpaqueAlphaChannel);
2410 GetMagickPixelPacket(image,&background);
2411 SetMagickPixelPacket(image,&image->background_color,(
const IndexPacket *)
2413 if (image->colorspace == CMYKColorspace)
2414 ConvertRGBToCMYK(&background);
2416 pixel.opacity=OpaqueOpacity;
2417 SetPixelPacket(image,&background,&pixel,&index);
2422 exception=(&image->exception);
2423 image_view=AcquireAuthenticCacheView(image,exception);
2424 for (y=0; y < (ssize_t) image->rows; y++)
2432 if (status == MagickFalse)
2434 q=QueueCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
2440 for (x=0; x < (ssize_t) image->columns; x++)
2442 if (image->colorspace == CMYKColorspace)
2445 *magick_restrict indexes;
2447 indexes=GetCacheViewAuthenticIndexQueue(image_view);
2448 for (x=0; x < (ssize_t) image->columns; x++)
2449 SetPixelIndex(indexes+x,index);
2451 if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2454 image_view=DestroyCacheView(image_view);
2483 MagickExport MagickBooleanType SetImageChannels(
Image *image,
2484 const size_t channels)
2486 image->channels=channels;
2515 MagickExport MagickBooleanType SetImageColor(
Image *image,
2530 assert(image != (
Image *) NULL);
2531 assert(image->signature == MagickCoreSignature);
2533 if (IsEventLogging() != MagickFalse)
2534 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
2535 image->colorspace=color->colorspace;
2536 image->matte=color->matte;
2537 image->fuzz=color->fuzz;
2538 image->depth=color->depth;
2540 exception=(&image->exception);
2541 image_view=AcquireAuthenticCacheView(image,exception);
2542 #if defined(MAGICKCORE_OPENMP_SUPPORT)
2543 #pragma omp parallel for schedule(static) shared(status) \
2544 magick_number_threads(image,image,image->rows,1)
2546 for (y=0; y < (ssize_t) image->rows; y++)
2549 *magick_restrict indexes;
2557 if (status == MagickFalse)
2559 q=QueueCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
2565 indexes=GetCacheViewAuthenticIndexQueue(image_view);
2566 for (x=0; x < (ssize_t) image->columns; x++)
2568 SetPixelPacket(image,color,q,
2569 indexes == (IndexPacket *) NULL ? NULL : indexes+x);
2572 if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2575 image_view=DestroyCacheView(image_view);
2605 MagickExport MagickBooleanType SetImageStorageClass(
Image *image,
2606 const ClassType storage_class)
2608 assert(image != (
Image *) NULL);
2609 assert(image->signature == MagickCoreSignature);
2610 if (IsEventLogging() != MagickFalse)
2611 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
2612 image->storage_class=storage_class;
2613 return(SyncImagePixelCache(image,&image->exception));
2643 MagickExport MagickBooleanType SetImageClipMask(
Image *image,
2644 const Image *clip_mask)
2646 assert(image != (
Image *) NULL);
2647 assert(image->signature == MagickCoreSignature);
2648 if (IsEventLogging() != MagickFalse)
2649 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
2650 if (clip_mask != (
const Image *) NULL)
2651 if ((clip_mask->columns != image->columns) ||
2652 (clip_mask->rows != image->rows))
2653 ThrowBinaryImageException(ImageError,
"ImageSizeDiffers",image->filename);
2654 if (image->clip_mask != (
Image *) NULL)
2655 image->clip_mask=DestroyImage(image->clip_mask);
2656 image->clip_mask=NewImageList();
2657 if (clip_mask == (
Image *) NULL)
2659 if (SetImageStorageClass(image,DirectClass) == MagickFalse)
2660 return(MagickFalse);
2661 image->clip_mask=CloneImage(clip_mask,0,0,MagickTrue,&image->exception);
2662 if (image->clip_mask == (
Image *) NULL)
2663 return(MagickFalse);
2694 MagickExport MagickBooleanType SetImageExtent(
Image *image,
const size_t columns,
2697 if ((columns == 0) || (rows == 0))
2698 ThrowBinaryImageException(ImageError,
"NegativeOrZeroImageSize",
2700 image->columns=columns;
2702 if (image->depth == 0)
2705 (void) ThrowMagickException(&image->exception,GetMagickModule(),
2706 ImageError,
"ImageDepthNotSupported",
"`%s'",image->filename);
2708 if (image->depth > (8*
sizeof(MagickSizeType)))
2710 image->depth=8*
sizeof(MagickSizeType);
2711 (void) ThrowMagickException(&image->exception,GetMagickModule(),
2712 ImageError,
"ImageDepthNotSupported",
"`%s'",image->filename);
2714 return(SyncImagePixelCache(image,&image->exception));
2751 MagickExport MagickBooleanType SetImageInfo(
ImageInfo *image_info,
2755 extension[MaxTextExtent],
2756 filename[MaxTextExtent],
2757 magic[MaxTextExtent],
2759 subimage[MaxTextExtent];
2783 magick[2*MaxTextExtent];
2788 assert(image_info != (
ImageInfo *) NULL);
2789 assert(image_info->signature == MagickCoreSignature);
2790 if (IsEventLogging() != MagickFalse)
2791 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
2792 image_info->filename);
2794 GetPathComponent(image_info->filename,SubimagePath,subimage);
2795 if (*subimage !=
'\0')
2800 if (IsSceneGeometry(subimage,MagickFalse) == MagickFalse)
2802 if (IsGeometry(subimage) != MagickFalse)
2803 (void) CloneString(&image_info->extract,subimage);
2811 (void) CloneString(&image_info->scenes,subimage);
2812 image_info->scene=StringToUnsignedLong(image_info->scenes);
2813 image_info->number_scenes=image_info->scene;
2814 p=image_info->scenes;
2815 for (q=(
char *) image_info->scenes; *q !=
'\0'; p++)
2817 while ((isspace((
int) ((
unsigned char) *p)) != 0) || (*p ==
','))
2819 first=(size_t) strtol(p,&q,10);
2821 while (isspace((
int) ((
unsigned char) *q)) != 0)
2824 last=(size_t) strtol(q+1,&q,10);
2827 if (first < image_info->scene)
2828 image_info->scene=first;
2829 if (last > image_info->number_scenes)
2830 image_info->number_scenes=last;
2833 image_info->number_scenes-=image_info->scene-1;
2834 image_info->subimage=image_info->scene;
2835 image_info->subrange=image_info->number_scenes;
2839 if (*image_info->magick ==
'\0')
2840 GetPathComponent(image_info->filename,ExtensionPath,extension);
2841 if (*extension !=
'\0')
2844 path[MaxTextExtent];
2849 GetPathComponent(image_info->filename,BasePathSansCompressExtension,path);
2850 GetPathComponent(path,ExtensionPath,extension);
2852 image_info->affirm=MagickFalse;
2853 sans_exception=AcquireExceptionInfo();
2854 if ((*extension !=
'\0') && (IsGlob(extension) == MagickFalse))
2863 *format_type_formats[] =
2887 (void) CopyMagickString(magic,extension,MaxTextExtent);
2892 format_type=UndefinedFormatType;
2894 while ((format_type == UndefinedFormatType) &&
2895 (format_type_formats[i] != (
char *) NULL))
2897 if ((*magic == *format_type_formats[i]) &&
2898 (LocaleCompare(magic,format_type_formats[i]) == 0))
2899 format_type=ExplicitFormatType;
2902 magick_info=GetMagickInfo(magic,sans_exception);
2903 if ((magick_info != (
const MagickInfo *) NULL) &&
2904 (magick_info->format_type != UndefinedFormatType))
2905 format_type=magick_info->format_type;
2906 if (format_type == UndefinedFormatType)
2907 (void) CopyMagickString(image_info->magick,magic,MaxTextExtent);
2909 if (format_type == ExplicitFormatType)
2911 image_info->affirm=MagickTrue;
2912 (void) CopyMagickString(image_info->magick,magic,MaxTextExtent);
2914 if (LocaleCompare(magic,
"RGB") == 0)
2915 image_info->affirm=MagickFalse;
2921 GetPathComponent(image_info->filename,MagickPath,magic);
2924 (void) CopyMagickString(magic,image_info->magick,MaxTextExtent);
2925 magick_info=GetMagickInfo(magic,sans_exception);
2927 GetPathComponent(image_info->filename,CanonicalPath,filename);
2929 GetPathComponent(image_info->filename,SubcanonicalPath,filename);
2930 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
2941 magick_info=GetMagickInfo(magic,sans_exception);
2942 delegate_info=GetDelegateInfo(magic,
"*",sans_exception);
2944 delegate_info=GetDelegateInfo(
"*",magic,sans_exception);
2945 if (((magick_info != (
const MagickInfo *) NULL) ||
2947 (IsMagickConflict(magic) == MagickFalse))
2949 image_info->affirm=MagickTrue;
2950 (void) CopyMagickString(image_info->magick,magic,MaxTextExtent);
2951 GetPathComponent(image_info->filename,CanonicalPath,filename);
2952 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
2955 sans_exception=DestroyExceptionInfo(sans_exception);
2956 if ((magick_info == (
const MagickInfo *) NULL) ||
2957 (GetMagickEndianSupport(magick_info) == MagickFalse))
2958 image_info->endian=UndefinedEndian;
2959 if ((image_info->adjoin != MagickFalse) && (frames > 1))
2964 (void) InterpretImageFilename(image_info,(
Image *) NULL,
2965 image_info->filename,(int) image_info->scene,filename);
2966 if ((LocaleCompare(filename,image_info->filename) != 0) &&
2967 (strchr(filename,
'%') == (
char *) NULL))
2968 image_info->adjoin=MagickFalse;
2970 if ((image_info->adjoin != MagickFalse) && (frames > 0))
2975 magick_info=GetMagickInfo(magic,exception);
2976 if (magick_info != (
const MagickInfo *) NULL)
2977 if (GetMagickAdjoin(magick_info) == MagickFalse)
2978 image_info->adjoin=MagickFalse;
2980 if (image_info->affirm != MagickFalse)
2987 image=AcquireImage(image_info);
2988 (void) CopyMagickString(image->filename,image_info->filename,
2990 status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
2991 if (status == MagickFalse)
2993 image=DestroyImage(image);
2994 return(MagickFalse);
2996 if ((IsBlobSeekable(image) == MagickFalse) ||
2997 (IsBlobExempt(image) != MagickFalse))
3003 status=ImageToFile(image,filename,exception);
3004 (void) CloseBlob(image);
3005 if (status == MagickFalse)
3007 (void) RelinquishUniqueFileResource(filename);
3008 image=DestroyImage(image);
3009 return(MagickFalse);
3011 SetImageInfoFile(image_info,(FILE *) NULL);
3012 (void) CopyMagickString(image->filename,filename,MaxTextExtent);
3013 status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
3014 if (status == MagickFalse)
3016 (void) RelinquishUniqueFileResource(filename);
3017 image=DestroyImage(image);
3018 return(MagickFalse);
3020 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
3021 image_info->temporary=MagickTrue;
3023 (void) memset(magick,0,
sizeof(magick));
3024 count=ReadBlob(image,2*MaxTextExtent,magick);
3025 (void) SeekBlob(image,-((MagickOffsetType) count),SEEK_CUR);
3026 (void) CloseBlob(image);
3027 image=DestroyImage(image);
3031 sans_exception=AcquireExceptionInfo();
3032 magic_info=GetMagicInfo(magick,(
size_t) count,sans_exception);
3033 if ((magic_info != (
const MagicInfo *) NULL) &&
3034 (GetMagicName(magic_info) != (
char *) NULL))
3036 (void) CopyMagickString(image_info->magick,GetMagicName(magic_info),
3038 magick_info=GetMagickInfo(image_info->magick,sans_exception);
3039 if ((magick_info == (
const MagickInfo *) NULL) ||
3040 (GetMagickEndianSupport(magick_info) == MagickFalse))
3041 image_info->endian=UndefinedEndian;
3042 sans_exception=DestroyExceptionInfo(sans_exception);
3045 magick_info=GetMagickInfo(image_info->magick,sans_exception);
3046 if ((magick_info == (
const MagickInfo *) NULL) ||
3047 (GetMagickEndianSupport(magick_info) == MagickFalse))
3048 image_info->endian=UndefinedEndian;
3049 sans_exception=DestroyExceptionInfo(sans_exception);
3081 MagickExport
void SetImageInfoBlob(
ImageInfo *image_info,
const void *blob,
3082 const size_t length)
3084 assert(image_info != (
ImageInfo *) NULL);
3085 assert(image_info->signature == MagickCoreSignature);
3086 if (IsEventLogging() != MagickFalse)
3087 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
3088 image_info->filename);
3089 image_info->blob=(
void *) blob;
3090 image_info->length=length;
3117 MagickExport
void SetImageInfoFile(
ImageInfo *image_info,FILE *file)
3119 assert(image_info != (
ImageInfo *) NULL);
3120 assert(image_info->signature == MagickCoreSignature);
3121 if (IsEventLogging() != MagickFalse)
3122 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
3123 image_info->filename);
3124 image_info->file=file;
3152 MagickExport MagickBooleanType SetImageMask(
Image *image,
const Image *mask)
3154 assert(image != (
Image *) NULL);
3155 assert(image->signature == MagickCoreSignature);
3156 if (IsEventLogging() != MagickFalse)
3157 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
3158 if (mask != (
const Image *) NULL)
3159 if ((mask->columns != image->columns) || (mask->rows != image->rows))
3160 ThrowBinaryImageException(ImageError,
"ImageSizeDiffers",image->filename);
3161 if (image->mask != (
Image *) NULL)
3162 image->mask=DestroyImage(image->mask);
3163 image->mask=NewImageList();
3164 if (mask == (
Image *) NULL)
3166 if (SetImageStorageClass(image,DirectClass) == MagickFalse)
3167 return(MagickFalse);
3168 image->mask=CloneImage(mask,0,0,MagickTrue,&image->exception);
3169 if (image->mask == (
Image *) NULL)
3170 return(MagickFalse);
3199 MagickExport MagickBooleanType SetImageOpacity(
Image *image,
3200 const Quantum opacity)
3214 assert(image != (
Image *) NULL);
3215 assert(image->signature == MagickCoreSignature);
3216 if (IsEventLogging() != MagickFalse)
3217 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
3218 image->matte=MagickTrue;
3220 exception=(&image->exception);
3221 image_view=AcquireAuthenticCacheView(image,exception);
3222 #if defined(MAGICKCORE_OPENMP_SUPPORT)
3223 #pragma omp parallel for schedule(static) shared(status) \
3224 magick_number_threads(image,image,image->rows,1)
3226 for (y=0; y < (ssize_t) image->rows; y++)
3234 if (status == MagickFalse)
3236 q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
3242 for (x=0; x < (ssize_t) image->columns; x++)
3244 SetPixelOpacity(q,opacity);
3247 if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
3250 image_view=DestroyCacheView(image_view);
3281 MagickExport VirtualPixelMethod SetImageVirtualPixelMethod(
const Image *image,
3282 const VirtualPixelMethod virtual_pixel_method)
3284 assert(image != (
const Image *) NULL);
3285 assert(image->signature == MagickCoreSignature);
3286 if (IsEventLogging() != MagickFalse)
3287 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
3288 return(SetPixelCacheVirtualMethod(image,virtual_pixel_method));
3326 static ssize_t SmushXGap(
const Image *smush_image,
const Image *images,
3354 if (images->previous == (
Image *) NULL)
3357 SetGeometry(smush_image,&right_geometry);
3358 GravityAdjustGeometry(right_image->columns,right_image->rows,
3359 right_image->gravity,&right_geometry);
3360 left_image=images->previous;
3361 SetGeometry(smush_image,&left_geometry);
3362 GravityAdjustGeometry(left_image->columns,left_image->rows,
3363 left_image->gravity,&left_geometry);
3364 gap=right_image->columns;
3365 left_view=AcquireVirtualCacheView(left_image,exception);
3366 right_view=AcquireVirtualCacheView(right_image,exception);
3367 for (y=0; y < (ssize_t) smush_image->rows; y++)
3369 for (x=(ssize_t) left_image->columns-1; x > 0; x--)
3371 p=GetCacheViewVirtualPixels(left_view,x,left_geometry.y+y,1,1,exception);
3373 (GetPixelOpacity(p) != TransparentOpacity) ||
3374 ((left_image->columns-x-1) >= gap))
3377 i=(ssize_t) left_image->columns-x-1;
3378 for (x=0; x < (ssize_t) right_image->columns; x++)
3380 p=GetCacheViewVirtualPixels(right_view,x,right_geometry.y+y,1,1,
3383 (GetPixelOpacity(p) != TransparentOpacity) ||
3384 ((x+i) >= (ssize_t) gap))
3387 if ((x+i) < (ssize_t) gap)
3390 right_view=DestroyCacheView(right_view);
3391 left_view=DestroyCacheView(left_view);
3392 if (y < (ssize_t) smush_image->rows)
3394 return((ssize_t) gap-offset);
3397 static ssize_t SmushYGap(
const Image *smush_image,
const Image *images,
3425 if (images->previous == (
Image *) NULL)
3427 bottom_image=images;
3428 SetGeometry(smush_image,&bottom_geometry);
3429 GravityAdjustGeometry(bottom_image->columns,bottom_image->rows,
3430 bottom_image->gravity,&bottom_geometry);
3431 top_image=images->previous;
3432 SetGeometry(smush_image,&top_geometry);
3433 GravityAdjustGeometry(top_image->columns,top_image->rows,top_image->gravity,
3435 gap=bottom_image->rows;
3436 top_view=AcquireVirtualCacheView(top_image,exception);
3437 bottom_view=AcquireVirtualCacheView(bottom_image,exception);
3438 for (x=0; x < (ssize_t) smush_image->columns; x++)
3440 for (y=(ssize_t) top_image->rows-1; y > 0; y--)
3442 p=GetCacheViewVirtualPixels(top_view,top_geometry.x+x,y,1,1,exception);
3444 (GetPixelOpacity(p) != TransparentOpacity) ||
3445 ((top_image->rows-y-1) >= gap))
3448 i=(ssize_t) top_image->rows-y-1;
3449 for (y=0; y < (ssize_t) bottom_image->rows; y++)
3451 p=GetCacheViewVirtualPixels(bottom_view,bottom_geometry.x+x,y,1,1,
3454 (GetPixelOpacity(p) != TransparentOpacity) ||
3455 ((y+i) >= (ssize_t) gap))
3458 if ((y+i) < (ssize_t) gap)
3461 bottom_view=DestroyCacheView(bottom_view);
3462 top_view=DestroyCacheView(top_view);
3463 if (x < (ssize_t) smush_image->columns)
3465 return((ssize_t) gap-offset);
3468 MagickExport
Image *SmushImages(
const Image *images,
3469 const MagickBooleanType stack,
const ssize_t offset,
ExceptionInfo *exception)
3471 #define SmushImageTag "Smush/Image"
3508 assert(images != (
Image *) NULL);
3509 assert(images->signature == MagickCoreSignature);
3511 assert(exception->signature == MagickCoreSignature);
3512 if (IsEventLogging() != MagickFalse)
3513 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",images->filename);
3517 width=image->columns;
3519 next=GetNextImageInList(image);
3520 for ( ; next != (
Image *) NULL; next=GetNextImageInList(next))
3522 if (next->matte != MagickFalse)
3525 if (stack != MagickFalse)
3527 if (next->columns > width)
3528 width=next->columns;
3530 if (next->previous != (
Image *) NULL)
3534 width+=next->columns;
3535 if (next->previous != (
Image *) NULL)
3537 if (next->rows > height)
3543 smush_image=CloneImage(image,width,height,MagickTrue,exception);
3544 if (smush_image == (
Image *) NULL)
3545 return((
Image *) NULL);
3546 if (SetImageStorageClass(smush_image,DirectClass) == MagickFalse)
3548 InheritException(exception,&smush_image->exception);
3549 smush_image=DestroyImage(smush_image);
3550 return((
Image *) NULL);
3552 smush_image->matte=matte;
3553 (void) SetImageBackgroundColor(smush_image);
3557 smush_view=AcquireVirtualCacheView(smush_image,exception);
3558 for (n=0; n < (MagickOffsetType) number_images; n++)
3560 SetGeometry(smush_image,&geometry);
3561 GravityAdjustGeometry(image->columns,image->rows,image->gravity,&geometry);
3562 if (stack != MagickFalse)
3564 x_offset-=geometry.x;
3565 y_offset-=SmushYGap(smush_image,image,offset,exception);
3569 x_offset-=SmushXGap(smush_image,image,offset,exception);
3570 y_offset-=geometry.y;
3572 status=CompositeImage(smush_image,OverCompositeOp,image,x_offset,y_offset);
3573 proceed=SetImageProgress(image,SmushImageTag,n,number_images);
3574 if (proceed == MagickFalse)
3576 if (stack == MagickFalse)
3578 x_offset+=(ssize_t) image->columns;
3584 y_offset+=(ssize_t) image->rows;
3586 image=GetNextImageInList(image);
3588 if (stack == MagickFalse)
3589 smush_image->columns=(size_t) x_offset;
3591 smush_image->rows=(size_t) y_offset;
3592 smush_view=DestroyCacheView(smush_view);
3593 if (status == MagickFalse)
3594 smush_image=DestroyImage(smush_image);
3595 return(smush_image);
3620 MagickExport MagickBooleanType StripImage(
Image *image)
3625 assert(image != (
Image *) NULL);
3626 if (IsEventLogging() != MagickFalse)
3627 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
3628 DestroyImageProfiles(image);
3629 (void) DeleteImageProperty(image,
"comment");
3630 (void) DeleteImageProperty(image,
"date:create");
3631 (void) DeleteImageProperty(image,
"date:modify");
3632 status=SetImageArtifact(image,
"png:exclude-chunk",
3633 "bKGD,caNv,cHRM,eXIf,gAMA,iCCP,iTXt,pHYs,sRGB,tEXt,zCCP,zTXt,date");
3661 static inline IndexPacket PushColormapIndex(
Image *image,
3662 const size_t index,MagickBooleanType *range_exception)
3664 if (index < image->colors)
3665 return((IndexPacket) index);
3666 *range_exception=MagickTrue;
3667 return((IndexPacket) 0);
3670 MagickExport MagickBooleanType SyncImage(
Image *image)
3686 assert(image != (
Image *) NULL);
3687 assert(image->signature == MagickCoreSignature);
3688 if (IsEventLogging() != MagickFalse)
3689 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
3690 if (image->ping != MagickFalse)
3692 if (image->storage_class != PseudoClass)
3693 return(MagickFalse);
3695 range_exception=MagickFalse;
3698 exception=(&image->exception);
3699 image_view=AcquireAuthenticCacheView(image,exception);
3700 #if defined(MAGICKCORE_OPENMP_SUPPORT)
3701 #pragma omp parallel for schedule(static) shared(range_exception,status) \
3702 magick_number_threads(image,image,image->rows,1)
3704 for (y=0; y < (ssize_t) image->rows; y++)
3710 *magick_restrict indexes;
3718 if (status == MagickFalse)
3720 q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
3726 indexes=GetCacheViewAuthenticIndexQueue(image_view);
3727 for (x=0; x < (ssize_t) image->columns; x++)
3729 index=PushColormapIndex(image,(
size_t) GetPixelIndex(indexes+x),
3731 if (image->matte == MagickFalse)
3732 SetPixelRgb(q,image->colormap+(ssize_t) index)
3734 SetPixelRGBO(q,image->colormap+(ssize_t) index);
3737 if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
3740 image_view=DestroyCacheView(image_view);
3742 if ((image->ping == MagickFalse) && (range_exception != MagickFalse))
3743 (void) ThrowMagickException(&image->exception,GetMagickModule(),
3744 CorruptImageWarning,
"InvalidColormapIndex",
"`%s'",image->filename);
3776 MagickExport MagickBooleanType SyncImagesSettings(
ImageInfo *image_info,
3782 assert(image_info != (
const ImageInfo *) NULL);
3783 assert(image_info->signature == MagickCoreSignature);
3784 assert(images != (
Image *) NULL);
3785 assert(images->signature == MagickCoreSignature);
3786 if (IsEventLogging() != MagickFalse)
3787 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",images->filename);
3789 for ( ; image != (
Image *) NULL; image=GetNextImageInList(image))
3790 (
void) SyncImageSettings(image_info,image);
3791 (void) DeleteImageOption(image_info,
"page");
3795 MagickExport MagickBooleanType SyncImageSettings(
const ImageInfo *image_info,
3799 property[MaxTextExtent];
3817 assert(image_info != (
const ImageInfo *) NULL);
3818 assert(image_info->signature == MagickCoreSignature);
3819 assert(image != (
Image *) NULL);
3820 assert(image->signature == MagickCoreSignature);
3821 if (IsEventLogging() != MagickFalse)
3822 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
3823 option=GetImageOption(image_info,
"background");
3824 if (option != (
const char *) NULL)
3825 (void) QueryColorDatabase(option,&image->background_color,
3827 option=GetImageOption(image_info,
"bias");
3828 if (option != (
const char *) NULL)
3829 image->bias=StringToDoubleInterval(option,(
double) QuantumRange+1.0);
3830 option=GetImageOption(image_info,
"black-point-compensation");
3831 if (option != (
const char *) NULL)
3832 image->black_point_compensation=(MagickBooleanType) ParseCommandOption(
3833 MagickBooleanOptions,MagickFalse,option);
3834 option=GetImageOption(image_info,
"blue-primary");
3835 if (option != (
const char *) NULL)
3837 flags=ParseGeometry(option,&geometry_info);
3838 if ((flags & RhoValue) != 0)
3839 image->chromaticity.blue_primary.x=geometry_info.rho;
3840 image->chromaticity.blue_primary.y=image->chromaticity.blue_primary.x;
3841 if ((flags & SigmaValue) != 0)
3842 image->chromaticity.blue_primary.y=geometry_info.sigma;
3844 option=GetImageOption(image_info,
"bordercolor");
3845 if (option != (
const char *) NULL)
3846 (void) QueryColorDatabase(option,&image->border_color,&image->exception);
3847 option=GetImageOption(image_info,
"colors");
3848 if (option != (
const char *) NULL)
3849 image->colors=StringToUnsignedLong(option);
3850 option=GetImageOption(image_info,
"compose");
3851 if (option != (
const char *) NULL)
3852 image->compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
3853 MagickFalse,option);
3854 option=GetImageOption(image_info,
"compress");
3855 if (option != (
const char *) NULL)
3856 image->compression=(CompressionType) ParseCommandOption(
3857 MagickCompressOptions,MagickFalse,option);
3858 option=GetImageOption(image_info,
"debug");
3859 if (option != (
const char *) NULL)
3860 image->debug=(MagickBooleanType) ParseCommandOption(MagickBooleanOptions,
3861 MagickFalse,option);
3862 option=GetImageOption(image_info,
"density");
3863 if (option != (
const char *) NULL)
3871 flags=ParseGeometry(option,&geometry_info);
3872 if ((flags & RhoValue) != 0)
3873 image->x_resolution=geometry_info.rho;
3874 image->y_resolution=image->x_resolution;
3875 if ((flags & SigmaValue) != 0)
3876 image->y_resolution=geometry_info.sigma;
3878 option=GetImageOption(image_info,
"depth");
3879 if (option != (
const char *) NULL)
3880 image->depth=StringToUnsignedLong(option);
3881 option=GetImageOption(image_info,
"endian");
3882 if (option != (
const char *) NULL)
3883 image->endian=(EndianType) ParseCommandOption(MagickEndianOptions,
3884 MagickFalse,option);
3885 option=GetImageOption(image_info,
"filter");
3886 if (option != (
const char *) NULL)
3887 image->filter=(FilterTypes) ParseCommandOption(MagickFilterOptions,
3888 MagickFalse,option);
3889 option=GetImageOption(image_info,
"fuzz");
3890 if (option != (
const char *) NULL)
3891 image->fuzz=StringToDoubleInterval(option,(
double) QuantumRange+1.0);
3892 option=GetImageOption(image_info,
"gravity");
3893 if (option != (
const char *) NULL)
3894 image->gravity=(GravityType) ParseCommandOption(MagickGravityOptions,
3895 MagickFalse,option);
3896 option=GetImageOption(image_info,
"green-primary");
3897 if (option != (
const char *) NULL)
3899 flags=ParseGeometry(option,&geometry_info);
3900 if ((flags & RhoValue) != 0)
3901 image->chromaticity.green_primary.x=geometry_info.rho;
3902 image->chromaticity.green_primary.y=image->chromaticity.green_primary.x;
3903 if ((flags & SigmaValue) != 0)
3904 image->chromaticity.green_primary.y=geometry_info.sigma;
3906 option=GetImageOption(image_info,
"intensity");
3907 if (option != (
const char *) NULL)
3908 image->intensity=(PixelIntensityMethod) ParseCommandOption(
3909 MagickPixelIntensityOptions,MagickFalse,option);
3910 option=GetImageOption(image_info,
"intent");
3911 if (option != (
const char *) NULL)
3912 image->rendering_intent=(RenderingIntent) ParseCommandOption(
3913 MagickIntentOptions,MagickFalse,option);
3914 option=GetImageOption(image_info,
"interlace");
3915 if (option != (
const char *) NULL)
3916 image->interlace=(InterlaceType) ParseCommandOption(MagickInterlaceOptions,
3917 MagickFalse,option);
3918 option=GetImageOption(image_info,
"interpolate");
3919 if (option != (
const char *) NULL)
3920 image->interpolate=(InterpolatePixelMethod) ParseCommandOption(
3921 MagickInterpolateOptions,MagickFalse,option);
3922 option=GetImageOption(image_info,
"loop");
3923 if (option != (
const char *) NULL)
3924 image->iterations=StringToUnsignedLong(option);
3925 option=GetImageOption(image_info,
"mattecolor");
3926 if (option != (
const char *) NULL)
3927 (void) QueryColorDatabase(option,&image->matte_color,&image->exception);
3928 option=GetImageOption(image_info,
"orient");
3929 if (option != (
const char *) NULL)
3930 image->orientation=(OrientationType) ParseCommandOption(
3931 MagickOrientationOptions,MagickFalse,option);
3932 option=GetImageOption(image_info,
"page");
3933 if (option != (
const char *) NULL)
3938 geometry=GetPageGeometry(option);
3939 flags=ParseAbsoluteGeometry(geometry,&image->page);
3940 geometry=DestroyString(geometry);
3942 option=GetImageOption(image_info,
"quality");
3943 if (option != (
const char *) NULL)
3944 image->quality=StringToUnsignedLong(option);
3945 option=GetImageOption(image_info,
"red-primary");
3946 if (option != (
const char *) NULL)
3948 flags=ParseGeometry(option,&geometry_info);
3949 if ((flags & RhoValue) != 0)
3950 image->chromaticity.red_primary.x=geometry_info.rho;
3951 image->chromaticity.red_primary.y=image->chromaticity.red_primary.x;
3952 if ((flags & SigmaValue) != 0)
3953 image->chromaticity.red_primary.y=geometry_info.sigma;
3955 if (image_info->quality != UndefinedCompressionQuality)
3956 image->quality=image_info->quality;
3957 option=GetImageOption(image_info,
"scene");
3958 if (option != (
const char *) NULL)
3959 image->scene=StringToUnsignedLong(option);
3960 option=GetImageOption(image_info,
"taint");
3961 if (option != (
const char *) NULL)
3962 image->taint=(MagickBooleanType) ParseCommandOption(MagickBooleanOptions,
3963 MagickFalse,option);
3964 option=GetImageOption(image_info,
"tile-offset");
3965 if (option != (
const char *) NULL)
3970 geometry=GetPageGeometry(option);
3971 flags=ParseAbsoluteGeometry(geometry,&image->tile_offset);
3972 geometry=DestroyString(geometry);
3974 option=GetImageOption(image_info,
"transparent-color");
3975 if (option != (
const char *) NULL)
3976 (void) QueryColorDatabase(option,&image->transparent_color,
3978 option=GetImageOption(image_info,
"type");
3979 if (option != (
const char *) NULL)
3980 image->type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3982 option=GetImageOption(image_info,
"units");
3983 units=image_info->units;
3984 if (option != (
const char *) NULL)
3985 units=(ResolutionType) ParseCommandOption(MagickResolutionOptions,
3986 MagickFalse,option);
3987 if (units != UndefinedResolution)
3989 if (image->units != units)
3990 switch (image->units)
3992 case PixelsPerInchResolution:
3994 if (units == PixelsPerCentimeterResolution)
3996 image->x_resolution/=2.54;
3997 image->y_resolution/=2.54;
4001 case PixelsPerCentimeterResolution:
4003 if (units == PixelsPerInchResolution)
4005 image->x_resolution=(double) ((
size_t) (100.0*2.54*
4006 image->x_resolution+0.5))/100.0;
4007 image->y_resolution=(double) ((
size_t) (100.0*2.54*
4008 image->y_resolution+0.5))/100.0;
4016 option=GetImageOption(image_info,
"density");
4017 if (option != (
const char *) NULL)
4019 flags=ParseGeometry(option,&geometry_info);
4020 if ((flags & RhoValue) != 0)
4021 image->x_resolution=geometry_info.rho;
4022 image->y_resolution=image->x_resolution;
4023 if ((flags & SigmaValue) != 0)
4024 image->y_resolution=geometry_info.sigma;
4027 option=GetImageOption(image_info,
"white-point");
4028 if (option != (
const char *) NULL)
4030 flags=ParseGeometry(option,&geometry_info);
4031 if ((flags & RhoValue) != 0)
4032 image->chromaticity.white_point.x=geometry_info.rho;
4033 image->chromaticity.white_point.y=image->chromaticity.white_point.x;
4034 if ((flags & SigmaValue) != 0)
4035 image->chromaticity.white_point.y=geometry_info.sigma;
4037 ResetImageOptionIterator(image_info);
4038 for (option=GetNextImageOption(image_info); option != (
const char *) NULL; )
4040 value=GetImageOption(image_info,option);
4041 if (value != (
const char *) NULL)
4043 (void) FormatLocaleString(property,MaxTextExtent,
"%s",option);
4044 (void) SetImageArtifact(image,property,value);
4046 option=GetNextImageOption(image_info);