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->ttl=(time_t) GetMagickResourceLimit(TimeResource);
185 image->debug=(GetLogEventMask() & (ImageEvent | TransformEvent | CoderEvent))
186 != 0 ? MagickTrue : MagickFalse;
187 image->reference_count=1;
188 image->semaphore=AllocateSemaphoreInfo();
189 image->signature=MagickCoreSignature;
195 SetBlobExempt(image,image_info->file != (FILE *) NULL ? MagickTrue :
197 (void) CopyMagickString(image->filename,image_info->filename,MaxTextExtent);
198 (void) CopyMagickString(image->magick_filename,image_info->filename,
200 (void) CopyMagickString(image->magick,image_info->magick,MaxTextExtent);
201 if (image_info->size != (
char *) NULL)
203 (void) ParseAbsoluteGeometry(image_info->size,&image->extract_info);
204 image->columns=image->extract_info.width;
205 image->rows=image->extract_info.height;
206 image->offset=image->extract_info.x;
207 image->extract_info.x=0;
208 image->extract_info.y=0;
210 if (image_info->extract != (
char *) NULL)
215 (void) memset(&geometry,0,
sizeof(geometry));
216 flags=ParseAbsoluteGeometry(image_info->extract,&geometry);
217 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
219 image->extract_info=geometry;
220 Swap(image->columns,image->extract_info.width);
221 Swap(image->rows,image->extract_info.height);
224 image->compression=image_info->compression;
225 image->quality=image_info->quality;
226 image->endian=image_info->endian;
227 image->interlace=image_info->interlace;
228 image->units=image_info->units;
229 if (image_info->density != (
char *) NULL)
234 flags=ParseGeometry(image_info->density,&geometry_info);
235 if ((flags & RhoValue) != 0)
236 image->x_resolution=geometry_info.rho;
237 image->y_resolution=image->x_resolution;
238 if ((flags & SigmaValue) != 0)
239 image->y_resolution=geometry_info.sigma;
241 if (image_info->page != (
char *) NULL)
246 image->page=image->extract_info;
247 geometry=GetPageGeometry(image_info->page);
248 (void) ParseAbsoluteGeometry(geometry,&image->page);
249 geometry=DestroyString(geometry);
251 if (image_info->depth != 0)
252 image->depth=image_info->depth;
253 image->dither=image_info->dither;
254 image->background_color=image_info->background_color;
255 image->border_color=image_info->border_color;
256 image->matte_color=image_info->matte_color;
257 image->transparent_color=image_info->transparent_color;
258 image->ping=image_info->ping;
259 image->progress_monitor=image_info->progress_monitor;
260 image->client_data=image_info->client_data;
261 if (image_info->cache != (
void *) NULL)
262 ClonePixelCacheMethods(image->cache,image_info->cache);
263 (void) SyncImageSettings(image_info,image);
264 option=GetImageOption(image_info,
"delay");
265 if (option != (
const char *) NULL)
270 flags=ParseGeometry(option,&geometry_info);
271 if ((flags & GreaterValue) != 0)
273 if ((
double) image->delay > floor(geometry_info.rho+0.5))
274 image->delay=(size_t) CastDoubleToLong(floor(
275 geometry_info.rho+0.5));
278 if ((flags & LessValue) != 0)
280 if ((
double) image->delay < floor(geometry_info.rho+0.5))
281 image->ticks_per_second=CastDoubleToLong(floor(
282 geometry_info.sigma+0.5));
285 image->delay=(size_t) CastDoubleToLong(floor(
286 geometry_info.rho+0.5));
287 if ((flags & SigmaValue) != 0)
288 image->ticks_per_second=CastDoubleToLong(floor(
289 geometry_info.sigma+0.5));
291 option=GetImageOption(image_info,
"dispose");
292 if (option != (
const char *) NULL)
293 image->dispose=(DisposeType) ParseCommandOption(MagickDisposeOptions,
316MagickExport
ImageInfo *AcquireImageInfo(
void)
321 image_info=(
ImageInfo *) AcquireMagickMemory(
sizeof(*image_info));
323 ThrowFatalException(ResourceLimitFatalError,
"MemoryAllocationFailed");
324 GetImageInfo(image_info);
356MagickExport
void AcquireNextImage(
const ImageInfo *image_info,
Image *image)
361 assert(image != (
Image *) NULL);
362 assert(image->signature == MagickCoreSignature);
363 if (IsEventLogging() != MagickFalse)
364 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
365 image->next=AcquireImage(image_info);
366 if (GetNextImageInList(image) == (
Image *) NULL)
368 (void) CopyMagickString(GetNextImageInList(image)->filename,image->filename,
371 (
void) CopyMagickString(GetNextImageInList(image)->filename,
372 image_info->filename,MaxTextExtent);
373 DestroyBlob(GetNextImageInList(image));
374 image->next->blob=ReferenceBlob(image->blob);
375 image->next->endian=image->endian;
376 image->next->scene=image->scene+1;
377 image->next->previous=image;
412MagickExport
Image *AppendImages(
const Image *images,
415#define AppendImageTag "Append/Image"
424 homogeneous_colorspace,
451 assert(images != (
Image *) NULL);
452 assert(images->signature == MagickCoreSignature);
454 assert(exception->signature == MagickCoreSignature);
455 if (IsEventLogging() != MagickFalse)
456 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",images->filename);
459 width=images->columns;
462 homogeneous_colorspace=MagickTrue;
463 next=GetNextImageInList(images);
464 for ( ; next != (
Image *) NULL; next=GetNextImageInList(next))
466 if (next->depth > depth)
468 if (next->colorspace != images->colorspace)
469 homogeneous_colorspace=MagickFalse;
470 if (next->matte != MagickFalse)
473 if (stack != MagickFalse)
475 if (next->columns > width)
480 width+=next->columns;
481 if (next->rows > height)
487 append_image=CloneImage(images,width,height,MagickTrue,exception);
488 if (append_image == (
Image *) NULL)
489 return((
Image *) NULL);
490 if (SetImageStorageClass(append_image,DirectClass) == MagickFalse)
492 InheritException(exception,&append_image->exception);
493 append_image=DestroyImage(append_image);
494 return((
Image *) NULL);
496 if (homogeneous_colorspace == MagickFalse)
497 (void) SetImageColorspace(append_image,sRGBColorspace);
498 append_image->depth=depth;
499 append_image->matte=matte;
500 append_image->page=images->page;
501 (void) SetImageBackgroundColor(append_image);
506 append_view=AcquireAuthenticCacheView(append_image,exception);
507 for (n=0; n < (MagickOffsetType) number_images; n++)
515 SetGeometry(append_image,&geometry);
516 GravityAdjustGeometry(next->columns,next->rows,next->gravity,&geometry);
517 if (stack != MagickFalse)
518 x_offset-=geometry.x;
520 y_offset-=geometry.y;
521 image_view=AcquireVirtualCacheView(next,exception);
522#if defined(MAGICKCORE_OPENMP_SUPPORT)
523 #pragma omp parallel for schedule(static) shared(status) \
524 magick_number_threads(next,next,next->rows,2)
526 for (y=0; y < (ssize_t) next->rows; y++)
529 *magick_restrict indexes;
535 *magick_restrict append_indexes;
546 if (status == MagickFalse)
548 p=GetCacheViewVirtualPixels(image_view,0,y,next->columns,1,exception);
549 q=QueueCacheViewAuthenticPixels(append_view,x_offset,y+y_offset,
550 next->columns,1,exception);
556 indexes=GetCacheViewVirtualIndexQueue(image_view);
557 append_indexes=GetCacheViewAuthenticIndexQueue(append_view);
558 for (x=0; x < (ssize_t) next->columns; x++)
560 SetPixelRed(q,GetPixelRed(p));
561 SetPixelGreen(q,GetPixelGreen(p));
562 SetPixelBlue(q,GetPixelBlue(p));
563 SetPixelOpacity(q,OpaqueOpacity);
564 if (next->matte != MagickFalse)
565 SetPixelOpacity(q,GetPixelOpacity(p));
566 if ((next->colorspace == CMYKColorspace) &&
567 (append_image->colorspace == CMYKColorspace))
568 SetPixelIndex(append_indexes+x,GetPixelIndex(indexes+x));
572 sync=SyncCacheViewAuthenticPixels(append_view,exception);
573 if (sync == MagickFalse)
576 image_view=DestroyCacheView(image_view);
577 if (stack == MagickFalse)
579 x_offset+=(ssize_t) next->columns;
585 y_offset+=(ssize_t) next->rows;
587 proceed=SetImageProgress(append_image,AppendImageTag,n,number_images);
588 if (proceed == MagickFalse)
590 next=GetNextImageInList(next);
592 append_view=DestroyCacheView(append_view);
593 if (status == MagickFalse)
594 append_image=DestroyImage(append_image);
595 return(append_image);
622MagickExport ExceptionType CatchImageException(
Image *image)
630 assert(image != (
const Image *) NULL);
631 assert(image->signature == MagickCoreSignature);
632 if (IsEventLogging() != MagickFalse)
633 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
634 exception=AcquireExceptionInfo();
635 GetImageException(image,exception);
636 CatchException(exception);
637 severity=exception->severity;
638 exception=DestroyExceptionInfo(exception);
673MagickExport MagickBooleanType ClipImage(
Image *image)
675 return(ClipImagePath(image,
"#1",MagickTrue));
678MagickExport MagickBooleanType ClipImagePath(
Image *image,
const char *pathname,
679 const MagickBooleanType inside)
681#define ClipImagePathTag "ClipPath/Image"
695 assert(image != (
const Image *) NULL);
696 assert(image->signature == MagickCoreSignature);
697 assert(pathname != NULL);
698 if (IsEventLogging() != MagickFalse)
699 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
700 property=AcquireString(pathname);
701 (void) FormatLocaleString(property,MaxTextExtent,
"8BIM:1999,2998:%s",
703 value=GetImageProperty(image,property);
704 property=DestroyString(property);
705 if (value == (
const char *) NULL)
707 ThrowFileException(&image->exception,OptionError,
"NoClipPathDefined",
711 image_info=AcquireImageInfo();
712 (void) CopyMagickString(image_info->filename,image->filename,MaxTextExtent);
713 (void) ConcatenateMagickString(image_info->filename,pathname,MaxTextExtent);
714 clip_mask=BlobToImage(image_info,value,strlen(value),&image->exception);
715 image_info=DestroyImageInfo(image_info);
716 if (clip_mask == (
Image *) NULL)
718 if (clip_mask->storage_class == PseudoClass)
720 (void) SyncImage(clip_mask);
721 if (SetImageStorageClass(clip_mask,DirectClass) == MagickFalse)
724 if (inside == MagickFalse)
725 (void) NegateImage(clip_mask,MagickFalse);
726 (void) FormatLocaleString(clip_mask->magick_filename,MaxTextExtent,
727 "8BIM:1999,2998:%s\nPS",pathname);
728 (void) SetImageClipMask(image,clip_mask);
729 clip_mask=DestroyImage(clip_mask);
772MagickExport
Image *CloneImage(
const Image *image,
const size_t columns,
773 const size_t rows,
const MagickBooleanType detach,
ExceptionInfo *exception)
788 assert(image != (
const Image *) NULL);
789 assert(image->signature == MagickCoreSignature);
791 assert(exception->signature == MagickCoreSignature);
792 if (IsEventLogging() != MagickFalse)
793 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
794 if ((image->columns == 0) || (image->rows == 0))
796 (void) ThrowMagickException(exception,GetMagickModule(),CorruptImageError,
797 "NegativeOrZeroImageSize",
"`%s'",image->filename);
798 return((
Image *) NULL);
800 clone_image=(
Image *) AcquireCriticalMemory(
sizeof(*clone_image));
801 (void) memset(clone_image,0,
sizeof(*clone_image));
802 clone_image->signature=MagickCoreSignature;
803 clone_image->storage_class=image->storage_class;
804 clone_image->channels=image->channels;
805 clone_image->colorspace=image->colorspace;
806 clone_image->matte=image->matte;
807 clone_image->columns=image->columns;
808 clone_image->rows=image->rows;
809 clone_image->dither=image->dither;
810 (void) CloneImageProfiles(clone_image,image);
811 (void) CloneImageProperties(clone_image,image);
812 (void) CloneImageArtifacts(clone_image,image);
813 GetTimerInfo(&clone_image->timer);
814 InitializeExceptionInfo(&clone_image->exception);
815 InheritException(&clone_image->exception,&image->exception);
816 if (image->ascii85 != (
void *) NULL)
817 Ascii85Initialize(clone_image);
818 clone_image->extent=image->extent;
819 clone_image->magick_columns=image->magick_columns;
820 clone_image->magick_rows=image->magick_rows;
821 clone_image->type=image->type;
822 (void) CopyMagickString(clone_image->magick_filename,image->magick_filename,
824 (void) CopyMagickString(clone_image->magick,image->magick,MaxTextExtent);
825 (void) CopyMagickString(clone_image->filename,image->filename,MaxTextExtent);
826 clone_image->progress_monitor=image->progress_monitor;
827 clone_image->client_data=image->client_data;
828 clone_image->reference_count=1;
829 clone_image->next=image->next;
830 clone_image->previous=image->previous;
831 clone_image->list=NewImageList();
832 clone_image->clip_mask=NewImageList();
833 clone_image->mask=NewImageList();
834 if (detach == MagickFalse)
835 clone_image->blob=ReferenceBlob(image->blob);
838 clone_image->next=NewImageList();
839 clone_image->previous=NewImageList();
840 clone_image->blob=CloneBlobInfo((
BlobInfo *) NULL);
842 clone_image->ping=image->ping;
843 clone_image->timestamp=image->timestamp;
844 clone_image->ttl=image->ttl;
845 clone_image->debug=image->debug;
846 clone_image->semaphore=AllocateSemaphoreInfo();
852 clone_image->colors=image->colors;
853 length=(size_t) image->colors;
854 clone_image->colormap=(
PixelPacket *) AcquireQuantumMemory(length+1,
855 sizeof(*clone_image->colormap));
858 clone_image=DestroyImage(clone_image);
859 ThrowImageException(ResourceLimitError,
"MemoryAllocationFailed");
861 (void) memcpy(clone_image->colormap,image->colormap,length*
862 sizeof(*clone_image->colormap));
864 if ((columns == 0) || (rows == 0))
866 if (image->montage != (
char *) NULL)
867 (
void) CloneString(&clone_image->montage,image->montage);
868 if (image->directory != (
char *) NULL)
869 (void) CloneString(&clone_image->directory,image->directory);
870 if (image->clip_mask != (
Image *) NULL)
871 clone_image->clip_mask=CloneImage(image->clip_mask,0,0,MagickTrue,
873 if (image->mask != (
Image *) NULL)
874 clone_image->mask=CloneImage(image->mask,0,0,MagickTrue,exception);
875 clone_image->cache=ReferencePixelCache(image->cache);
878 if ((columns == image->columns) && (rows == image->rows))
880 if (image->clip_mask != (
Image *) NULL)
881 clone_image->clip_mask=CloneImage(image->clip_mask,0,0,MagickTrue,
883 if (image->mask != (
Image *) NULL)
884 clone_image->mask=CloneImage(image->mask,0,0,MagickTrue,exception);
888 if (image->columns != 0)
889 scale_x=(double) columns/(
double) image->columns;
890 if (image->rows != 0)
891 scale_y=(double) rows/(
double) image->rows;
892 clone_image->page.width=(size_t) CastDoubleToLong(floor(scale_x*
893 image->page.width+0.5));
894 clone_image->page.height=(size_t) CastDoubleToLong(floor(scale_y*
895 image->page.height+0.5));
896 if (MagickAbsoluteValue(scale_x-scale_y) < 2.0)
897 scale_x=scale_y=MagickMin(scale_x,scale_y);
898 clone_image->page.x=CastDoubleToLong(ceil(scale_x*image->page.x-0.5));
899 clone_image->tile_offset.x=CastDoubleToLong(ceil(scale_x*
900 image->tile_offset.x-0.5));
901 clone_image->page.y=CastDoubleToLong(ceil(scale_y*image->page.y-0.5));
902 clone_image->tile_offset.y=CastDoubleToLong(ceil(scale_y*
903 image->tile_offset.y-0.5));
904 clone_image->cache=ClonePixelCache(image->cache);
905 if (SetImageExtent(clone_image,columns,rows) == MagickFalse)
907 InheritException(exception,&clone_image->exception);
908 clone_image=DestroyImage(clone_image);
942 clone_info=AcquireImageInfo();
945 clone_info->compression=image_info->compression;
946 clone_info->temporary=image_info->temporary;
947 clone_info->adjoin=image_info->adjoin;
948 clone_info->antialias=image_info->antialias;
949 clone_info->scene=image_info->scene;
950 clone_info->number_scenes=image_info->number_scenes;
951 clone_info->depth=image_info->depth;
952 if (image_info->size != (
char *) NULL)
953 (void) CloneString(&clone_info->size,image_info->size);
954 if (image_info->extract != (
char *) NULL)
955 (
void) CloneString(&clone_info->extract,image_info->extract);
956 if (image_info->scenes != (
char *) NULL)
957 (void) CloneString(&clone_info->scenes,image_info->scenes);
958 if (image_info->page != (
char *) NULL)
959 (
void) CloneString(&clone_info->page,image_info->page);
960 clone_info->interlace=image_info->interlace;
961 clone_info->endian=image_info->endian;
962 clone_info->units=image_info->units;
963 clone_info->quality=image_info->quality;
964 if (image_info->sampling_factor != (
char *) NULL)
965 (void) CloneString(&clone_info->sampling_factor,
966 image_info->sampling_factor);
967 if (image_info->server_name != (
char *) NULL)
968 (
void) CloneString(&clone_info->server_name,image_info->server_name);
969 if (image_info->font != (
char *) NULL)
970 (void) CloneString(&clone_info->font,image_info->font);
971 if (image_info->texture != (
char *) NULL)
972 (
void) CloneString(&clone_info->texture,image_info->texture);
973 if (image_info->density != (
char *) NULL)
974 (void) CloneString(&clone_info->density,image_info->density);
975 clone_info->pointsize=image_info->pointsize;
976 clone_info->fuzz=image_info->fuzz;
977 clone_info->pen=image_info->pen;
978 clone_info->background_color=image_info->background_color;
979 clone_info->border_color=image_info->border_color;
980 clone_info->matte_color=image_info->matte_color;
981 clone_info->transparent_color=image_info->transparent_color;
982 clone_info->dither=image_info->dither;
983 clone_info->monochrome=image_info->monochrome;
984 clone_info->colors=image_info->colors;
985 clone_info->colorspace=image_info->colorspace;
986 clone_info->type=image_info->type;
987 clone_info->orientation=image_info->orientation;
988 clone_info->preview_type=image_info->preview_type;
989 clone_info->group=image_info->group;
990 clone_info->ping=image_info->ping;
991 clone_info->verbose=image_info->verbose;
992 if (image_info->view != (
char *) NULL)
993 (
void) CloneString(&clone_info->view,image_info->view);
994 if (image_info->authenticate != (
char *) NULL)
995 (void) CloneString(&clone_info->authenticate,image_info->authenticate);
996 (void) CloneImageOptions(clone_info,image_info);
997 clone_info->progress_monitor=image_info->progress_monitor;
998 clone_info->client_data=image_info->client_data;
999 clone_info->cache=image_info->cache;
1000 if (image_info->cache != (
void *) NULL)
1001 clone_info->cache=ReferencePixelCache(image_info->cache);
1002 if (image_info->profile != (
void *) NULL)
1003 clone_info->profile=(
void *) CloneStringInfo((
StringInfo *)
1004 image_info->profile);
1005 SetImageInfoFile(clone_info,image_info->file);
1006 SetImageInfoBlob(clone_info,image_info->blob,image_info->length);
1007 clone_info->stream=image_info->stream;
1008 clone_info->virtual_pixel_method=image_info->virtual_pixel_method;
1009 (void) CopyMagickString(clone_info->magick,image_info->magick,MaxTextExtent);
1010 (void) CopyMagickString(clone_info->unique,image_info->unique,MaxTextExtent);
1011 (void) CopyMagickString(clone_info->zero,image_info->zero,MaxTextExtent);
1012 (void) CopyMagickString(clone_info->filename,image_info->filename,
1014 clone_info->subimage=image_info->scene;
1015 clone_info->subrange=image_info->number_scenes;
1016 clone_info->channel=image_info->channel;
1017 clone_info->debug=image_info->debug;
1018 clone_info->signature=image_info->signature;
1055MagickExport MagickBooleanType CopyImagePixels(
Image *image,
1059#define CopyImageTag "Copy/Image"
1074 assert(image != (
Image *) NULL);
1075 assert(source_image != (
Image *) NULL);
1078 if (IsEventLogging() != MagickFalse)
1079 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
1080 if ((offset->x < 0) || (offset->y < 0) ||
1081 ((offset->x+(ssize_t) geometry->width) > (ssize_t) image->columns) ||
1082 ((offset->y+(ssize_t) geometry->height) > (ssize_t) image->rows))
1083 ThrowBinaryException(OptionError,
"GeometryDoesNotContainImage",
1085 if (SetImageStorageClass(image,DirectClass) == MagickFalse)
1086 return(MagickFalse);
1092 source_view=AcquireVirtualCacheView(source_image,exception);
1093 image_view=AcquireAuthenticCacheView(image,exception);
1094#if defined(MAGICKCORE_OPENMP_SUPPORT)
1095 #pragma omp parallel for schedule(static) shared(progress,status) \
1096 magick_number_threads(source_image,image,geometry->height,2)
1098 for (y=0; y < (ssize_t) geometry->height; y++)
1101 *magick_restrict source_indexes;
1107 *magick_restrict indexes;
1115 if (status == MagickFalse)
1117 p=GetCacheViewVirtualPixels(source_view,geometry->x,y+geometry->y,
1118 geometry->width,1,exception);
1119 q=GetCacheViewAuthenticPixels(image_view,offset->x,y+offset->y,
1120 geometry->width,1,exception);
1126 source_indexes=GetCacheViewVirtualIndexQueue(source_view);
1127 indexes=GetCacheViewAuthenticIndexQueue(image_view);
1128 for (x=0; x < (ssize_t) geometry->width; x++)
1131 if (image->colorspace == CMYKColorspace)
1132 indexes[x]=source_indexes[x];
1136 if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
1138 if (image->progress_monitor != (MagickProgressMonitor) NULL)
1143#if defined(MAGICKCORE_OPENMP_SUPPORT)
1147 proceed=SetImageProgress(image,CopyImageTag,progress,image->rows);
1148 if (proceed == MagickFalse)
1152 image_view=DestroyCacheView(image_view);
1153 source_view=DestroyCacheView(source_view);
1180MagickExport
Image *DestroyImage(
Image *image)
1188 assert(image != (
Image *) NULL);
1189 assert(image->signature == MagickCoreSignature);
1190 if (IsEventLogging() != MagickFalse)
1191 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
1192 destroy=MagickFalse;
1193 LockSemaphoreInfo(image->semaphore);
1194 image->reference_count--;
1195 if (image->reference_count == 0)
1197 UnlockSemaphoreInfo(image->semaphore);
1198 if (destroy == MagickFalse)
1199 return((
Image *) NULL);
1203 DestroyImagePixels(image);
1204 if (image->clip_mask != (
Image *) NULL)
1205 image->clip_mask=DestroyImage(image->clip_mask);
1206 if (image->mask != (
Image *) NULL)
1207 image->mask=DestroyImage(image->mask);
1208 if (image->montage != (
char *) NULL)
1209 image->montage=DestroyString(image->montage);
1210 if (image->directory != (
char *) NULL)
1211 image->directory=DestroyString(image->directory);
1213 image->colormap=(
PixelPacket *) RelinquishMagickMemory(image->colormap);
1214 if (image->geometry != (
char *) NULL)
1215 image->geometry=DestroyString(image->geometry);
1216 DestroyImageProfiles(image);
1217 DestroyImageProperties(image);
1218 DestroyImageArtifacts(image);
1220 image->ascii85=(
Ascii85Info *) RelinquishMagickMemory(image->ascii85);
1222 (void) ClearExceptionInfo(&image->exception,MagickTrue);
1224 DestroySemaphoreInfo(&image->semaphore);
1225 image->signature=(~MagickCoreSignature);
1226 image=(
Image *) RelinquishMagickMemory(image);
1255 assert(image_info != (
ImageInfo *) NULL);
1256 assert(image_info->signature == MagickCoreSignature);
1257 if (IsEventLogging() != MagickFalse)
1258 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
1259 image_info->filename);
1260 if (image_info->size != (
char *) NULL)
1261 image_info->size=DestroyString(image_info->size);
1262 if (image_info->extract != (
char *) NULL)
1263 image_info->extract=DestroyString(image_info->extract);
1264 if (image_info->scenes != (
char *) NULL)
1265 image_info->scenes=DestroyString(image_info->scenes);
1266 if (image_info->page != (
char *) NULL)
1267 image_info->page=DestroyString(image_info->page);
1268 if (image_info->sampling_factor != (
char *) NULL)
1269 image_info->sampling_factor=DestroyString(
1270 image_info->sampling_factor);
1271 if (image_info->server_name != (
char *) NULL)
1272 image_info->server_name=DestroyString(
1273 image_info->server_name);
1274 if (image_info->font != (
char *) NULL)
1275 image_info->font=DestroyString(image_info->font);
1276 if (image_info->texture != (
char *) NULL)
1277 image_info->texture=DestroyString(image_info->texture);
1278 if (image_info->density != (
char *) NULL)
1279 image_info->density=DestroyString(image_info->density);
1280 if (image_info->view != (
char *) NULL)
1281 image_info->view=DestroyString(image_info->view);
1282 if (image_info->authenticate != (
char *) NULL)
1283 image_info->authenticate=DestroyString(
1284 image_info->authenticate);
1285 DestroyImageOptions(image_info);
1286 if (image_info->cache != (
void *) NULL)
1287 image_info->cache=DestroyPixelCache(image_info->cache);
1288 if (image_info->profile != (
StringInfo *) NULL)
1289 image_info->profile=(
void *) DestroyStringInfo((
StringInfo *)
1290 image_info->profile);
1291 image_info->signature=(~MagickCoreSignature);
1292 image_info=(
ImageInfo *) RelinquishMagickMemory(image_info);
1320MagickExport
void DisassociateImageStream(
Image *image)
1322 assert(image != (
Image *) NULL);
1323 assert(image->signature == MagickCoreSignature);
1324 if (IsEventLogging() != MagickFalse)
1325 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
1326 DisassociateBlob(image);
1351MagickExport
Image *GetImageClipMask(
const Image *image,
1354 assert(image != (
const Image *) NULL);
1355 assert(image->signature == MagickCoreSignature);
1356 if (IsEventLogging() != MagickFalse)
1357 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
1358 if (image->clip_mask == (
Image *) NULL)
1359 return((
Image *) NULL);
1360 return(CloneImage(image->clip_mask,0,0,MagickTrue,exception));
1393 assert(image != (
Image *) NULL);
1394 assert(image->signature == MagickCoreSignature);
1396 assert(exception->signature == MagickCoreSignature);
1397 if (IsEventLogging() != MagickFalse)
1398 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
1399 for (next=image; next != (
Image *) NULL; next=GetNextImageInList(next))
1401 if (next->exception.severity == UndefinedException)
1403 if (next->exception.severity > exception->severity)
1404 InheritException(exception,&next->exception);
1405 next->exception.severity=UndefinedException;
1431MagickExport
void GetImageInfo(
ImageInfo *image_info)
1439 assert(image_info != (
ImageInfo *) NULL);
1440 if (IsEventLogging() != MagickFalse)
1441 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
1442 (void) memset(image_info,0,
sizeof(*image_info));
1443 image_info->adjoin=MagickTrue;
1444 image_info->interlace=NoInterlace;
1445 image_info->channel=DefaultChannels;
1446 image_info->quality=UndefinedCompressionQuality;
1447 image_info->antialias=MagickTrue;
1448 image_info->dither=MagickTrue;
1449 synchronize=GetEnvironmentValue(
"MAGICK_SYNCHRONIZE");
1450 if (synchronize != (
const char *) NULL)
1452 image_info->synchronize=IsStringTrue(synchronize);
1453 synchronize=DestroyString(synchronize);
1455 GetPixelPacketRGBA(BackgroundColorRGBA,&image_info->background_color);
1456 GetPixelPacketRGBA(BorderColorRGBA,&image_info->border_color);
1457 GetPixelPacketRGBA(MatteColorRGBA,&image_info->matte_color);
1458 GetPixelPacketRGBA(TransparentColorRGBA,&image_info->transparent_color);
1459 image_info->debug=(GetLogEventMask() & ImageEvent) != 0 ? MagickTrue :
1461 image_info->signature=MagickCoreSignature;
1486MagickExport FILE *GetImageInfoFile(
const ImageInfo *image_info)
1488 return(image_info->file);
1515 assert(image != (
const Image *) NULL);
1516 assert(image->signature == MagickCoreSignature);
1517 if (IsEventLogging() != MagickFalse)
1518 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
1519 if (image->mask == (
Image *) NULL)
1520 return((
Image *) NULL);
1521 return(CloneImage(image->mask,0,0,MagickTrue,exception));
1547MagickExport
size_t GetImageChannels(
Image *image)
1549 assert(image != (
Image *) NULL);
1550 assert(image->signature == MagickCoreSignature);
1551 if (IsEventLogging() != MagickFalse)
1552 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
1553 return(image->channels);
1578MagickExport ssize_t GetImageReferenceCount(
Image *image)
1583 assert(image != (
Image *) NULL);
1584 assert(image->signature == MagickCoreSignature);
1585 if (IsEventLogging() != MagickFalse)
1586 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
1587 LockSemaphoreInfo(image->semaphore);
1588 reference_count=image->reference_count;
1589 UnlockSemaphoreInfo(image->semaphore);
1590 return(reference_count);
1617MagickExport VirtualPixelMethod GetImageVirtualPixelMethod(
const Image *image)
1619 assert(image != (
Image *) NULL);
1620 assert(image->signature == MagickCoreSignature);
1621 if (IsEventLogging() != MagickFalse)
1622 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
1623 return(GetPixelCacheVirtualMethod(image));
1659MagickExport
size_t InterpretImageFilename(
const ImageInfo *image_info,
1660 Image *image,
const char *format,
int value,
char *filename)
1678 canonical=MagickFalse;
1680 (void) CopyMagickString(filename,format,MaxTextExtent);
1681 if (IsStringTrue(GetImageOption(image_info,
"filename:literal")) != MagickFalse)
1682 return(strlen(filename));
1683 for (p=strchr(format,
'%'); p != (
char *) NULL; p=strchr(p+1,
'%'))
1693 field_width=(ssize_t) strtol(q,&q,10);
1703 (void) FormatLocaleString(filename+(p-format-offset),(size_t)
1704 (MaxTextExtent-(p-format-offset)),p,value);
1705 offset+=(4-field_width);
1707 (void) ConcatenateMagickString(filename,q,MaxTextExtent);
1708 canonical=MagickTrue;
1717 pattern[MaxTextExtent];
1734 if (strchr(p,
']') == (
char *) NULL)
1738 for (i=0; (i < (MaxTextExtent-1L)) && (*r !=
'\0'); i++)
1749 if (LocaleNCompare(pattern,
"filename:",9) != 0)
1751 value=(
const char *) NULL;
1752 if (image != (
Image *) NULL)
1753 value=GetImageProperty(image,pattern);
1754 if ((value == (
const char *) NULL) &&
1755 (image != (
Image *) NULL))
1756 value=GetImageArtifact(image,pattern);
1757 if ((value == (
const char *) NULL) &&
1759 value=GetImageOption(image_info,pattern);
1760 if (value == (
const char *) NULL)
1765 (void) CopyMagickString(filename+(p-format-offset),value,(size_t)
1766 (MaxTextExtent-(p-format-offset)));
1767 offset+=(ssize_t) strlen(pattern)-(ssize_t) strlen(value)+3;
1769 (void) ConcatenateMagickString(filename,r+1,MaxTextExtent);
1770 canonical=MagickTrue;
1780 if (canonical == MagickFalse)
1781 (void) CopyMagickString(filename,format,MaxTextExtent);
1783 for (q=filename; *q !=
'\0'; q++)
1784 if ((*q ==
'%') && (*(q+1) ==
'%'))
1785 (
void) CopyMagickString(q,q+1,(
size_t) (MaxTextExtent-(q-filename)));
1786 return(strlen(filename));
1816MagickExport MagickBooleanType IsHighDynamicRangeImage(
const Image *image,
1819#if !defined(MAGICKCORE_HDRI_SUPPORT)
1822 return(MagickFalse);
1836 assert(image != (
Image *) NULL);
1837 assert(image->signature == MagickCoreSignature);
1838 if (IsEventLogging() != MagickFalse)
1839 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
1840 GetMagickPixelPacket(image,&zero);
1841 image_view=AcquireVirtualCacheView(image,exception);
1842#if defined(MAGICKCORE_OPENMP_SUPPORT)
1843 #pragma omp parallel for schedule(static) shared(hdri) \
1844 magick_number_threads(image,image,image->rows,2)
1846 for (y=0; y < (ssize_t) image->rows; y++)
1860 if (hdri != MagickFalse)
1862 p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
1865 indexes=GetCacheViewVirtualIndexQueue(image_view);
1867 for (x=0; x < (ssize_t) image->columns; x++)
1869 SetMagickPixelPacket(image,p,indexes+x,&pixel);
1870 if ((pixel.red < 0.0) || (pixel.red > (MagickRealType) QuantumRange) ||
1871 (pixel.red != (QuantumAny) pixel.red))
1873 if ((pixel.green < 0.0) ||
1874 (pixel.green > (MagickRealType) QuantumRange) ||
1875 (pixel.green != (QuantumAny) pixel.green))
1877 if ((pixel.blue < 0.0) || (pixel.blue > (MagickRealType) QuantumRange) ||
1878 (pixel.blue != (QuantumAny) pixel.blue))
1880 if (pixel.matte != MagickFalse)
1882 if ((pixel.opacity < 0.0) || (pixel.opacity > (MagickRealType) QuantumRange) ||
1883 (pixel.opacity != (QuantumAny) pixel.opacity))
1886 if (pixel.colorspace == CMYKColorspace)
1888 if ((pixel.index < 0.0) ||
1889 (pixel.index > (MagickRealType) QuantumRange) ||
1890 (pixel.index != (QuantumAny) pixel.index))
1893 if (hdri != MagickFalse)
1898 image_view=DestroyCacheView(image_view);
1926MagickExport MagickBooleanType IsImageObject(
const Image *image)
1931 assert(image != (
Image *) NULL);
1932 if (IsEventLogging() != MagickFalse)
1933 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
1934 for (p=image; p != (
Image *) NULL; p=GetNextImageInList(p))
1935 if (p->signature != MagickCoreSignature)
1936 return(MagickFalse);
1963MagickExport MagickBooleanType IsTaintImage(
const Image *image)
1966 magick[MaxTextExtent],
1967 filename[MaxTextExtent];
1972 assert(image != (
Image *) NULL);
1973 assert(image->signature == MagickCoreSignature);
1974 if (IsEventLogging() != MagickFalse)
1975 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
1976 (void) CopyMagickString(magick,image->magick,MaxTextExtent);
1977 (void) CopyMagickString(filename,image->filename,MaxTextExtent);
1978 for (p=image; p != (
Image *) NULL; p=GetNextImageInList(p))
1980 if (p->taint != MagickFalse)
1982 if (LocaleCompare(p->magick,magick) != 0)
1984 if (LocaleCompare(p->filename,filename) != 0)
1987 return(MagickFalse);
2016MagickExport MagickBooleanType ModifyImage(
Image **image,
2022 assert(image != (
Image **) NULL);
2023 assert(*image != (
Image *) NULL);
2024 assert((*image)->signature == MagickCoreSignature);
2025 if (IsEventLogging() != MagickFalse)
2026 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",(*image)->filename);
2027 if (GetImageReferenceCount(*image) <= 1)
2029 clone_image=CloneImage(*image,0,0,MagickTrue,exception);
2030 LockSemaphoreInfo((*image)->semaphore);
2031 (*image)->reference_count--;
2032 UnlockSemaphoreInfo((*image)->semaphore);
2085 assert(image_info != (
const ImageInfo *) NULL);
2086 assert(image_info->signature == MagickCoreSignature);
2088 if (IsEventLogging() != MagickFalse)
2089 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
2090 image=AcquireImage(image_info);
2091 image->columns=width;
2093 image->colorspace=background->colorspace;
2094 image->matte=background->matte;
2095 image->fuzz=background->fuzz;
2096 image->depth=background->depth;
2098 exception=(&image->exception);
2099 image_view=AcquireAuthenticCacheView(image,exception);
2100#if defined(MAGICKCORE_OPENMP_SUPPORT)
2101 #pragma omp parallel for schedule(static) shared(status) \
2102 magick_number_threads(image,image,image->rows,2)
2104 for (y=0; y < (ssize_t) image->rows; y++)
2107 *magick_restrict indexes;
2115 if (status == MagickFalse)
2117 q=QueueCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
2123 indexes=GetCacheViewAuthenticIndexQueue(image_view);
2124 for (x=0; x < (ssize_t) image->columns; x++)
2126 SetPixelPacket(image,background,q,indexes+x);
2129 if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2132 image_view=DestroyCacheView(image_view);
2133 if (status == MagickFalse)
2134 image=DestroyImage(image);
2161MagickExport
Image *ReferenceImage(
Image *image)
2163 assert(image != (
Image *) NULL);
2164 assert(image->signature == MagickCoreSignature);
2165 if (IsEventLogging() != MagickFalse)
2166 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
2167 LockSemaphoreInfo(image->semaphore);
2168 image->reference_count++;
2169 UnlockSemaphoreInfo(image->semaphore);
2197MagickExport MagickBooleanType ResetImagePage(
Image *image,
const char *page)
2205 assert(image != (
Image *) NULL);
2206 assert(image->signature == MagickCoreSignature);
2207 if (IsEventLogging() != MagickFalse)
2208 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
2209 flags=ParseAbsoluteGeometry(page,&geometry);
2210 if ((flags & WidthValue) != 0)
2212 if ((flags & HeightValue) == 0)
2213 geometry.height=geometry.width;
2214 image->page.width=geometry.width;
2215 image->page.height=geometry.height;
2217 if ((flags & AspectValue) != 0)
2219 if ((flags & XValue) != 0)
2220 image->page.x+=geometry.x;
2221 if ((flags & YValue) != 0)
2222 image->page.y+=geometry.y;
2226 if ((flags & XValue) != 0)
2228 image->page.x=geometry.x;
2229 if ((image->page.width == 0) && (geometry.x > 0))
2230 image->page.width=(size_t) ((ssize_t) image->columns+geometry.x);
2232 if ((flags & YValue) != 0)
2234 image->page.y=geometry.y;
2235 if ((image->page.height == 0) && (geometry.y > 0))
2236 image->page.height=(size_t) ((ssize_t) image->rows+geometry.y);
2268MagickExport MagickBooleanType ResetImagePixels(
Image *image,
2286 assert(image != (
Image *) NULL);
2287 assert(image->signature == MagickCoreSignature);
2288 if (IsEventLogging() != MagickFalse)
2289 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
2290 pixels=AcquirePixelCachePixels(image,&length,exception);
2291 if (pixels != (
void *) NULL)
2296 (void) memset((
void *) pixels,0,(size_t) length);
2303 image_view=AcquireAuthenticCacheView(image,exception);
2304#if defined(MAGICKCORE_OPENMP_SUPPORT)
2305 #pragma omp parallel for schedule(static) shared(status) \
2306 magick_number_threads(image,image,image->rows,2)
2308 for (y=0; y < (ssize_t) image->rows; y++)
2311 *magick_restrict indexes;
2319 if (status == MagickFalse)
2321 q=QueueCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
2327 indexes=GetCacheViewAuthenticIndexQueue(image_view);
2328 for (x=0; x < (ssize_t) image->columns; x++)
2331 if ((image->storage_class == PseudoClass) ||
2332 (image->colorspace == CMYKColorspace))
2336 if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2339 image_view=DestroyCacheView(image_view);
2367MagickExport MagickBooleanType SetImageBackgroundColor(
Image *image)
2390 assert(image != (
Image *) NULL);
2391 assert(image->signature == MagickCoreSignature);
2392 if (IsEventLogging() != MagickFalse)
2393 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
2394 if (SetImageStorageClass(image,DirectClass) == MagickFalse)
2395 return(MagickFalse);
2396 if ((IsPixelGray(&image->background_color) == MagickFalse) &&
2397 (IsGrayColorspace(image->colorspace) != MagickFalse))
2398 (void) TransformImageColorspace(image,RGBColorspace);
2399 if ((image->background_color.opacity != OpaqueOpacity) &&
2400 (image->matte == MagickFalse))
2401 (void) SetImageAlphaChannel(image,OpaqueAlphaChannel);
2402 GetMagickPixelPacket(image,&background);
2403 SetMagickPixelPacket(image,&image->background_color,(
const IndexPacket *)
2405 if (image->colorspace == CMYKColorspace)
2406 ConvertRGBToCMYK(&background);
2408 pixel.opacity=OpaqueOpacity;
2409 SetPixelPacket(image,&background,&pixel,&index);
2414 exception=(&image->exception);
2415 image_view=AcquireAuthenticCacheView(image,exception);
2416#if defined(MAGICKCORE_OPENMP_SUPPORT)
2417 #pragma omp parallel for schedule(static) shared(status) \
2418 magick_number_threads(image,image,image->rows,2)
2420 for (y=0; y < (ssize_t) image->rows; y++)
2428 if (status == MagickFalse)
2430 q=QueueCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
2436 for (x=0; x < (ssize_t) image->columns; x++)
2438 if (image->colorspace == CMYKColorspace)
2441 *magick_restrict indexes;
2443 indexes=GetCacheViewAuthenticIndexQueue(image_view);
2444 for (x=0; x < (ssize_t) image->columns; x++)
2445 SetPixelIndex(indexes+x,index);
2447 if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2450 image_view=DestroyCacheView(image_view);
2479MagickExport MagickBooleanType SetImageChannels(
Image *image,
2480 const size_t channels)
2482 image->channels=channels;
2511MagickExport MagickBooleanType SetImageColor(
Image *image,
2526 assert(image != (
Image *) NULL);
2527 assert(image->signature == MagickCoreSignature);
2529 if (IsEventLogging() != MagickFalse)
2530 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
2531 image->colorspace=color->colorspace;
2532 image->matte=color->matte;
2533 image->fuzz=color->fuzz;
2534 image->depth=color->depth;
2536 exception=(&image->exception);
2537 image_view=AcquireAuthenticCacheView(image,exception);
2538#if defined(MAGICKCORE_OPENMP_SUPPORT)
2539 #pragma omp parallel for schedule(static) shared(status) \
2540 magick_number_threads(image,image,image->rows,2)
2542 for (y=0; y < (ssize_t) image->rows; y++)
2545 *magick_restrict indexes;
2553 if (status == MagickFalse)
2555 q=QueueCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
2561 indexes=GetCacheViewAuthenticIndexQueue(image_view);
2562 for (x=0; x < (ssize_t) image->columns; x++)
2564 SetPixelPacket(image,color,q,
2565 indexes == (IndexPacket *) NULL ? NULL : indexes+x);
2568 if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2571 image_view=DestroyCacheView(image_view);
2601MagickExport MagickBooleanType SetImageStorageClass(
Image *image,
2602 const ClassType storage_class)
2604 assert(image != (
Image *) NULL);
2605 assert(image->signature == MagickCoreSignature);
2606 if (IsEventLogging() != MagickFalse)
2607 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
2608 image->storage_class=storage_class;
2609 return(SyncImagePixelCache(image,&image->exception));
2639MagickExport MagickBooleanType SetImageClipMask(
Image *image,
2640 const Image *clip_mask)
2642 assert(image != (
Image *) NULL);
2643 assert(image->signature == MagickCoreSignature);
2644 if (IsEventLogging() != MagickFalse)
2645 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
2646 if (clip_mask != (
const Image *) NULL)
2647 if ((clip_mask->columns != image->columns) ||
2648 (clip_mask->rows != image->rows))
2649 ThrowBinaryImageException(ImageError,
"ImageSizeDiffers",image->filename);
2650 if (image->clip_mask != (
Image *) NULL)
2651 image->clip_mask=DestroyImage(image->clip_mask);
2652 image->clip_mask=NewImageList();
2653 if (clip_mask == (
Image *) NULL)
2655 if (SetImageStorageClass(image,DirectClass) == MagickFalse)
2656 return(MagickFalse);
2657 image->clip_mask=CloneImage(clip_mask,0,0,MagickTrue,&image->exception);
2658 if (image->clip_mask == (
Image *) NULL)
2659 return(MagickFalse);
2690MagickExport MagickBooleanType SetImageExtent(
Image *image,
const size_t columns,
2693 if ((columns == 0) || (rows == 0))
2694 ThrowBinaryImageException(ImageError,
"NegativeOrZeroImageSize",
2696 image->columns=columns;
2698 if (image->depth == 0)
2701 (void) ThrowMagickException(&image->exception,GetMagickModule(),
2702 ImageError,
"ImageDepthNotSupported",
"`%s'",image->filename);
2704 if (image->depth > (8*
sizeof(MagickSizeType)))
2706 image->depth=8*
sizeof(MagickSizeType);
2707 (void) ThrowMagickException(&image->exception,GetMagickModule(),
2708 ImageError,
"ImageDepthNotSupported",
"`%s'",image->filename);
2710 return(SyncImagePixelCache(image,&image->exception));
2747MagickExport MagickBooleanType SetImageInfo(
ImageInfo *image_info,
2751 extension[MaxTextExtent],
2752 filename[MaxTextExtent],
2753 magic[MaxTextExtent],
2755 subimage[MaxTextExtent];
2779 magick[2*MaxTextExtent];
2784 assert(image_info != (
ImageInfo *) NULL);
2785 assert(image_info->signature == MagickCoreSignature);
2786 if (IsEventLogging() != MagickFalse)
2787 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
2788 image_info->filename);
2790 GetPathComponent(image_info->filename,SubimagePath,subimage);
2791 if (*subimage !=
'\0')
2796 if (IsSceneGeometry(subimage,MagickFalse) == MagickFalse)
2798 if (IsGeometry(subimage) != MagickFalse)
2799 (void) CloneString(&image_info->extract,subimage);
2807 (void) CloneString(&image_info->scenes,subimage);
2808 image_info->scene=StringToUnsignedLong(image_info->scenes);
2809 image_info->number_scenes=image_info->scene;
2810 p=image_info->scenes;
2811 for (q=(
char *) image_info->scenes; *q !=
'\0'; p++)
2813 while ((isspace((
int) ((
unsigned char) *p)) != 0) || (*p ==
','))
2815 first=(size_t) strtol(p,&q,10);
2817 while (isspace((
int) ((
unsigned char) *q)) != 0)
2820 last=(size_t) strtol(q+1,&q,10);
2823 if (first < image_info->scene)
2824 image_info->scene=first;
2825 if (last > image_info->number_scenes)
2826 image_info->number_scenes=last;
2829 image_info->number_scenes-=image_info->scene-1;
2830 image_info->subimage=image_info->scene;
2831 image_info->subrange=image_info->number_scenes;
2835 if (*image_info->magick ==
'\0')
2836 GetPathComponent(image_info->filename,ExtensionPath,extension);
2837 if (*extension !=
'\0')
2840 path[MaxTextExtent];
2845 GetPathComponent(image_info->filename,BasePathSansCompressExtension,path);
2846 GetPathComponent(path,ExtensionPath,extension);
2848 image_info->affirm=MagickFalse;
2849 sans_exception=AcquireExceptionInfo();
2850 if ((*extension !=
'\0') && (IsGlob(extension) == MagickFalse))
2859 *format_type_formats[] =
2883 (void) CopyMagickString(magic,extension,MaxTextExtent);
2888 format_type=UndefinedFormatType;
2890 while ((format_type == UndefinedFormatType) &&
2891 (format_type_formats[i] != (
char *) NULL))
2893 if ((*magic == *format_type_formats[i]) &&
2894 (LocaleCompare(magic,format_type_formats[i]) == 0))
2895 format_type=ExplicitFormatType;
2898 magick_info=GetMagickInfo(magic,sans_exception);
2899 if ((magick_info != (
const MagickInfo *) NULL) &&
2900 (magick_info->format_type != UndefinedFormatType))
2901 format_type=magick_info->format_type;
2902 if (format_type == UndefinedFormatType)
2903 (void) CopyMagickString(image_info->magick,magic,MaxTextExtent);
2905 if (format_type == ExplicitFormatType)
2907 image_info->affirm=MagickTrue;
2908 (void) CopyMagickString(image_info->magick,magic,MaxTextExtent);
2910 if (LocaleCompare(magic,
"RGB") == 0)
2911 image_info->affirm=MagickFalse;
2917 GetPathComponent(image_info->filename,MagickPath,magic);
2920 (void) CopyMagickString(magic,image_info->magick,MaxTextExtent);
2921 magick_info=GetMagickInfo(magic,sans_exception);
2922 if ((magick_info != (
const MagickInfo *) NULL) &&
2923 (magick_info->format_type == ExplicitFormatType))
2924 image_info->affirm=MagickTrue;
2926 GetPathComponent(image_info->filename,CanonicalPath,filename);
2928 GetPathComponent(image_info->filename,SubcanonicalPath,filename);
2929 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
2940 magick_info=GetMagickInfo(magic,sans_exception);
2941 delegate_info=GetDelegateInfo(magic,
"*",sans_exception);
2943 delegate_info=GetDelegateInfo(
"*",magic,sans_exception);
2944 if (((magick_info != (
const MagickInfo *) NULL) ||
2946 (IsMagickConflict(magic) == MagickFalse))
2948 image_info->affirm=MagickTrue;
2949 (void) CopyMagickString(image_info->magick,magic,MaxTextExtent);
2950 GetPathComponent(image_info->filename,CanonicalPath,filename);
2951 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
2954 sans_exception=DestroyExceptionInfo(sans_exception);
2955 if ((magick_info == (
const MagickInfo *) NULL) ||
2956 (GetMagickEndianSupport(magick_info) == MagickFalse))
2957 image_info->endian=UndefinedEndian;
2958 if ((image_info->adjoin != MagickFalse) && (frames > 1))
2963 (void) InterpretImageFilename(image_info,(
Image *) NULL,
2964 image_info->filename,(int) image_info->scene,filename);
2965 if ((LocaleCompare(filename,image_info->filename) != 0) &&
2966 (strchr(filename,
'%') == (
char *) NULL))
2967 image_info->adjoin=MagickFalse;
2969 if ((image_info->adjoin != MagickFalse) && (frames > 0))
2974 magick_info=GetMagickInfo(magic,exception);
2975 if (magick_info != (
const MagickInfo *) NULL)
2976 if (GetMagickAdjoin(magick_info) == MagickFalse)
2977 image_info->adjoin=MagickFalse;
2979 if (image_info->affirm != MagickFalse)
2986 image=AcquireImage(image_info);
2987 (void) CopyMagickString(image->filename,image_info->filename,
2989 status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
2990 if (status == MagickFalse)
2992 image=DestroyImage(image);
2993 return(MagickFalse);
2995 if ((IsBlobSeekable(image) == MagickFalse) ||
2996 (IsBlobExempt(image) != MagickFalse))
3002 status=ImageToFile(image,filename,exception);
3003 if (CloseBlob(image) == MagickFalse)
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);
3081MagickExport
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;
3117MagickExport
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;
3152MagickExport 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);
3199MagickExport 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,2)
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);
3281MagickExport 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));
3326static 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 (((ssize_t) left_image->columns-x-1) >= (ssize_t) 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);
3397static 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 (((ssize_t) top_image->rows-y-1) >= (ssize_t) 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);
3468MagickExport
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)
3531 height=(
size_t) MagickMax((ssize_t) height+offset,0U);
3534 width+=next->columns;
3535 if (next->previous != (
Image *) NULL)
3536 width=(size_t) MagickMax((ssize_t) width+offset,0U);
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);
3620MagickExport 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");
3661static 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);
3670MagickExport 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,2)
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);
3776MagickExport 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");
3795MagickExport 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);