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 GetPixelPacketRGBA(BackgroundColorRGBA,&image->background_color);
175 GetPixelPacketRGBA(BorderColorRGBA,&image->border_color);
176 GetPixelPacketRGBA(MatteColorRGBA,&image->matte_color);
177 GetPixelPacketRGBA(TransparentColorRGBA,&image->transparent_color);
178 GetTimerInfo(&image->timer);
179 image->ping=MagickFalse;
180 image->cache=AcquirePixelCache(0);
181 image->blob=CloneBlobInfo((
BlobInfo *) NULL);
182 InitializeExceptionInfo(&image->exception);
183 image->timestamp=GetMagickTime();
184 image->debug=(GetLogEventMask() & (ImageEvent | TransformEvent | CoderEvent))
185 != 0 ? MagickTrue : MagickFalse;
186 image->reference_count=1;
187 image->semaphore=AllocateSemaphoreInfo();
188 image->signature=MagickCoreSignature;
194 SetBlobExempt(image,image_info->file != (FILE *) NULL ? MagickTrue :
196 (void) CopyMagickString(image->filename,image_info->filename,MaxTextExtent);
197 (void) CopyMagickString(image->magick_filename,image_info->filename,
199 (void) CopyMagickString(image->magick,image_info->magick,MaxTextExtent);
200 if (image_info->size != (
char *) NULL)
202 (void) ParseAbsoluteGeometry(image_info->size,&image->extract_info);
203 image->columns=image->extract_info.width;
204 image->rows=image->extract_info.height;
205 image->offset=image->extract_info.x;
206 image->extract_info.x=0;
207 image->extract_info.y=0;
209 if (image_info->extract != (
char *) NULL)
214 (void) memset(&geometry,0,
sizeof(geometry));
215 flags=ParseAbsoluteGeometry(image_info->extract,&geometry);
216 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
218 image->extract_info=geometry;
219 Swap(image->columns,image->extract_info.width);
220 Swap(image->rows,image->extract_info.height);
223 image->compression=image_info->compression;
224 image->quality=image_info->quality;
225 image->endian=image_info->endian;
226 image->interlace=image_info->interlace;
227 image->units=image_info->units;
228 if (image_info->density != (
char *) NULL)
233 flags=ParseGeometry(image_info->density,&geometry_info);
234 if ((flags & RhoValue) != 0)
235 image->x_resolution=geometry_info.rho;
236 image->y_resolution=image->x_resolution;
237 if ((flags & SigmaValue) != 0)
238 image->y_resolution=geometry_info.sigma;
240 if (image_info->page != (
char *) NULL)
245 image->page=image->extract_info;
246 geometry=GetPageGeometry(image_info->page);
247 (void) ParseAbsoluteGeometry(geometry,&image->page);
248 geometry=DestroyString(geometry);
250 if (image_info->depth != 0)
251 image->depth=image_info->depth;
252 image->dither=image_info->dither;
253 image->background_color=image_info->background_color;
254 image->border_color=image_info->border_color;
255 image->matte_color=image_info->matte_color;
256 image->transparent_color=image_info->transparent_color;
257 image->ping=image_info->ping;
258 image->progress_monitor=image_info->progress_monitor;
259 image->client_data=image_info->client_data;
260 if (image_info->cache != (
void *) NULL)
261 ClonePixelCacheMethods(image->cache,image_info->cache);
262 (void) SyncImageSettings(image_info,image);
263 option=GetImageOption(image_info,
"delay");
264 if (option != (
const char *) NULL)
269 flags=ParseGeometry(option,&geometry_info);
270 if ((flags & GreaterValue) != 0)
272 if ((
double) image->delay > floor(geometry_info.rho+0.5))
273 image->delay=(size_t) CastDoubleToLong(floor(
274 geometry_info.rho+0.5));
277 if ((flags & LessValue) != 0)
279 if ((
double) image->delay < floor(geometry_info.rho+0.5))
280 image->ticks_per_second=CastDoubleToLong(floor(
281 geometry_info.sigma+0.5));
284 image->delay=(size_t) CastDoubleToLong(floor(
285 geometry_info.rho+0.5));
286 if ((flags & SigmaValue) != 0)
287 image->ticks_per_second=CastDoubleToLong(floor(
288 geometry_info.sigma+0.5));
290 option=GetImageOption(image_info,
"dispose");
291 if (option != (
const char *) NULL)
292 image->dispose=(DisposeType) ParseCommandOption(MagickDisposeOptions,
315 MagickExport
ImageInfo *AcquireImageInfo(
void)
320 image_info=(
ImageInfo *) AcquireMagickMemory(
sizeof(*image_info));
322 ThrowFatalException(ResourceLimitFatalError,
"MemoryAllocationFailed");
323 GetImageInfo(image_info);
355 MagickExport
void AcquireNextImage(
const ImageInfo *image_info,
Image *image)
360 assert(image != (
Image *) NULL);
361 assert(image->signature == MagickCoreSignature);
362 if (IsEventLogging() != MagickFalse)
363 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
364 image->next=AcquireImage(image_info);
365 if (GetNextImageInList(image) == (
Image *) NULL)
367 (void) CopyMagickString(GetNextImageInList(image)->filename,image->filename,
370 (
void) CopyMagickString(GetNextImageInList(image)->filename,
371 image_info->filename,MaxTextExtent);
372 DestroyBlob(GetNextImageInList(image));
373 image->next->blob=ReferenceBlob(image->blob);
374 image->next->endian=image->endian;
375 image->next->scene=image->scene+1;
376 image->next->previous=image;
411 MagickExport
Image *AppendImages(
const Image *images,
414 #define AppendImageTag "Append/Image"
423 homogeneous_colorspace,
450 assert(images != (
Image *) NULL);
451 assert(images->signature == MagickCoreSignature);
453 assert(exception->signature == MagickCoreSignature);
454 if (IsEventLogging() != MagickFalse)
455 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",images->filename);
458 width=images->columns;
461 homogeneous_colorspace=MagickTrue;
462 next=GetNextImageInList(images);
463 for ( ; next != (
Image *) NULL; next=GetNextImageInList(next))
465 if (next->depth > depth)
467 if (next->colorspace != images->colorspace)
468 homogeneous_colorspace=MagickFalse;
469 if (next->matte != MagickFalse)
472 if (stack != MagickFalse)
474 if (next->columns > width)
479 width+=next->columns;
480 if (next->rows > height)
486 append_image=CloneImage(images,width,height,MagickTrue,exception);
487 if (append_image == (
Image *) NULL)
488 return((
Image *) NULL);
489 if (SetImageStorageClass(append_image,DirectClass) == MagickFalse)
491 InheritException(exception,&append_image->exception);
492 append_image=DestroyImage(append_image);
493 return((
Image *) NULL);
495 if (homogeneous_colorspace == MagickFalse)
496 (void) SetImageColorspace(append_image,sRGBColorspace);
497 append_image->depth=depth;
498 append_image->matte=matte;
499 append_image->page=images->page;
500 (void) SetImageBackgroundColor(append_image);
505 append_view=AcquireAuthenticCacheView(append_image,exception);
506 for (n=0; n < (MagickOffsetType) number_images; n++)
514 SetGeometry(append_image,&geometry);
515 GravityAdjustGeometry(next->columns,next->rows,next->gravity,&geometry);
516 if (stack != MagickFalse)
517 x_offset-=geometry.x;
519 y_offset-=geometry.y;
520 image_view=AcquireVirtualCacheView(next,exception);
521 #if defined(MAGICKCORE_OPENMP_SUPPORT)
522 #pragma omp parallel for schedule(static) shared(status) \
523 magick_number_threads(next,next,next->rows,1)
525 for (y=0; y < (ssize_t) next->rows; y++)
531 *magick_restrict indexes;
537 *magick_restrict append_indexes;
545 if (status == MagickFalse)
547 p=GetCacheViewVirtualPixels(image_view,0,y,next->columns,1,exception);
548 q=QueueCacheViewAuthenticPixels(append_view,x_offset,y+y_offset,
549 next->columns,1,exception);
555 indexes=GetCacheViewVirtualIndexQueue(image_view);
556 append_indexes=GetCacheViewAuthenticIndexQueue(append_view);
557 for (x=0; x < (ssize_t) next->columns; x++)
559 SetPixelRed(q,GetPixelRed(p));
560 SetPixelGreen(q,GetPixelGreen(p));
561 SetPixelBlue(q,GetPixelBlue(p));
562 SetPixelOpacity(q,OpaqueOpacity);
563 if (next->matte != MagickFalse)
564 SetPixelOpacity(q,GetPixelOpacity(p));
565 if ((next->colorspace == CMYKColorspace) &&
566 (append_image->colorspace == CMYKColorspace))
567 SetPixelIndex(append_indexes+x,GetPixelIndex(indexes+x));
571 sync=SyncCacheViewAuthenticPixels(append_view,exception);
572 if (sync == MagickFalse)
575 image_view=DestroyCacheView(image_view);
576 if (stack == MagickFalse)
578 x_offset+=(ssize_t) next->columns;
584 y_offset+=(ssize_t) next->rows;
586 proceed=SetImageProgress(append_image,AppendImageTag,n,number_images);
587 if (proceed == MagickFalse)
589 next=GetNextImageInList(next);
591 append_view=DestroyCacheView(append_view);
592 if (status == MagickFalse)
593 append_image=DestroyImage(append_image);
594 return(append_image);
621 MagickExport ExceptionType CatchImageException(
Image *image)
629 assert(image != (
const Image *) NULL);
630 assert(image->signature == MagickCoreSignature);
631 if (IsEventLogging() != MagickFalse)
632 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
633 exception=AcquireExceptionInfo();
634 GetImageException(image,exception);
635 CatchException(exception);
636 severity=exception->severity;
637 exception=DestroyExceptionInfo(exception);
672 MagickExport MagickBooleanType ClipImage(
Image *image)
674 return(ClipImagePath(image,
"#1",MagickTrue));
677 MagickExport MagickBooleanType ClipImagePath(
Image *image,
const char *pathname,
678 const MagickBooleanType inside)
680 #define ClipImagePathTag "ClipPath/Image"
694 assert(image != (
const Image *) NULL);
695 assert(image->signature == MagickCoreSignature);
696 assert(pathname != NULL);
697 if (IsEventLogging() != MagickFalse)
698 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
699 property=AcquireString(pathname);
700 (void) FormatLocaleString(property,MaxTextExtent,
"8BIM:1999,2998:%s",
702 value=GetImageProperty(image,property);
703 property=DestroyString(property);
704 if (value == (
const char *) NULL)
706 ThrowFileException(&image->exception,OptionError,
"NoClipPathDefined",
710 image_info=AcquireImageInfo();
711 (void) CopyMagickString(image_info->filename,image->filename,MaxTextExtent);
712 (void) ConcatenateMagickString(image_info->filename,pathname,MaxTextExtent);
713 clip_mask=BlobToImage(image_info,value,strlen(value),&image->exception);
714 image_info=DestroyImageInfo(image_info);
715 if (clip_mask == (
Image *) NULL)
717 if (clip_mask->storage_class == PseudoClass)
719 (void) SyncImage(clip_mask);
720 if (SetImageStorageClass(clip_mask,DirectClass) == MagickFalse)
723 if (inside == MagickFalse)
724 (void) NegateImage(clip_mask,MagickFalse);
725 (void) FormatLocaleString(clip_mask->magick_filename,MaxTextExtent,
726 "8BIM:1999,2998:%s\nPS",pathname);
727 (void) SetImageClipMask(image,clip_mask);
728 clip_mask=DestroyImage(clip_mask);
771 MagickExport
Image *CloneImage(
const Image *image,
const size_t columns,
772 const size_t rows,
const MagickBooleanType detach,
ExceptionInfo *exception)
787 assert(image != (
const Image *) NULL);
788 assert(image->signature == MagickCoreSignature);
790 assert(exception->signature == MagickCoreSignature);
791 if (IsEventLogging() != MagickFalse)
792 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
793 if ((image->columns == 0) || (image->rows == 0))
795 (void) ThrowMagickException(exception,GetMagickModule(),CorruptImageError,
796 "NegativeOrZeroImageSize",
"`%s'",image->filename);
797 return((
Image *) NULL);
799 clone_image=(
Image *) AcquireCriticalMemory(
sizeof(*clone_image));
800 (void) memset(clone_image,0,
sizeof(*clone_image));
801 clone_image->signature=MagickCoreSignature;
802 clone_image->storage_class=image->storage_class;
803 clone_image->channels=image->channels;
804 clone_image->colorspace=image->colorspace;
805 clone_image->matte=image->matte;
806 clone_image->columns=image->columns;
807 clone_image->rows=image->rows;
808 clone_image->dither=image->dither;
809 (void) CloneImageProfiles(clone_image,image);
810 (void) CloneImageProperties(clone_image,image);
811 (void) CloneImageArtifacts(clone_image,image);
812 GetTimerInfo(&clone_image->timer);
813 InitializeExceptionInfo(&clone_image->exception);
814 InheritException(&clone_image->exception,&image->exception);
815 if (image->ascii85 != (
void *) NULL)
816 Ascii85Initialize(clone_image);
817 clone_image->extent=image->extent;
818 clone_image->magick_columns=image->magick_columns;
819 clone_image->magick_rows=image->magick_rows;
820 clone_image->type=image->type;
821 (void) CopyMagickString(clone_image->magick_filename,image->magick_filename,
823 (void) CopyMagickString(clone_image->magick,image->magick,MaxTextExtent);
824 (void) CopyMagickString(clone_image->filename,image->filename,MaxTextExtent);
825 clone_image->progress_monitor=image->progress_monitor;
826 clone_image->client_data=image->client_data;
827 clone_image->reference_count=1;
828 clone_image->next=image->next;
829 clone_image->previous=image->previous;
830 clone_image->list=NewImageList();
831 clone_image->clip_mask=NewImageList();
832 clone_image->mask=NewImageList();
833 if (detach == MagickFalse)
834 clone_image->blob=ReferenceBlob(image->blob);
837 clone_image->next=NewImageList();
838 clone_image->previous=NewImageList();
839 clone_image->blob=CloneBlobInfo((
BlobInfo *) NULL);
841 clone_image->ping=image->ping;
842 clone_image->debug=image->debug;
843 clone_image->semaphore=AllocateSemaphoreInfo();
849 clone_image->colors=image->colors;
850 length=(size_t) image->colors;
851 clone_image->colormap=(
PixelPacket *) AcquireQuantumMemory(length+1,
852 sizeof(*clone_image->colormap));
855 clone_image=DestroyImage(clone_image);
856 ThrowImageException(ResourceLimitError,
"MemoryAllocationFailed");
858 (void) memcpy(clone_image->colormap,image->colormap,length*
859 sizeof(*clone_image->colormap));
861 if ((columns == 0) || (rows == 0))
863 if (image->montage != (
char *) NULL)
864 (
void) CloneString(&clone_image->montage,image->montage);
865 if (image->directory != (
char *) NULL)
866 (void) CloneString(&clone_image->directory,image->directory);
867 if (image->clip_mask != (
Image *) NULL)
868 clone_image->clip_mask=CloneImage(image->clip_mask,0,0,MagickTrue,
870 if (image->mask != (
Image *) NULL)
871 clone_image->mask=CloneImage(image->mask,0,0,MagickTrue,exception);
872 clone_image->cache=ReferencePixelCache(image->cache);
875 if ((columns == image->columns) && (rows == image->rows))
877 if (image->clip_mask != (
Image *) NULL)
878 clone_image->clip_mask=CloneImage(image->clip_mask,0,0,MagickTrue,
880 if (image->mask != (
Image *) NULL)
881 clone_image->mask=CloneImage(image->mask,0,0,MagickTrue,exception);
885 if (image->columns != 0)
886 scale_x=(double) columns/(
double) image->columns;
887 if (image->rows != 0)
888 scale_y=(double) rows/(
double) image->rows;
889 clone_image->page.width=(size_t) CastDoubleToLong(floor(scale_x*
890 image->page.width+0.5));
891 clone_image->page.height=(size_t) CastDoubleToLong(floor(scale_y*
892 image->page.height+0.5));
893 if (MagickAbsoluteValue(scale_x-scale_y) < 2.0)
894 scale_x=scale_y=MagickMin(scale_x,scale_y);
895 clone_image->page.x=CastDoubleToLong(ceil(scale_x*image->page.x-0.5));
896 clone_image->tile_offset.x=CastDoubleToLong(ceil(scale_x*
897 image->tile_offset.x-0.5));
898 clone_image->page.y=CastDoubleToLong(ceil(scale_y*image->page.y-0.5));
899 clone_image->tile_offset.y=CastDoubleToLong(ceil(scale_y*
900 image->tile_offset.y-0.5));
901 clone_image->cache=ClonePixelCache(image->cache);
902 if (SetImageExtent(clone_image,columns,rows) == MagickFalse)
904 InheritException(exception,&clone_image->exception);
905 clone_image=DestroyImage(clone_image);
939 clone_info=AcquireImageInfo();
942 clone_info->compression=image_info->compression;
943 clone_info->temporary=image_info->temporary;
944 clone_info->adjoin=image_info->adjoin;
945 clone_info->antialias=image_info->antialias;
946 clone_info->scene=image_info->scene;
947 clone_info->number_scenes=image_info->number_scenes;
948 clone_info->depth=image_info->depth;
949 if (image_info->size != (
char *) NULL)
950 (void) CloneString(&clone_info->size,image_info->size);
951 if (image_info->extract != (
char *) NULL)
952 (
void) CloneString(&clone_info->extract,image_info->extract);
953 if (image_info->scenes != (
char *) NULL)
954 (void) CloneString(&clone_info->scenes,image_info->scenes);
955 if (image_info->page != (
char *) NULL)
956 (
void) CloneString(&clone_info->page,image_info->page);
957 clone_info->interlace=image_info->interlace;
958 clone_info->endian=image_info->endian;
959 clone_info->units=image_info->units;
960 clone_info->quality=image_info->quality;
961 if (image_info->sampling_factor != (
char *) NULL)
962 (void) CloneString(&clone_info->sampling_factor,
963 image_info->sampling_factor);
964 if (image_info->server_name != (
char *) NULL)
965 (
void) CloneString(&clone_info->server_name,image_info->server_name);
966 if (image_info->font != (
char *) NULL)
967 (void) CloneString(&clone_info->font,image_info->font);
968 if (image_info->texture != (
char *) NULL)
969 (
void) CloneString(&clone_info->texture,image_info->texture);
970 if (image_info->density != (
char *) NULL)
971 (void) CloneString(&clone_info->density,image_info->density);
972 clone_info->pointsize=image_info->pointsize;
973 clone_info->fuzz=image_info->fuzz;
974 clone_info->pen=image_info->pen;
975 clone_info->background_color=image_info->background_color;
976 clone_info->border_color=image_info->border_color;
977 clone_info->matte_color=image_info->matte_color;
978 clone_info->transparent_color=image_info->transparent_color;
979 clone_info->dither=image_info->dither;
980 clone_info->monochrome=image_info->monochrome;
981 clone_info->colors=image_info->colors;
982 clone_info->colorspace=image_info->colorspace;
983 clone_info->type=image_info->type;
984 clone_info->orientation=image_info->orientation;
985 clone_info->preview_type=image_info->preview_type;
986 clone_info->group=image_info->group;
987 clone_info->ping=image_info->ping;
988 clone_info->verbose=image_info->verbose;
989 if (image_info->view != (
char *) NULL)
990 (
void) CloneString(&clone_info->view,image_info->view);
991 if (image_info->authenticate != (
char *) NULL)
992 (void) CloneString(&clone_info->authenticate,image_info->authenticate);
993 (void) CloneImageOptions(clone_info,image_info);
994 clone_info->progress_monitor=image_info->progress_monitor;
995 clone_info->client_data=image_info->client_data;
996 clone_info->cache=image_info->cache;
997 if (image_info->cache != (
void *) NULL)
998 clone_info->cache=ReferencePixelCache(image_info->cache);
999 if (image_info->profile != (
void *) NULL)
1000 clone_info->profile=(
void *) CloneStringInfo((
StringInfo *)
1001 image_info->profile);
1002 SetImageInfoFile(clone_info,image_info->file);
1003 SetImageInfoBlob(clone_info,image_info->blob,image_info->length);
1004 clone_info->stream=image_info->stream;
1005 clone_info->virtual_pixel_method=image_info->virtual_pixel_method;
1006 (void) CopyMagickString(clone_info->magick,image_info->magick,MaxTextExtent);
1007 (void) CopyMagickString(clone_info->unique,image_info->unique,MaxTextExtent);
1008 (void) CopyMagickString(clone_info->zero,image_info->zero,MaxTextExtent);
1009 (void) CopyMagickString(clone_info->filename,image_info->filename,
1011 clone_info->subimage=image_info->scene;
1012 clone_info->subrange=image_info->number_scenes;
1013 clone_info->channel=image_info->channel;
1014 clone_info->debug=image_info->debug;
1015 clone_info->signature=image_info->signature;
1052 MagickExport MagickBooleanType CopyImagePixels(
Image *image,
1056 #define CopyImageTag "Copy/Image"
1071 assert(image != (
Image *) NULL);
1072 assert(source_image != (
Image *) NULL);
1075 if (IsEventLogging() != MagickFalse)
1076 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
1077 if ((offset->x < 0) || (offset->y < 0) ||
1078 ((ssize_t) (offset->x+geometry->width) > (ssize_t) image->columns) ||
1079 ((ssize_t) (offset->y+geometry->height) > (ssize_t) image->rows))
1080 ThrowBinaryException(OptionError,
"GeometryDoesNotContainImage",
1082 if (SetImageStorageClass(image,DirectClass) == MagickFalse)
1083 return(MagickFalse);
1089 source_view=AcquireVirtualCacheView(source_image,exception);
1090 image_view=AcquireAuthenticCacheView(image,exception);
1091 #if defined(MAGICKCORE_OPENMP_SUPPORT)
1092 #pragma omp parallel for schedule(static) shared(progress,status) \
1093 magick_number_threads(source_image,image,geometry->height,1)
1095 for (y=0; y < (ssize_t) geometry->height; y++)
1098 *magick_restrict source_indexes;
1104 *magick_restrict indexes;
1112 if (status == MagickFalse)
1114 p=GetCacheViewVirtualPixels(source_view,geometry->x,y+geometry->y,
1115 geometry->width,1,exception);
1116 q=GetCacheViewAuthenticPixels(image_view,offset->x,y+offset->y,
1117 geometry->width,1,exception);
1123 source_indexes=GetCacheViewVirtualIndexQueue(source_view);
1124 indexes=GetCacheViewAuthenticIndexQueue(image_view);
1125 for (x=0; x < (ssize_t) geometry->width; x++)
1128 if (image->colorspace == CMYKColorspace)
1129 indexes[x]=source_indexes[x];
1133 if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
1135 if (image->progress_monitor != (MagickProgressMonitor) NULL)
1140 #if defined(MAGICKCORE_OPENMP_SUPPORT)
1144 proceed=SetImageProgress(image,CopyImageTag,progress,image->rows);
1145 if (proceed == MagickFalse)
1149 image_view=DestroyCacheView(image_view);
1150 source_view=DestroyCacheView(source_view);
1177 MagickExport
Image *DestroyImage(
Image *image)
1185 assert(image != (
Image *) NULL);
1186 assert(image->signature == MagickCoreSignature);
1187 if (IsEventLogging() != MagickFalse)
1188 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
1189 destroy=MagickFalse;
1190 LockSemaphoreInfo(image->semaphore);
1191 image->reference_count--;
1192 if (image->reference_count == 0)
1194 UnlockSemaphoreInfo(image->semaphore);
1195 if (destroy == MagickFalse)
1196 return((
Image *) NULL);
1200 DestroyImagePixels(image);
1201 if (image->clip_mask != (
Image *) NULL)
1202 image->clip_mask=DestroyImage(image->clip_mask);
1203 if (image->mask != (
Image *) NULL)
1204 image->mask=DestroyImage(image->mask);
1205 if (image->montage != (
char *) NULL)
1206 image->montage=DestroyString(image->montage);
1207 if (image->directory != (
char *) NULL)
1208 image->directory=DestroyString(image->directory);
1210 image->colormap=(
PixelPacket *) RelinquishMagickMemory(image->colormap);
1211 if (image->geometry != (
char *) NULL)
1212 image->geometry=DestroyString(image->geometry);
1213 DestroyImageProfiles(image);
1214 DestroyImageProperties(image);
1215 DestroyImageArtifacts(image);
1217 image->ascii85=(
Ascii85Info *) RelinquishMagickMemory(image->ascii85);
1219 (void) ClearExceptionInfo(&image->exception,MagickTrue);
1221 DestroySemaphoreInfo(&image->semaphore);
1222 image->signature=(~MagickCoreSignature);
1223 image=(
Image *) RelinquishMagickMemory(image);
1252 assert(image_info != (
ImageInfo *) NULL);
1253 assert(image_info->signature == MagickCoreSignature);
1254 if (IsEventLogging() != MagickFalse)
1255 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
1256 image_info->filename);
1257 if (image_info->size != (
char *) NULL)
1258 image_info->size=DestroyString(image_info->size);
1259 if (image_info->extract != (
char *) NULL)
1260 image_info->extract=DestroyString(image_info->extract);
1261 if (image_info->scenes != (
char *) NULL)
1262 image_info->scenes=DestroyString(image_info->scenes);
1263 if (image_info->page != (
char *) NULL)
1264 image_info->page=DestroyString(image_info->page);
1265 if (image_info->sampling_factor != (
char *) NULL)
1266 image_info->sampling_factor=DestroyString(
1267 image_info->sampling_factor);
1268 if (image_info->server_name != (
char *) NULL)
1269 image_info->server_name=DestroyString(
1270 image_info->server_name);
1271 if (image_info->font != (
char *) NULL)
1272 image_info->font=DestroyString(image_info->font);
1273 if (image_info->texture != (
char *) NULL)
1274 image_info->texture=DestroyString(image_info->texture);
1275 if (image_info->density != (
char *) NULL)
1276 image_info->density=DestroyString(image_info->density);
1277 if (image_info->view != (
char *) NULL)
1278 image_info->view=DestroyString(image_info->view);
1279 if (image_info->authenticate != (
char *) NULL)
1280 image_info->authenticate=DestroyString(
1281 image_info->authenticate);
1282 DestroyImageOptions(image_info);
1283 if (image_info->cache != (
void *) NULL)
1284 image_info->cache=DestroyPixelCache(image_info->cache);
1285 if (image_info->profile != (
StringInfo *) NULL)
1286 image_info->profile=(
void *) DestroyStringInfo((
StringInfo *)
1287 image_info->profile);
1288 image_info->signature=(~MagickCoreSignature);
1289 image_info=(
ImageInfo *) RelinquishMagickMemory(image_info);
1317 MagickExport
void DisassociateImageStream(
Image *image)
1319 assert(image != (
Image *) NULL);
1320 assert(image->signature == MagickCoreSignature);
1321 if (IsEventLogging() != MagickFalse)
1322 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
1323 DisassociateBlob(image);
1348 MagickExport
Image *GetImageClipMask(
const Image *image,
1351 assert(image != (
const Image *) NULL);
1352 assert(image->signature == MagickCoreSignature);
1353 if (IsEventLogging() != MagickFalse)
1354 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
1355 if (image->clip_mask == (
Image *) NULL)
1356 return((
Image *) NULL);
1357 return(CloneImage(image->clip_mask,0,0,MagickTrue,exception));
1390 assert(image != (
Image *) NULL);
1391 assert(image->signature == MagickCoreSignature);
1393 assert(exception->signature == MagickCoreSignature);
1394 if (IsEventLogging() != MagickFalse)
1395 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
1396 for (next=image; next != (
Image *) NULL; next=GetNextImageInList(next))
1398 if (next->exception.severity == UndefinedException)
1400 if (next->exception.severity > exception->severity)
1401 InheritException(exception,&next->exception);
1402 next->exception.severity=UndefinedException;
1428 MagickExport
void GetImageInfo(
ImageInfo *image_info)
1436 assert(image_info != (
ImageInfo *) NULL);
1437 if (IsEventLogging() != MagickFalse)
1438 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
1439 (void) memset(image_info,0,
sizeof(*image_info));
1440 image_info->adjoin=MagickTrue;
1441 image_info->interlace=NoInterlace;
1442 image_info->channel=DefaultChannels;
1443 image_info->quality=UndefinedCompressionQuality;
1444 image_info->antialias=MagickTrue;
1445 image_info->dither=MagickTrue;
1446 synchronize=GetEnvironmentValue(
"MAGICK_SYNCHRONIZE");
1447 if (synchronize != (
const char *) NULL)
1449 image_info->synchronize=IsStringTrue(synchronize);
1450 synchronize=DestroyString(synchronize);
1452 GetPixelPacketRGBA(BackgroundColorRGBA,&image_info->background_color);
1453 GetPixelPacketRGBA(BorderColorRGBA,&image_info->border_color);
1454 GetPixelPacketRGBA(MatteColorRGBA,&image_info->matte_color);
1455 GetPixelPacketRGBA(TransparentColorRGBA,&image_info->transparent_color);
1456 image_info->debug=(GetLogEventMask() & ImageEvent) != 0 ? MagickTrue :
1458 image_info->signature=MagickCoreSignature;
1483 MagickExport FILE *GetImageInfoFile(
const ImageInfo *image_info)
1485 return(image_info->file);
1512 assert(image != (
const Image *) NULL);
1513 assert(image->signature == MagickCoreSignature);
1514 if (IsEventLogging() != MagickFalse)
1515 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
1516 if (image->mask == (
Image *) NULL)
1517 return((
Image *) NULL);
1518 return(CloneImage(image->mask,0,0,MagickTrue,exception));
1544 MagickExport
size_t GetImageChannels(
Image *image)
1546 assert(image != (
Image *) NULL);
1547 assert(image->signature == MagickCoreSignature);
1548 if (IsEventLogging() != MagickFalse)
1549 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
1550 return(image->channels);
1575 MagickExport ssize_t GetImageReferenceCount(
Image *image)
1580 assert(image != (
Image *) NULL);
1581 assert(image->signature == MagickCoreSignature);
1582 if (IsEventLogging() != MagickFalse)
1583 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
1584 LockSemaphoreInfo(image->semaphore);
1585 reference_count=image->reference_count;
1586 UnlockSemaphoreInfo(image->semaphore);
1587 return(reference_count);
1614 MagickExport VirtualPixelMethod GetImageVirtualPixelMethod(
const Image *image)
1616 assert(image != (
Image *) NULL);
1617 assert(image->signature == MagickCoreSignature);
1618 if (IsEventLogging() != MagickFalse)
1619 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
1620 return(GetPixelCacheVirtualMethod(image));
1656 MagickExport
size_t InterpretImageFilename(
const ImageInfo *image_info,
1657 Image *image,
const char *format,
int value,
char *filename)
1675 canonical=MagickFalse;
1677 (void) CopyMagickString(filename,format,MaxTextExtent);
1678 if (IsStringTrue(GetImageOption(image_info,
"filename:literal")) != MagickFalse)
1679 return(strlen(filename));
1680 for (p=strchr(format,
'%'); p != (
char *) NULL; p=strchr(p+1,
'%'))
1690 field_width=(ssize_t) strtol(q,&q,10);
1700 (void) FormatLocaleString(filename+(p-format-offset),(size_t)
1701 (MaxTextExtent-(p-format-offset)),p,value);
1702 offset+=(4-field_width);
1704 (void) ConcatenateMagickString(filename,q,MaxTextExtent);
1705 canonical=MagickTrue;
1714 pattern[MaxTextExtent];
1731 if (strchr(p,
']') == (
char *) NULL)
1735 for (i=0; (i < (MaxTextExtent-1L)) && (*r !=
'\0'); i++)
1746 if (LocaleNCompare(pattern,
"filename:",9) != 0)
1748 value=(
const char *) NULL;
1749 if (image != (
Image *) NULL)
1750 value=GetImageProperty(image,pattern);
1751 if ((value == (
const char *) NULL) &&
1752 (image != (
Image *) NULL))
1753 value=GetImageArtifact(image,pattern);
1754 if ((value == (
const char *) NULL) &&
1756 value=GetImageOption(image_info,pattern);
1757 if (value == (
const char *) NULL)
1762 (void) CopyMagickString(filename+(p-format-offset),value,(size_t)
1763 (MaxTextExtent-(p-format-offset)));
1764 offset+=strlen(pattern)-strlen(value)+3;
1766 (void) ConcatenateMagickString(filename,r+1,MaxTextExtent);
1767 canonical=MagickTrue;
1777 if (canonical == MagickFalse)
1778 (void) CopyMagickString(filename,format,MaxTextExtent);
1780 for (q=filename; *q !=
'\0'; q++)
1781 if ((*q ==
'%') && (*(q+1) ==
'%'))
1782 (
void) CopyMagickString(q,q+1,(
size_t) (MaxTextExtent-(q-filename)));
1783 return(strlen(filename));
1813 MagickExport MagickBooleanType IsHighDynamicRangeImage(
const Image *image,
1816 #if !defined(MAGICKCORE_HDRI_SUPPORT)
1819 return(MagickFalse);
1833 assert(image != (
Image *) NULL);
1834 assert(image->signature == MagickCoreSignature);
1835 if (IsEventLogging() != MagickFalse)
1836 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
1838 GetMagickPixelPacket(image,&zero);
1839 image_view=AcquireVirtualCacheView(image,exception);
1840 #if defined(MAGICKCORE_OPENMP_SUPPORT)
1841 #pragma omp parallel for schedule(static) shared(status) \
1842 magick_number_threads(image,image,image->rows,1)
1844 for (y=0; y < (ssize_t) image->rows; y++)
1858 if (status == MagickFalse)
1860 p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
1866 indexes=GetCacheViewVirtualIndexQueue(image_view);
1868 for (x=0; x < (ssize_t) image->columns; x++)
1870 SetMagickPixelPacket(image,p,indexes+x,&pixel);
1871 if ((pixel.red < 0.0) || (pixel.red > QuantumRange) ||
1872 (pixel.red != (QuantumAny) pixel.red))
1874 if ((pixel.green < 0.0) || (pixel.green > QuantumRange) ||
1875 (pixel.green != (QuantumAny) pixel.green))
1877 if ((pixel.blue < 0.0) || (pixel.blue > QuantumRange) ||
1878 (pixel.blue != (QuantumAny) pixel.blue))
1880 if (pixel.matte != MagickFalse)
1882 if ((pixel.opacity < 0.0) || (pixel.opacity > QuantumRange) ||
1883 (pixel.opacity != (QuantumAny) pixel.opacity))
1886 if (pixel.colorspace == CMYKColorspace)
1888 if ((pixel.index < 0.0) || (pixel.index > QuantumRange) ||
1889 (pixel.index != (QuantumAny) pixel.index))
1894 if (x < (ssize_t) image->columns)
1897 image_view=DestroyCacheView(image_view);
1898 return(status != MagickFalse ? MagickFalse : MagickTrue);
1925 MagickExport MagickBooleanType IsImageObject(
const Image *image)
1930 assert(image != (
Image *) NULL);
1931 if (IsEventLogging() != MagickFalse)
1932 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
1933 for (p=image; p != (
Image *) NULL; p=GetNextImageInList(p))
1934 if (p->signature != MagickCoreSignature)
1935 return(MagickFalse);
1962 MagickExport MagickBooleanType IsTaintImage(
const Image *image)
1965 magick[MaxTextExtent],
1966 filename[MaxTextExtent];
1971 assert(image != (
Image *) NULL);
1972 assert(image->signature == MagickCoreSignature);
1973 if (IsEventLogging() != MagickFalse)
1974 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
1975 (void) CopyMagickString(magick,image->magick,MaxTextExtent);
1976 (void) CopyMagickString(filename,image->filename,MaxTextExtent);
1977 for (p=image; p != (
Image *) NULL; p=GetNextImageInList(p))
1979 if (p->taint != MagickFalse)
1981 if (LocaleCompare(p->magick,magick) != 0)
1983 if (LocaleCompare(p->filename,filename) != 0)
1986 return(MagickFalse);
2015 MagickExport MagickBooleanType ModifyImage(
Image **image,
2021 assert(image != (
Image **) NULL);
2022 assert(*image != (
Image *) NULL);
2023 assert((*image)->signature == MagickCoreSignature);
2024 if (IsEventLogging() != MagickFalse)
2025 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",(*image)->filename);
2026 if (GetImageReferenceCount(*image) <= 1)
2028 clone_image=CloneImage(*image,0,0,MagickTrue,exception);
2029 LockSemaphoreInfo((*image)->semaphore);
2030 (*image)->reference_count--;
2031 UnlockSemaphoreInfo((*image)->semaphore);
2084 assert(image_info != (
const ImageInfo *) NULL);
2085 assert(image_info->signature == MagickCoreSignature);
2087 if (IsEventLogging() != MagickFalse)
2088 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
2089 image=AcquireImage(image_info);
2090 image->columns=width;
2092 image->colorspace=background->colorspace;
2093 image->matte=background->matte;
2094 image->fuzz=background->fuzz;
2095 image->depth=background->depth;
2097 exception=(&image->exception);
2098 image_view=AcquireAuthenticCacheView(image,exception);
2099 #if defined(MAGICKCORE_OPENMP_SUPPORT)
2100 #pragma omp parallel for schedule(static) shared(status) \
2101 magick_number_threads(image,image,image->rows,1)
2103 for (y=0; y < (ssize_t) image->rows; y++)
2106 *magick_restrict indexes;
2114 if (status == MagickFalse)
2116 q=QueueCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
2122 indexes=GetCacheViewAuthenticIndexQueue(image_view);
2123 for (x=0; x < (ssize_t) image->columns; x++)
2125 SetPixelPacket(image,background,q,indexes+x);
2128 if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2131 image_view=DestroyCacheView(image_view);
2132 if (status == MagickFalse)
2133 image=DestroyImage(image);
2160 MagickExport
Image *ReferenceImage(
Image *image)
2162 assert(image != (
Image *) NULL);
2163 assert(image->signature == MagickCoreSignature);
2164 if (IsEventLogging() != MagickFalse)
2165 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
2166 LockSemaphoreInfo(image->semaphore);
2167 image->reference_count++;
2168 UnlockSemaphoreInfo(image->semaphore);
2196 MagickExport MagickBooleanType ResetImagePage(
Image *image,
const char *page)
2204 assert(image != (
Image *) NULL);
2205 assert(image->signature == MagickCoreSignature);
2206 if (IsEventLogging() != MagickFalse)
2207 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
2208 flags=ParseAbsoluteGeometry(page,&geometry);
2209 if ((flags & WidthValue) != 0)
2211 if ((flags & HeightValue) == 0)
2212 geometry.height=geometry.width;
2213 image->page.width=geometry.width;
2214 image->page.height=geometry.height;
2216 if ((flags & AspectValue) != 0)
2218 if ((flags & XValue) != 0)
2219 image->page.x+=geometry.x;
2220 if ((flags & YValue) != 0)
2221 image->page.y+=geometry.y;
2225 if ((flags & XValue) != 0)
2227 image->page.x=geometry.x;
2228 if ((image->page.width == 0) && (geometry.x > 0))
2229 image->page.width=image->columns+geometry.x;
2231 if ((flags & YValue) != 0)
2233 image->page.y=geometry.y;
2234 if ((image->page.height == 0) && (geometry.y > 0))
2235 image->page.height=image->rows+geometry.y;
2267 MagickExport MagickBooleanType ResetImagePixels(
Image *image,
2285 assert(image != (
Image *) NULL);
2286 assert(image->signature == MagickCoreSignature);
2287 if (IsEventLogging() != MagickFalse)
2288 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
2289 pixels=AcquirePixelCachePixels(image,&length,exception);
2290 if (pixels != (
void *) NULL)
2295 (void) memset((
void *) pixels,0,(size_t) length);
2302 image_view=AcquireAuthenticCacheView(image,exception);
2303 #if defined(MAGICKCORE_OPENMP_SUPPORT)
2304 #pragma omp parallel for schedule(static) shared(status) \
2305 magick_number_threads(image,image,image->rows,1)
2307 for (y=0; y < (ssize_t) image->rows; y++)
2310 *magick_restrict indexes;
2318 if (status == MagickFalse)
2320 q=QueueCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
2326 indexes=GetCacheViewAuthenticIndexQueue(image_view);
2327 for (x=0; x < (ssize_t) image->columns; x++)
2330 if ((image->storage_class == PseudoClass) ||
2331 (image->colorspace == CMYKColorspace))
2335 if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2338 image_view=DestroyCacheView(image_view);
2366 MagickExport MagickBooleanType SetImageBackgroundColor(
Image *image)
2389 assert(image != (
Image *) NULL);
2390 assert(image->signature == MagickCoreSignature);
2391 if (IsEventLogging() != MagickFalse)
2392 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
2393 if (SetImageStorageClass(image,DirectClass) == MagickFalse)
2394 return(MagickFalse);
2395 if ((IsPixelGray(&image->background_color) == MagickFalse) &&
2396 (IsGrayColorspace(image->colorspace) != MagickFalse))
2397 (void) TransformImageColorspace(image,RGBColorspace);
2398 if ((image->background_color.opacity != OpaqueOpacity) &&
2399 (image->matte == MagickFalse))
2400 (void) SetImageAlphaChannel(image,OpaqueAlphaChannel);
2401 GetMagickPixelPacket(image,&background);
2402 SetMagickPixelPacket(image,&image->background_color,(
const IndexPacket *)
2404 if (image->colorspace == CMYKColorspace)
2405 ConvertRGBToCMYK(&background);
2407 pixel.opacity=OpaqueOpacity;
2408 SetPixelPacket(image,&background,&pixel,&index);
2413 exception=(&image->exception);
2414 image_view=AcquireAuthenticCacheView(image,exception);
2415 for (y=0; y < (ssize_t) image->rows; y++)
2423 if (status == MagickFalse)
2425 q=QueueCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
2431 for (x=0; x < (ssize_t) image->columns; x++)
2433 if (image->colorspace == CMYKColorspace)
2436 *magick_restrict indexes;
2438 indexes=GetCacheViewAuthenticIndexQueue(image_view);
2439 for (x=0; x < (ssize_t) image->columns; x++)
2440 SetPixelIndex(indexes+x,index);
2442 if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2445 image_view=DestroyCacheView(image_view);
2474 MagickExport MagickBooleanType SetImageChannels(
Image *image,
2475 const size_t channels)
2477 image->channels=channels;
2506 MagickExport MagickBooleanType SetImageColor(
Image *image,
2521 assert(image != (
Image *) NULL);
2522 assert(image->signature == MagickCoreSignature);
2524 if (IsEventLogging() != MagickFalse)
2525 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
2526 image->colorspace=color->colorspace;
2527 image->matte=color->matte;
2528 image->fuzz=color->fuzz;
2529 image->depth=color->depth;
2531 exception=(&image->exception);
2532 image_view=AcquireAuthenticCacheView(image,exception);
2533 #if defined(MAGICKCORE_OPENMP_SUPPORT)
2534 #pragma omp parallel for schedule(static) shared(status) \
2535 magick_number_threads(image,image,image->rows,1)
2537 for (y=0; y < (ssize_t) image->rows; y++)
2540 *magick_restrict indexes;
2548 if (status == MagickFalse)
2550 q=QueueCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
2556 indexes=GetCacheViewAuthenticIndexQueue(image_view);
2557 for (x=0; x < (ssize_t) image->columns; x++)
2559 SetPixelPacket(image,color,q,
2560 indexes == (IndexPacket *) NULL ? NULL : indexes+x);
2563 if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2566 image_view=DestroyCacheView(image_view);
2596 MagickExport MagickBooleanType SetImageStorageClass(
Image *image,
2597 const ClassType storage_class)
2599 assert(image != (
Image *) NULL);
2600 assert(image->signature == MagickCoreSignature);
2601 if (IsEventLogging() != MagickFalse)
2602 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
2603 image->storage_class=storage_class;
2604 return(SyncImagePixelCache(image,&image->exception));
2634 MagickExport MagickBooleanType SetImageClipMask(
Image *image,
2635 const Image *clip_mask)
2637 assert(image != (
Image *) NULL);
2638 assert(image->signature == MagickCoreSignature);
2639 if (IsEventLogging() != MagickFalse)
2640 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
2641 if (clip_mask != (
const Image *) NULL)
2642 if ((clip_mask->columns != image->columns) ||
2643 (clip_mask->rows != image->rows))
2644 ThrowBinaryImageException(ImageError,
"ImageSizeDiffers",image->filename);
2645 if (image->clip_mask != (
Image *) NULL)
2646 image->clip_mask=DestroyImage(image->clip_mask);
2647 image->clip_mask=NewImageList();
2648 if (clip_mask == (
Image *) NULL)
2650 if (SetImageStorageClass(image,DirectClass) == MagickFalse)
2651 return(MagickFalse);
2652 image->clip_mask=CloneImage(clip_mask,0,0,MagickTrue,&image->exception);
2653 if (image->clip_mask == (
Image *) NULL)
2654 return(MagickFalse);
2685 MagickExport MagickBooleanType SetImageExtent(
Image *image,
const size_t columns,
2688 if ((columns == 0) || (rows == 0))
2689 ThrowBinaryImageException(ImageError,
"NegativeOrZeroImageSize",
2691 image->columns=columns;
2693 if (image->depth == 0)
2696 (void) ThrowMagickException(&image->exception,GetMagickModule(),
2697 ImageError,
"ImageDepthNotSupported",
"`%s'",image->filename);
2699 if (image->depth > (8*
sizeof(MagickSizeType)))
2701 image->depth=8*
sizeof(MagickSizeType);
2702 (void) ThrowMagickException(&image->exception,GetMagickModule(),
2703 ImageError,
"ImageDepthNotSupported",
"`%s'",image->filename);
2705 return(SyncImagePixelCache(image,&image->exception));
2742 MagickExport MagickBooleanType SetImageInfo(
ImageInfo *image_info,
2746 extension[MaxTextExtent],
2747 filename[MaxTextExtent],
2748 magic[MaxTextExtent],
2750 subimage[MaxTextExtent];
2774 magick[2*MaxTextExtent];
2779 assert(image_info != (
ImageInfo *) NULL);
2780 assert(image_info->signature == MagickCoreSignature);
2781 if (IsEventLogging() != MagickFalse)
2782 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
2783 image_info->filename);
2785 GetPathComponent(image_info->filename,SubimagePath,subimage);
2786 if (*subimage !=
'\0')
2791 if (IsSceneGeometry(subimage,MagickFalse) == MagickFalse)
2793 if (IsGeometry(subimage) != MagickFalse)
2794 (void) CloneString(&image_info->extract,subimage);
2802 (void) CloneString(&image_info->scenes,subimage);
2803 image_info->scene=StringToUnsignedLong(image_info->scenes);
2804 image_info->number_scenes=image_info->scene;
2805 p=image_info->scenes;
2806 for (q=(
char *) image_info->scenes; *q !=
'\0'; p++)
2808 while ((isspace((
int) ((
unsigned char) *p)) != 0) || (*p ==
','))
2810 first=(size_t) strtol(p,&q,10);
2812 while (isspace((
int) ((
unsigned char) *q)) != 0)
2815 last=(size_t) strtol(q+1,&q,10);
2818 if (first < image_info->scene)
2819 image_info->scene=first;
2820 if (last > image_info->number_scenes)
2821 image_info->number_scenes=last;
2824 image_info->number_scenes-=image_info->scene-1;
2825 image_info->subimage=image_info->scene;
2826 image_info->subrange=image_info->number_scenes;
2830 if (*image_info->magick ==
'\0')
2831 GetPathComponent(image_info->filename,ExtensionPath,extension);
2832 if (*extension !=
'\0')
2835 path[MaxTextExtent];
2840 GetPathComponent(image_info->filename,BasePathSansCompressExtension,path);
2841 GetPathComponent(path,ExtensionPath,extension);
2843 image_info->affirm=MagickFalse;
2844 sans_exception=AcquireExceptionInfo();
2845 if ((*extension !=
'\0') && (IsGlob(extension) == MagickFalse))
2854 *format_type_formats[] =
2878 (void) CopyMagickString(magic,extension,MaxTextExtent);
2883 format_type=UndefinedFormatType;
2885 while ((format_type == UndefinedFormatType) &&
2886 (format_type_formats[i] != (
char *) NULL))
2888 if ((*magic == *format_type_formats[i]) &&
2889 (LocaleCompare(magic,format_type_formats[i]) == 0))
2890 format_type=ExplicitFormatType;
2893 magick_info=GetMagickInfo(magic,sans_exception);
2894 if ((magick_info != (
const MagickInfo *) NULL) &&
2895 (magick_info->format_type != UndefinedFormatType))
2896 format_type=magick_info->format_type;
2897 if (format_type == UndefinedFormatType)
2898 (void) CopyMagickString(image_info->magick,magic,MaxTextExtent);
2900 if (format_type == ExplicitFormatType)
2902 image_info->affirm=MagickTrue;
2903 (void) CopyMagickString(image_info->magick,magic,MaxTextExtent);
2905 if (LocaleCompare(magic,
"RGB") == 0)
2906 image_info->affirm=MagickFalse;
2912 GetPathComponent(image_info->filename,MagickPath,magic);
2915 (void) CopyMagickString(magic,image_info->magick,MaxTextExtent);
2916 magick_info=GetMagickInfo(magic,sans_exception);
2917 if ((magick_info != (
const MagickInfo *) NULL) &&
2918 (magick_info->format_type == ExplicitFormatType))
2919 image_info->affirm=MagickTrue;
2921 GetPathComponent(image_info->filename,CanonicalPath,filename);
2923 GetPathComponent(image_info->filename,SubcanonicalPath,filename);
2924 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
2935 magick_info=GetMagickInfo(magic,sans_exception);
2936 delegate_info=GetDelegateInfo(magic,
"*",sans_exception);
2938 delegate_info=GetDelegateInfo(
"*",magic,sans_exception);
2939 if (((magick_info != (
const MagickInfo *) NULL) ||
2941 (IsMagickConflict(magic) == MagickFalse))
2943 image_info->affirm=MagickTrue;
2944 (void) CopyMagickString(image_info->magick,magic,MaxTextExtent);
2945 GetPathComponent(image_info->filename,CanonicalPath,filename);
2946 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
2949 sans_exception=DestroyExceptionInfo(sans_exception);
2950 if ((magick_info == (
const MagickInfo *) NULL) ||
2951 (GetMagickEndianSupport(magick_info) == MagickFalse))
2952 image_info->endian=UndefinedEndian;
2953 if ((image_info->adjoin != MagickFalse) && (frames > 1))
2958 (void) InterpretImageFilename(image_info,(
Image *) NULL,
2959 image_info->filename,(int) image_info->scene,filename);
2960 if ((LocaleCompare(filename,image_info->filename) != 0) &&
2961 (strchr(filename,
'%') == (
char *) NULL))
2962 image_info->adjoin=MagickFalse;
2964 if ((image_info->adjoin != MagickFalse) && (frames > 0))
2969 magick_info=GetMagickInfo(magic,exception);
2970 if (magick_info != (
const MagickInfo *) NULL)
2971 if (GetMagickAdjoin(magick_info) == MagickFalse)
2972 image_info->adjoin=MagickFalse;
2974 if (image_info->affirm != MagickFalse)
2981 image=AcquireImage(image_info);
2982 (void) CopyMagickString(image->filename,image_info->filename,
2984 status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
2985 if (status == MagickFalse)
2987 image=DestroyImage(image);
2988 return(MagickFalse);
2990 if ((IsBlobSeekable(image) == MagickFalse) ||
2991 (IsBlobExempt(image) != MagickFalse))
2997 status=ImageToFile(image,filename,exception);
2998 (void) CloseBlob(image);
2999 if (status == MagickFalse)
3001 (void) RelinquishUniqueFileResource(filename);
3002 image=DestroyImage(image);
3003 return(MagickFalse);
3005 SetImageInfoFile(image_info,(FILE *) NULL);
3006 (void) CopyMagickString(image->filename,filename,MaxTextExtent);
3007 status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
3008 if (status == MagickFalse)
3010 (void) RelinquishUniqueFileResource(filename);
3011 image=DestroyImage(image);
3012 return(MagickFalse);
3014 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
3015 image_info->temporary=MagickTrue;
3017 (void) memset(magick,0,
sizeof(magick));
3018 count=ReadBlob(image,2*MaxTextExtent,magick);
3019 (void) SeekBlob(image,-((MagickOffsetType) count),SEEK_CUR);
3020 (void) CloseBlob(image);
3021 image=DestroyImage(image);
3025 sans_exception=AcquireExceptionInfo();
3026 magic_info=GetMagicInfo(magick,(
size_t) count,sans_exception);
3027 if ((magic_info != (
const MagicInfo *) NULL) &&
3028 (GetMagicName(magic_info) != (
char *) NULL))
3030 (void) CopyMagickString(image_info->magick,GetMagicName(magic_info),
3032 magick_info=GetMagickInfo(image_info->magick,sans_exception);
3033 if ((magick_info == (
const MagickInfo *) NULL) ||
3034 (GetMagickEndianSupport(magick_info) == MagickFalse))
3035 image_info->endian=UndefinedEndian;
3036 sans_exception=DestroyExceptionInfo(sans_exception);
3039 magick_info=GetMagickInfo(image_info->magick,sans_exception);
3040 if ((magick_info == (
const MagickInfo *) NULL) ||
3041 (GetMagickEndianSupport(magick_info) == MagickFalse))
3042 image_info->endian=UndefinedEndian;
3043 sans_exception=DestroyExceptionInfo(sans_exception);
3075 MagickExport
void SetImageInfoBlob(
ImageInfo *image_info,
const void *blob,
3076 const size_t length)
3078 assert(image_info != (
ImageInfo *) NULL);
3079 assert(image_info->signature == MagickCoreSignature);
3080 if (IsEventLogging() != MagickFalse)
3081 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
3082 image_info->filename);
3083 image_info->blob=(
void *) blob;
3084 image_info->length=length;
3111 MagickExport
void SetImageInfoFile(
ImageInfo *image_info,FILE *file)
3113 assert(image_info != (
ImageInfo *) NULL);
3114 assert(image_info->signature == MagickCoreSignature);
3115 if (IsEventLogging() != MagickFalse)
3116 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
3117 image_info->filename);
3118 image_info->file=file;
3146 MagickExport MagickBooleanType SetImageMask(
Image *image,
const Image *mask)
3148 assert(image != (
Image *) NULL);
3149 assert(image->signature == MagickCoreSignature);
3150 if (IsEventLogging() != MagickFalse)
3151 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
3152 if (mask != (
const Image *) NULL)
3153 if ((mask->columns != image->columns) || (mask->rows != image->rows))
3154 ThrowBinaryImageException(ImageError,
"ImageSizeDiffers",image->filename);
3155 if (image->mask != (
Image *) NULL)
3156 image->mask=DestroyImage(image->mask);
3157 image->mask=NewImageList();
3158 if (mask == (
Image *) NULL)
3160 if (SetImageStorageClass(image,DirectClass) == MagickFalse)
3161 return(MagickFalse);
3162 image->mask=CloneImage(mask,0,0,MagickTrue,&image->exception);
3163 if (image->mask == (
Image *) NULL)
3164 return(MagickFalse);
3193 MagickExport MagickBooleanType SetImageOpacity(
Image *image,
3194 const Quantum opacity)
3208 assert(image != (
Image *) NULL);
3209 assert(image->signature == MagickCoreSignature);
3210 if (IsEventLogging() != MagickFalse)
3211 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
3212 image->matte=MagickTrue;
3214 exception=(&image->exception);
3215 image_view=AcquireAuthenticCacheView(image,exception);
3216 #if defined(MAGICKCORE_OPENMP_SUPPORT)
3217 #pragma omp parallel for schedule(static) shared(status) \
3218 magick_number_threads(image,image,image->rows,1)
3220 for (y=0; y < (ssize_t) image->rows; y++)
3228 if (status == MagickFalse)
3230 q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
3236 for (x=0; x < (ssize_t) image->columns; x++)
3238 SetPixelOpacity(q,opacity);
3241 if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
3244 image_view=DestroyCacheView(image_view);
3275 MagickExport VirtualPixelMethod SetImageVirtualPixelMethod(
const Image *image,
3276 const VirtualPixelMethod virtual_pixel_method)
3278 assert(image != (
const Image *) NULL);
3279 assert(image->signature == MagickCoreSignature);
3280 if (IsEventLogging() != MagickFalse)
3281 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
3282 return(SetPixelCacheVirtualMethod(image,virtual_pixel_method));
3320 static ssize_t SmushXGap(
const Image *smush_image,
const Image *images,
3348 if (images->previous == (
Image *) NULL)
3351 SetGeometry(smush_image,&right_geometry);
3352 GravityAdjustGeometry(right_image->columns,right_image->rows,
3353 right_image->gravity,&right_geometry);
3354 left_image=images->previous;
3355 SetGeometry(smush_image,&left_geometry);
3356 GravityAdjustGeometry(left_image->columns,left_image->rows,
3357 left_image->gravity,&left_geometry);
3358 gap=right_image->columns;
3359 left_view=AcquireVirtualCacheView(left_image,exception);
3360 right_view=AcquireVirtualCacheView(right_image,exception);
3361 for (y=0; y < (ssize_t) smush_image->rows; y++)
3363 for (x=(ssize_t) left_image->columns-1; x > 0; x--)
3365 p=GetCacheViewVirtualPixels(left_view,x,left_geometry.y+y,1,1,exception);
3367 (GetPixelOpacity(p) != TransparentOpacity) ||
3368 ((left_image->columns-x-1) >= gap))
3371 i=(ssize_t) left_image->columns-x-1;
3372 for (x=0; x < (ssize_t) right_image->columns; x++)
3374 p=GetCacheViewVirtualPixels(right_view,x,right_geometry.y+y,1,1,
3377 (GetPixelOpacity(p) != TransparentOpacity) ||
3378 ((x+i) >= (ssize_t) gap))
3381 if ((x+i) < (ssize_t) gap)
3384 right_view=DestroyCacheView(right_view);
3385 left_view=DestroyCacheView(left_view);
3386 if (y < (ssize_t) smush_image->rows)
3388 return((ssize_t) gap-offset);
3391 static ssize_t SmushYGap(
const Image *smush_image,
const Image *images,
3419 if (images->previous == (
Image *) NULL)
3421 bottom_image=images;
3422 SetGeometry(smush_image,&bottom_geometry);
3423 GravityAdjustGeometry(bottom_image->columns,bottom_image->rows,
3424 bottom_image->gravity,&bottom_geometry);
3425 top_image=images->previous;
3426 SetGeometry(smush_image,&top_geometry);
3427 GravityAdjustGeometry(top_image->columns,top_image->rows,top_image->gravity,
3429 gap=bottom_image->rows;
3430 top_view=AcquireVirtualCacheView(top_image,exception);
3431 bottom_view=AcquireVirtualCacheView(bottom_image,exception);
3432 for (x=0; x < (ssize_t) smush_image->columns; x++)
3434 for (y=(ssize_t) top_image->rows-1; y > 0; y--)
3436 p=GetCacheViewVirtualPixels(top_view,top_geometry.x+x,y,1,1,exception);
3438 (GetPixelOpacity(p) != TransparentOpacity) ||
3439 ((top_image->rows-y-1) >= gap))
3442 i=(ssize_t) top_image->rows-y-1;
3443 for (y=0; y < (ssize_t) bottom_image->rows; y++)
3445 p=GetCacheViewVirtualPixels(bottom_view,bottom_geometry.x+x,y,1,1,
3448 (GetPixelOpacity(p) != TransparentOpacity) ||
3449 ((y+i) >= (ssize_t) gap))
3452 if ((y+i) < (ssize_t) gap)
3455 bottom_view=DestroyCacheView(bottom_view);
3456 top_view=DestroyCacheView(top_view);
3457 if (x < (ssize_t) smush_image->columns)
3459 return((ssize_t) gap-offset);
3462 MagickExport
Image *SmushImages(
const Image *images,
3463 const MagickBooleanType stack,
const ssize_t offset,
ExceptionInfo *exception)
3465 #define SmushImageTag "Smush/Image"
3502 assert(images != (
Image *) NULL);
3503 assert(images->signature == MagickCoreSignature);
3505 assert(exception->signature == MagickCoreSignature);
3506 if (IsEventLogging() != MagickFalse)
3507 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",images->filename);
3511 width=image->columns;
3513 next=GetNextImageInList(image);
3514 for ( ; next != (
Image *) NULL; next=GetNextImageInList(next))
3516 if (next->matte != MagickFalse)
3519 if (stack != MagickFalse)
3521 if (next->columns > width)
3522 width=next->columns;
3524 if (next->previous != (
Image *) NULL)
3528 width+=next->columns;
3529 if (next->previous != (
Image *) NULL)
3531 if (next->rows > height)
3537 smush_image=CloneImage(image,width,height,MagickTrue,exception);
3538 if (smush_image == (
Image *) NULL)
3539 return((
Image *) NULL);
3540 if (SetImageStorageClass(smush_image,DirectClass) == MagickFalse)
3542 InheritException(exception,&smush_image->exception);
3543 smush_image=DestroyImage(smush_image);
3544 return((
Image *) NULL);
3546 smush_image->matte=matte;
3547 (void) SetImageBackgroundColor(smush_image);
3551 smush_view=AcquireVirtualCacheView(smush_image,exception);
3552 for (n=0; n < (MagickOffsetType) number_images; n++)
3554 SetGeometry(smush_image,&geometry);
3555 GravityAdjustGeometry(image->columns,image->rows,image->gravity,&geometry);
3556 if (stack != MagickFalse)
3558 x_offset-=geometry.x;
3559 y_offset-=SmushYGap(smush_image,image,offset,exception);
3563 x_offset-=SmushXGap(smush_image,image,offset,exception);
3564 y_offset-=geometry.y;
3566 status=CompositeImage(smush_image,OverCompositeOp,image,x_offset,y_offset);
3567 proceed=SetImageProgress(image,SmushImageTag,n,number_images);
3568 if (proceed == MagickFalse)
3570 if (stack == MagickFalse)
3572 x_offset+=(ssize_t) image->columns;
3578 y_offset+=(ssize_t) image->rows;
3580 image=GetNextImageInList(image);
3582 if (stack == MagickFalse)
3583 smush_image->columns=(size_t) x_offset;
3585 smush_image->rows=(size_t) y_offset;
3586 smush_view=DestroyCacheView(smush_view);
3587 if (status == MagickFalse)
3588 smush_image=DestroyImage(smush_image);
3589 return(smush_image);
3614 MagickExport MagickBooleanType StripImage(
Image *image)
3619 assert(image != (
Image *) NULL);
3620 if (IsEventLogging() != MagickFalse)
3621 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
3622 DestroyImageProfiles(image);
3623 (void) DeleteImageProperty(image,
"comment");
3624 (void) DeleteImageProperty(image,
"date:create");
3625 (void) DeleteImageProperty(image,
"date:modify");
3626 status=SetImageArtifact(image,
"png:exclude-chunk",
3627 "bKGD,caNv,cHRM,eXIf,gAMA,iCCP,iTXt,pHYs,sRGB,tEXt,zCCP,zTXt,date");
3655 static inline IndexPacket PushColormapIndex(
Image *image,
3656 const size_t index,MagickBooleanType *range_exception)
3658 if (index < image->colors)
3659 return((IndexPacket) index);
3660 *range_exception=MagickTrue;
3661 return((IndexPacket) 0);
3664 MagickExport MagickBooleanType SyncImage(
Image *image)
3680 assert(image != (
Image *) NULL);
3681 assert(image->signature == MagickCoreSignature);
3682 if (IsEventLogging() != MagickFalse)
3683 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
3684 if (image->ping != MagickFalse)
3686 if (image->storage_class != PseudoClass)
3687 return(MagickFalse);
3689 range_exception=MagickFalse;
3692 exception=(&image->exception);
3693 image_view=AcquireAuthenticCacheView(image,exception);
3694 #if defined(MAGICKCORE_OPENMP_SUPPORT)
3695 #pragma omp parallel for schedule(static) shared(range_exception,status) \
3696 magick_number_threads(image,image,image->rows,1)
3698 for (y=0; y < (ssize_t) image->rows; y++)
3704 *magick_restrict indexes;
3712 if (status == MagickFalse)
3714 q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
3720 indexes=GetCacheViewAuthenticIndexQueue(image_view);
3721 for (x=0; x < (ssize_t) image->columns; x++)
3723 index=PushColormapIndex(image,(
size_t) GetPixelIndex(indexes+x),
3725 if (image->matte == MagickFalse)
3726 SetPixelRgb(q,image->colormap+(ssize_t) index)
3728 SetPixelRGBO(q,image->colormap+(ssize_t) index);
3731 if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
3734 image_view=DestroyCacheView(image_view);
3736 if ((image->ping == MagickFalse) && (range_exception != MagickFalse))
3737 (void) ThrowMagickException(&image->exception,GetMagickModule(),
3738 CorruptImageWarning,
"InvalidColormapIndex",
"`%s'",image->filename);
3770 MagickExport MagickBooleanType SyncImagesSettings(
ImageInfo *image_info,
3776 assert(image_info != (
const ImageInfo *) NULL);
3777 assert(image_info->signature == MagickCoreSignature);
3778 assert(images != (
Image *) NULL);
3779 assert(images->signature == MagickCoreSignature);
3780 if (IsEventLogging() != MagickFalse)
3781 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",images->filename);
3783 for ( ; image != (
Image *) NULL; image=GetNextImageInList(image))
3784 (
void) SyncImageSettings(image_info,image);
3785 (void) DeleteImageOption(image_info,
"page");
3789 MagickExport MagickBooleanType SyncImageSettings(
const ImageInfo *image_info,
3793 property[MaxTextExtent];
3811 assert(image_info != (
const ImageInfo *) NULL);
3812 assert(image_info->signature == MagickCoreSignature);
3813 assert(image != (
Image *) NULL);
3814 assert(image->signature == MagickCoreSignature);
3815 if (IsEventLogging() != MagickFalse)
3816 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
3817 option=GetImageOption(image_info,
"background");
3818 if (option != (
const char *) NULL)
3819 (void) QueryColorDatabase(option,&image->background_color,
3821 option=GetImageOption(image_info,
"bias");
3822 if (option != (
const char *) NULL)
3823 image->bias=StringToDoubleInterval(option,(
double) QuantumRange+1.0);
3824 option=GetImageOption(image_info,
"black-point-compensation");
3825 if (option != (
const char *) NULL)
3826 image->black_point_compensation=(MagickBooleanType) ParseCommandOption(
3827 MagickBooleanOptions,MagickFalse,option);
3828 option=GetImageOption(image_info,
"blue-primary");
3829 if (option != (
const char *) NULL)
3831 flags=ParseGeometry(option,&geometry_info);
3832 if ((flags & RhoValue) != 0)
3833 image->chromaticity.blue_primary.x=geometry_info.rho;
3834 image->chromaticity.blue_primary.y=image->chromaticity.blue_primary.x;
3835 if ((flags & SigmaValue) != 0)
3836 image->chromaticity.blue_primary.y=geometry_info.sigma;
3838 option=GetImageOption(image_info,
"bordercolor");
3839 if (option != (
const char *) NULL)
3840 (void) QueryColorDatabase(option,&image->border_color,&image->exception);
3841 option=GetImageOption(image_info,
"colors");
3842 if (option != (
const char *) NULL)
3843 image->colors=StringToUnsignedLong(option);
3844 option=GetImageOption(image_info,
"compose");
3845 if (option != (
const char *) NULL)
3846 image->compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
3847 MagickFalse,option);
3848 option=GetImageOption(image_info,
"compress");
3849 if (option != (
const char *) NULL)
3850 image->compression=(CompressionType) ParseCommandOption(
3851 MagickCompressOptions,MagickFalse,option);
3852 option=GetImageOption(image_info,
"debug");
3853 if (option != (
const char *) NULL)
3854 image->debug=(MagickBooleanType) ParseCommandOption(MagickBooleanOptions,
3855 MagickFalse,option);
3856 option=GetImageOption(image_info,
"density");
3857 if (option != (
const char *) NULL)
3865 flags=ParseGeometry(option,&geometry_info);
3866 if ((flags & RhoValue) != 0)
3867 image->x_resolution=geometry_info.rho;
3868 image->y_resolution=image->x_resolution;
3869 if ((flags & SigmaValue) != 0)
3870 image->y_resolution=geometry_info.sigma;
3872 option=GetImageOption(image_info,
"depth");
3873 if (option != (
const char *) NULL)
3874 image->depth=StringToUnsignedLong(option);
3875 option=GetImageOption(image_info,
"endian");
3876 if (option != (
const char *) NULL)
3877 image->endian=(EndianType) ParseCommandOption(MagickEndianOptions,
3878 MagickFalse,option);
3879 option=GetImageOption(image_info,
"filter");
3880 if (option != (
const char *) NULL)
3881 image->filter=(FilterTypes) ParseCommandOption(MagickFilterOptions,
3882 MagickFalse,option);
3883 option=GetImageOption(image_info,
"fuzz");
3884 if (option != (
const char *) NULL)
3885 image->fuzz=StringToDoubleInterval(option,(
double) QuantumRange+1.0);
3886 option=GetImageOption(image_info,
"gravity");
3887 if (option != (
const char *) NULL)
3888 image->gravity=(GravityType) ParseCommandOption(MagickGravityOptions,
3889 MagickFalse,option);
3890 option=GetImageOption(image_info,
"green-primary");
3891 if (option != (
const char *) NULL)
3893 flags=ParseGeometry(option,&geometry_info);
3894 if ((flags & RhoValue) != 0)
3895 image->chromaticity.green_primary.x=geometry_info.rho;
3896 image->chromaticity.green_primary.y=image->chromaticity.green_primary.x;
3897 if ((flags & SigmaValue) != 0)
3898 image->chromaticity.green_primary.y=geometry_info.sigma;
3900 option=GetImageOption(image_info,
"intensity");
3901 if (option != (
const char *) NULL)
3902 image->intensity=(PixelIntensityMethod) ParseCommandOption(
3903 MagickPixelIntensityOptions,MagickFalse,option);
3904 option=GetImageOption(image_info,
"intent");
3905 if (option != (
const char *) NULL)
3906 image->rendering_intent=(RenderingIntent) ParseCommandOption(
3907 MagickIntentOptions,MagickFalse,option);
3908 option=GetImageOption(image_info,
"interlace");
3909 if (option != (
const char *) NULL)
3910 image->interlace=(InterlaceType) ParseCommandOption(MagickInterlaceOptions,
3911 MagickFalse,option);
3912 option=GetImageOption(image_info,
"interpolate");
3913 if (option != (
const char *) NULL)
3914 image->interpolate=(InterpolatePixelMethod) ParseCommandOption(
3915 MagickInterpolateOptions,MagickFalse,option);
3916 option=GetImageOption(image_info,
"loop");
3917 if (option != (
const char *) NULL)
3918 image->iterations=StringToUnsignedLong(option);
3919 option=GetImageOption(image_info,
"mattecolor");
3920 if (option != (
const char *) NULL)
3921 (void) QueryColorDatabase(option,&image->matte_color,&image->exception);
3922 option=GetImageOption(image_info,
"orient");
3923 if (option != (
const char *) NULL)
3924 image->orientation=(OrientationType) ParseCommandOption(
3925 MagickOrientationOptions,MagickFalse,option);
3926 option=GetImageOption(image_info,
"page");
3927 if (option != (
const char *) NULL)
3932 geometry=GetPageGeometry(option);
3933 flags=ParseAbsoluteGeometry(geometry,&image->page);
3934 geometry=DestroyString(geometry);
3936 option=GetImageOption(image_info,
"quality");
3937 if (option != (
const char *) NULL)
3938 image->quality=StringToUnsignedLong(option);
3939 option=GetImageOption(image_info,
"red-primary");
3940 if (option != (
const char *) NULL)
3942 flags=ParseGeometry(option,&geometry_info);
3943 if ((flags & RhoValue) != 0)
3944 image->chromaticity.red_primary.x=geometry_info.rho;
3945 image->chromaticity.red_primary.y=image->chromaticity.red_primary.x;
3946 if ((flags & SigmaValue) != 0)
3947 image->chromaticity.red_primary.y=geometry_info.sigma;
3949 if (image_info->quality != UndefinedCompressionQuality)
3950 image->quality=image_info->quality;
3951 option=GetImageOption(image_info,
"scene");
3952 if (option != (
const char *) NULL)
3953 image->scene=StringToUnsignedLong(option);
3954 option=GetImageOption(image_info,
"taint");
3955 if (option != (
const char *) NULL)
3956 image->taint=(MagickBooleanType) ParseCommandOption(MagickBooleanOptions,
3957 MagickFalse,option);
3958 option=GetImageOption(image_info,
"tile-offset");
3959 if (option != (
const char *) NULL)
3964 geometry=GetPageGeometry(option);
3965 flags=ParseAbsoluteGeometry(geometry,&image->tile_offset);
3966 geometry=DestroyString(geometry);
3968 option=GetImageOption(image_info,
"transparent-color");
3969 if (option != (
const char *) NULL)
3970 (void) QueryColorDatabase(option,&image->transparent_color,
3972 option=GetImageOption(image_info,
"type");
3973 if (option != (
const char *) NULL)
3974 image->type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3976 option=GetImageOption(image_info,
"units");
3977 units=image_info->units;
3978 if (option != (
const char *) NULL)
3979 units=(ResolutionType) ParseCommandOption(MagickResolutionOptions,
3980 MagickFalse,option);
3981 if (units != UndefinedResolution)
3983 if (image->units != units)
3984 switch (image->units)
3986 case PixelsPerInchResolution:
3988 if (units == PixelsPerCentimeterResolution)
3990 image->x_resolution/=2.54;
3991 image->y_resolution/=2.54;
3995 case PixelsPerCentimeterResolution:
3997 if (units == PixelsPerInchResolution)
3999 image->x_resolution=(double) ((
size_t) (100.0*2.54*
4000 image->x_resolution+0.5))/100.0;
4001 image->y_resolution=(double) ((
size_t) (100.0*2.54*
4002 image->y_resolution+0.5))/100.0;
4010 option=GetImageOption(image_info,
"density");
4011 if (option != (
const char *) NULL)
4013 flags=ParseGeometry(option,&geometry_info);
4014 if ((flags & RhoValue) != 0)
4015 image->x_resolution=geometry_info.rho;
4016 image->y_resolution=image->x_resolution;
4017 if ((flags & SigmaValue) != 0)
4018 image->y_resolution=geometry_info.sigma;
4021 option=GetImageOption(image_info,
"white-point");
4022 if (option != (
const char *) NULL)
4024 flags=ParseGeometry(option,&geometry_info);
4025 if ((flags & RhoValue) != 0)
4026 image->chromaticity.white_point.x=geometry_info.rho;
4027 image->chromaticity.white_point.y=image->chromaticity.white_point.x;
4028 if ((flags & SigmaValue) != 0)
4029 image->chromaticity.white_point.y=geometry_info.sigma;
4031 ResetImageOptionIterator(image_info);
4032 for (option=GetNextImageOption(image_info); option != (
const char *) NULL; )
4034 value=GetImageOption(image_info,option);
4035 if (value != (
const char *) NULL)
4037 (void) FormatLocaleString(property,MaxTextExtent,
"%s",option);
4038 (void) SetImageArtifact(image,property,value);
4040 option=GetNextImageOption(image_info);