% MagickCore Methods to Consitute an Image %
% %
% Software Design %
-% John Cristy %
+% Cristy %
% October 1998 %
% %
% %
-% Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2015 ImageMagick Studio LLC, a non-profit organization %
% dedicated to making software imaging solutions freely available. %
% %
% You may not use this file except in compliance with the License. You may %
Include declarations.
*/
#include "MagickCore/studio.h"
+#include "MagickCore/attribute.h"
#include "MagickCore/blob.h"
#include "MagickCore/blob-private.h"
#include "MagickCore/exception.h"
#include "MagickCore/exception-private.h"
#include "MagickCore/cache.h"
#include "MagickCore/client.h"
+#include "MagickCore/colorspace-private.h"
#include "MagickCore/constitute.h"
+#include "MagickCore/constitute-private.h"
#include "MagickCore/delegate.h"
#include "MagickCore/geometry.h"
#include "MagickCore/identify.h"
#include "MagickCore/pixel-accessor.h"
#include "MagickCore/policy.h"
#include "MagickCore/profile.h"
+#include "MagickCore/profile-private.h"
#include "MagickCore/property.h"
#include "MagickCore/quantum.h"
#include "MagickCore/resize.h"
#include "MagickCore/string_.h"
#include "MagickCore/string-private.h"
#include "MagickCore/timer.h"
+#include "MagickCore/token.h"
#include "MagickCore/transform.h"
#include "MagickCore/utility.h"
-\f
-static SemaphoreInfo
- *constitute_semaphore = (SemaphoreInfo *) NULL;
-\f
-/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% %
-% %
-% %
-+ C o n s t i t u t e C o m p o n e n t G e n e s i s %
-% %
-% %
-% %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% ConstituteComponentGenesis() instantiates the constitute component.
-%
-% The format of the ConstituteComponentGenesis method is:
-%
-% MagickBooleanType ConstituteComponentGenesis(void)
-%
-*/
-MagickExport MagickBooleanType ConstituteComponentGenesis(void)
-{
- AcquireSemaphoreInfo(&constitute_semaphore);
- return(MagickTrue);
-}
-\f
-/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% %
-% %
-% %
-+ C o n s t i t u t e C o m p o n e n t T e r m i n u s %
-% %
-% %
-% %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% ConstituteComponentTerminus() destroys the constitute component.
-%
-% The format of the ConstituteComponentTerminus method is:
-%
-% ConstituteComponentTerminus(void)
-%
-*/
-MagickExport void ConstituteComponentTerminus(void)
-{
- if (constitute_semaphore == (SemaphoreInfo *) NULL)
- AcquireSemaphoreInfo(&constitute_semaphore);
- DestroySemaphoreInfo(&constitute_semaphore);
-}
+#include "MagickCore/utility-private.h"
\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% o exception: return any errors or warnings in this structure.
%
*/
-MagickExport Image *ConstituteImage(const size_t columns,
- const size_t rows,const char *map,const StorageType storage,
- const void *pixels,ExceptionInfo *exception)
+MagickExport Image *ConstituteImage(const size_t columns,const size_t rows,
+ const char *map,const StorageType storage,const void *pixels,
+ ExceptionInfo *exception)
{
Image
*image;
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",map);
assert(pixels != (void *) NULL);
assert(exception != (ExceptionInfo *) NULL);
- assert(exception->signature == MagickSignature);
- image=AcquireImage((ImageInfo *) NULL);
+ assert(exception->signature == MagickCoreSignature);
+ image=AcquireImage((ImageInfo *) NULL,exception);
if (image == (Image *) NULL)
return((Image *) NULL);
if ((columns == 0) || (rows == 0))
ThrowImageException(OptionError,"NonZeroWidthAndHeightRequired");
image->columns=columns;
image->rows=rows;
- (void) SetImageBackgroundColor(image);
- status=ImportImagePixels(image,0,0,columns,rows,map,storage,pixels);
+ (void) SetImageBackgroundColor(image,exception);
+ status=ImportImagePixels(image,0,0,columns,rows,map,storage,pixels,exception);
if (status == MagickFalse)
- {
- InheritException(exception,&image->exception);
- image=DestroyImage(image);
- }
+ image=DestroyImage(image);
return(image);
}
\f
*ping_info;
assert(image_info != (ImageInfo *) NULL);
- assert(image_info->signature == MagickSignature);
+ assert(image_info->signature == MagickCoreSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
{
ResetTimer(&image->timer);
if (ping_info->verbose != MagickFalse)
- (void) IdentifyImage(image,stdout,MagickFalse);
+ (void) IdentifyImage(image,stdout,MagickFalse,exception);
}
ping_info=DestroyImageInfo(ping_info);
return(image);
%
% The format of the PingImage method is:
%
-% Image *PingImages(const ImageInfo *image_info,ExceptionInfo *exception)
+% Image *PingImages(ImageInfo *image_info,const char *filename,
+% ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o image_info: the image info.
%
+% o filename: the image filename.
+%
% o exception: return any errors or warnings in this structure.
%
*/
-MagickExport Image *PingImages(const ImageInfo *image_info,
+MagickExport Image *PingImages(ImageInfo *image_info,const char *filename,
ExceptionInfo *exception)
{
char
- filename[MaxTextExtent];
+ ping_filename[MagickPathExtent];
Image
*image,
Ping image list from a file.
*/
assert(image_info != (ImageInfo *) NULL);
- assert(image_info->signature == MagickSignature);
+ assert(image_info->signature == MagickCoreSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
+ (void) SetImageOption(image_info,"filename",filename);
+ (void) CopyMagickString(image_info->filename,filename,MagickPathExtent);
(void) InterpretImageFilename(image_info,(Image *) NULL,image_info->filename,
- (int) image_info->scene,filename);
- if (LocaleCompare(filename,image_info->filename) != 0)
+ (int) image_info->scene,ping_filename,exception);
+ if (LocaleCompare(ping_filename,image_info->filename) != 0)
{
ExceptionInfo
*sans;
sans=AcquireExceptionInfo();
(void) SetImageInfo(read_info,0,sans);
sans=DestroyExceptionInfo(sans);
- (void) CopyMagickString(filename,read_info->filename,MaxTextExtent);
+ if (read_info->number_scenes == 0)
+ {
+ read_info=DestroyImageInfo(read_info);
+ return(PingImage(image_info,exception));
+ }
+ (void) CopyMagickString(ping_filename,read_info->filename,MagickPathExtent);
images=NewImageList();
extent=(ssize_t) (read_info->scene+read_info->number_scenes);
for (scene=(ssize_t) read_info->scene; scene < (ssize_t) extent; scene++)
{
- (void) InterpretImageFilename(image_info,(Image *) NULL,filename,(int)
- scene,read_info->filename);
+ (void) InterpretImageFilename(image_info,(Image *) NULL,ping_filename,
+ (int) scene,read_info->filename,exception);
image=PingImage(read_info,exception);
if (image == (Image *) NULL)
continue;
ExceptionInfo *exception)
{
char
- filename[MaxTextExtent],
- magick[MaxTextExtent],
- magick_filename[MaxTextExtent];
+ filename[MagickPathExtent],
+ magick[MagickPathExtent],
+ magick_filename[MagickPathExtent];
const char
*value;
*read_info;
MagickStatusType
- flags,
- thread_support;
+ flags;
PolicyDomain
domain;
Determine image type from filename prefix or suffix (e.g. image.jpg).
*/
assert(image_info != (ImageInfo *) NULL);
- assert(image_info->signature == MagickSignature);
+ assert(image_info->signature == MagickCoreSignature);
assert(image_info->filename != (char *) NULL);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
read_info=CloneImageInfo(image_info);
- (void) CopyMagickString(magick_filename,read_info->filename,MaxTextExtent);
+ (void) CopyMagickString(magick_filename,read_info->filename,MagickPathExtent);
(void) SetImageInfo(read_info,0,exception);
- (void) CopyMagickString(filename,read_info->filename,MaxTextExtent);
- (void) CopyMagickString(magick,read_info->magick,MaxTextExtent);
+ (void) CopyMagickString(filename,read_info->filename,MagickPathExtent);
+ (void) CopyMagickString(magick,read_info->magick,MagickPathExtent);
domain=CoderPolicyDomain;
rights=ReadPolicyRights;
if (IsRightsAuthorized(domain,rights,read_info->magick) == MagickFalse)
errno=EPERM;
(void) ThrowMagickException(exception,GetMagickModule(),PolicyError,
"NotAuthorized","`%s'",read_info->filename);
+ read_info=DestroyImageInfo(read_info);
return((Image *) NULL);
}
/*
MagickBooleanType
status;
- image=AcquireImage(read_info);
+ image=AcquireImage(read_info,exception);
(void) CopyMagickString(image->filename,read_info->filename,
- MaxTextExtent);
+ MagickPathExtent);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
{
image=DestroyImage(image);
}
image=NewImageList();
- if (constitute_semaphore == (SemaphoreInfo *) NULL)
- AcquireSemaphoreInfo(&constitute_semaphore);
+ if ((magick_info == (const MagickInfo *) NULL) ||
+ (GetImageDecoder(magick_info) == (DecodeImageHandler *) NULL))
+ {
+ delegate_info=GetDelegateInfo(read_info->magick,(char *) NULL,exception);
+ if (delegate_info == (const DelegateInfo *) NULL)
+ {
+ (void) SetImageInfo(read_info,0,exception);
+ (void) CopyMagickString(read_info->filename,filename,MagickPathExtent);
+ magick_info=GetMagickInfo(read_info->magick,exception);
+ }
+ }
if ((magick_info != (const MagickInfo *) NULL) &&
(GetImageDecoder(magick_info) != (DecodeImageHandler *) NULL))
{
- thread_support=GetMagickThreadSupport(magick_info);
- if ((thread_support & DecoderThreadSupport) == 0)
- LockSemaphoreInfo(constitute_semaphore);
+ if (GetMagickDecoderThreadSupport(magick_info) == MagickFalse)
+ LockSemaphoreInfo(magick_info->semaphore);
image=GetImageDecoder(magick_info)(read_info,exception);
- if ((thread_support & DecoderThreadSupport) == 0)
- UnlockSemaphoreInfo(constitute_semaphore);
+ if (GetMagickDecoderThreadSupport(magick_info) == MagickFalse)
+ UnlockSemaphoreInfo(magick_info->semaphore);
}
else
{
{
(void) ThrowMagickException(exception,GetMagickModule(),
MissingDelegateError,"NoDecodeDelegateForThisImageFormat","`%s'",
- read_info->filename);
+ read_info->magick);
if (read_info->temporary != MagickFalse)
(void) RelinquishUniqueFileResource(read_info->filename);
read_info=DestroyImageInfo(read_info);
/*
Let our decoding delegate process the image.
*/
- image=AcquireImage(read_info);
+ image=AcquireImage(read_info,exception);
if (image == (Image *) NULL)
{
read_info=DestroyImageInfo(read_info);
return((Image *) NULL);
}
(void) CopyMagickString(image->filename,read_info->filename,
- MaxTextExtent);
+ MagickPathExtent);
*read_info->filename='\0';
if (GetDelegateThreadSupport(delegate_info) == MagickFalse)
- LockSemaphoreInfo(constitute_semaphore);
+ LockSemaphoreInfo(delegate_info->semaphore);
(void) InvokeDelegate(read_info,image,read_info->magick,(char *) NULL,
exception);
if (GetDelegateThreadSupport(delegate_info) == MagickFalse)
- UnlockSemaphoreInfo(constitute_semaphore);
+ UnlockSemaphoreInfo(delegate_info->semaphore);
image=DestroyImageList(image);
read_info->temporary=MagickTrue;
(void) SetImageInfo(read_info,0,exception);
if (IsPathAccessible(read_info->filename) != MagickFalse)
(void) ThrowMagickException(exception,GetMagickModule(),
MissingDelegateError,"NoDecodeDelegateForThisImageFormat","`%s'",
- read_info->filename);
+ read_info->magick);
else
ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
read_info->filename);
read_info=DestroyImageInfo(read_info);
return((Image *) NULL);
}
- thread_support=GetMagickThreadSupport(magick_info);
- if ((thread_support & DecoderThreadSupport) == 0)
- LockSemaphoreInfo(constitute_semaphore);
+ if (GetMagickDecoderThreadSupport(magick_info) == MagickFalse)
+ LockSemaphoreInfo(magick_info->semaphore);
image=(Image *) (GetImageDecoder(magick_info))(read_info,exception);
- if ((thread_support & DecoderThreadSupport) == 0)
- UnlockSemaphoreInfo(constitute_semaphore);
+ if (GetMagickDecoderThreadSupport(magick_info) == MagickFalse)
+ UnlockSemaphoreInfo(magick_info->semaphore);
}
if (read_info->temporary != MagickFalse)
{
(void) RelinquishUniqueFileResource(read_info->filename);
read_info->temporary=MagickFalse;
if (image != (Image *) NULL)
- (void) CopyMagickString(image->filename,filename,MaxTextExtent);
+ (void) CopyMagickString(image->filename,filename,MagickPathExtent);
}
if (image == (Image *) NULL)
{
image=GetFirstImageInList(clones);
}
}
- if (GetBlobError(image) != MagickFalse)
- {
- ThrowFileException(exception,FileOpenError,
- "AnErrorHasOccurredReadingFromFile",read_info->filename);
- image=DestroyImageList(image);
- read_info=DestroyImageInfo(read_info);
- return((Image *) NULL);
- }
for (next=image; next != (Image *) NULL; next=GetNextImageInList(next))
{
char
- magick_path[MaxTextExtent],
+ magick_path[MagickPathExtent],
*property,
- timestamp[MaxTextExtent];
+ timestamp[MagickPathExtent];
const char
*option;
next->taint=MagickFalse;
GetPathComponent(magick_filename,MagickPath,magick_path);
- if (*magick_path == '\0')
- (void) CopyMagickString(next->magick,magick,MaxTextExtent);
+ if (*magick_path == '\0' && *next->magick == '\0')
+ (void) CopyMagickString(next->magick,magick,MagickPathExtent);
(void) CopyMagickString(next->magick_filename,magick_filename,
- MaxTextExtent);
+ MagickPathExtent);
if (IsBlobTemporary(image) != MagickFalse)
- (void) CopyMagickString(next->filename,filename,MaxTextExtent);
+ (void) CopyMagickString(next->filename,filename,MagickPathExtent);
if (next->magick_columns == 0)
next->magick_columns=next->columns;
if (next->magick_rows == 0)
next->magick_rows=next->rows;
- value=GetImageProperty(next,"tiff:Orientation");
+ value=GetImageProperty(next,"tiff:Orientation",exception);
if (value == (char *) NULL)
- value=GetImageProperty(next,"exif:Orientation");
+ value=GetImageProperty(next,"exif:Orientation",exception);
if (value != (char *) NULL)
{
next->orientation=(OrientationType) StringToLong(value);
(void) DeleteImageProperty(next,"tiff:Orientation");
(void) DeleteImageProperty(next,"exif:Orientation");
}
- value=GetImageProperty(next,"exif:XResolution");
+ value=GetImageProperty(next,"exif:XResolution",exception);
if (value != (char *) NULL)
{
- geometry_info.rho=next->x_resolution;
+ geometry_info.rho=next->resolution.x;
geometry_info.sigma=1.0;
flags=ParseGeometry(value,&geometry_info);
if (geometry_info.sigma != 0)
- next->x_resolution=geometry_info.rho/geometry_info.sigma;
+ next->resolution.x=geometry_info.rho/geometry_info.sigma;
(void) DeleteImageProperty(next,"exif:XResolution");
}
- value=GetImageProperty(next,"exif:YResolution");
+ value=GetImageProperty(next,"exif:YResolution",exception);
if (value != (char *) NULL)
{
- geometry_info.rho=next->y_resolution;
+ geometry_info.rho=next->resolution.y;
geometry_info.sigma=1.0;
flags=ParseGeometry(value,&geometry_info);
if (geometry_info.sigma != 0)
- next->y_resolution=geometry_info.rho/geometry_info.sigma;
+ next->resolution.y=geometry_info.rho/geometry_info.sigma;
(void) DeleteImageProperty(next,"exif:YResolution");
}
- value=GetImageProperty(next,"tiff:ResolutionUnit");
+ value=GetImageProperty(next,"tiff:ResolutionUnit",exception);
if (value == (char *) NULL)
- value=GetImageProperty(next,"exif:ResolutionUnit");
+ value=GetImageProperty(next,"exif:ResolutionUnit",exception);
if (value != (char *) NULL)
{
next->units=(ResolutionType) (StringToLong(value)-1);
option=GetImageOption(read_info,"caption");
if (option != (const char *) NULL)
{
- property=InterpretImageProperties(read_info,next,option);
- (void) SetImageProperty(next,"caption",property);
+ property=InterpretImageProperties(read_info,next,option,exception);
+ (void) SetImageProperty(next,"caption",property,exception);
property=DestroyString(property);
}
option=GetImageOption(read_info,"comment");
if (option != (const char *) NULL)
{
- property=InterpretImageProperties(read_info,next,option);
- (void) SetImageProperty(next,"comment",property);
+ property=InterpretImageProperties(read_info,next,option,exception);
+ (void) SetImageProperty(next,"comment",property,exception);
property=DestroyString(property);
}
option=GetImageOption(read_info,"label");
if (option != (const char *) NULL)
{
- property=InterpretImageProperties(read_info,next,option);
- (void) SetImageProperty(next,"label",property);
+ property=InterpretImageProperties(read_info,next,option,exception);
+ (void) SetImageProperty(next,"label",property,exception);
property=DestroyString(property);
}
if (LocaleCompare(next->magick,"TEXT") == 0)
flags=ParseRegionGeometry(next,read_info->extract,&geometry,
exception);
size_image=ResizeImage(next,geometry.width,geometry.height,
- next->filter,next->blur,exception);
+ next->filter,exception);
if (size_image != (Image *) NULL)
ReplaceImageInList(&next,size_image);
}
profile=GetImageProfile(next,"iptc");
if (profile == (const StringInfo *) NULL)
profile=GetImageProfile(next,"8bim");
- (void) FormatMagickTime(GetBlobProperties(next)->st_mtime,MaxTextExtent,
+ (void) FormatMagickTime(GetBlobProperties(next)->st_mtime,MagickPathExtent,
timestamp);
- (void) SetImageProperty(next,"date:modify",timestamp);
- (void) FormatMagickTime(GetBlobProperties(next)->st_ctime,MaxTextExtent,
+ (void) SetImageProperty(next,"date:modify",timestamp,exception);
+ (void) FormatMagickTime(GetBlobProperties(next)->st_ctime,MagickPathExtent,
timestamp);
- (void) SetImageProperty(next,"date:create",timestamp);
+ (void) SetImageProperty(next,"date:create",timestamp,exception);
option=GetImageOption(image_info,"delay");
if (option != (const char *) NULL)
{
next->dispose=(DisposeType) ParseCommandOption(MagickDisposeOptions,
MagickFalse,option);
if (read_info->verbose != MagickFalse)
- (void) IdentifyImage(next,stderr,MagickFalse);
+ (void) IdentifyImage(next,stderr,MagickFalse,exception);
image=next;
}
read_info=DestroyImageInfo(read_info);
%
% The format of the ReadImage method is:
%
-% Image *ReadImages(const ImageInfo *image_info,ExceptionInfo *exception)
+% Image *ReadImages(ImageInfo *image_info,const char *filename,
+% ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o image_info: the image info.
%
+% o filename: the image filename.
+%
% o exception: return any errors or warnings in this structure.
%
*/
-MagickExport Image *ReadImages(const ImageInfo *image_info,
+MagickExport Image *ReadImages(ImageInfo *image_info,const char *filename,
ExceptionInfo *exception)
{
char
- filename[MaxTextExtent];
+ read_filename[MagickPathExtent];
Image
*image,
Read image list from a file.
*/
assert(image_info != (ImageInfo *) NULL);
- assert(image_info->signature == MagickSignature);
+ assert(image_info->signature == MagickCoreSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
- (void) InterpretImageFilename(image_info,(Image *) NULL,image_info->filename,
- (int) image_info->scene,filename);
- if (LocaleCompare(filename,image_info->filename) != 0)
+ read_info=CloneImageInfo(image_info);
+ *read_info->magick='\0';
+ (void) SetImageOption(read_info,"filename",filename);
+ (void) CopyMagickString(read_info->filename,filename,MagickPathExtent);
+ (void) InterpretImageFilename(read_info,(Image *) NULL,filename,
+ (int) read_info->scene,read_filename,exception);
+ if (LocaleCompare(read_filename,read_info->filename) != 0)
{
ExceptionInfo
*sans;
/*
Images of the form image-%d.png[1-5].
*/
- read_info=CloneImageInfo(image_info);
sans=AcquireExceptionInfo();
(void) SetImageInfo(read_info,0,sans);
sans=DestroyExceptionInfo(sans);
- (void) CopyMagickString(filename,read_info->filename,MaxTextExtent);
- images=NewImageList();
if (read_info->number_scenes == 0)
{
read_info=DestroyImageInfo(read_info);
return(ReadImage(image_info,exception));
}
+ (void) CopyMagickString(read_filename,read_info->filename,MagickPathExtent);
+ images=NewImageList();
extent=(ssize_t) (read_info->scene+read_info->number_scenes);
for (scene=(ssize_t) read_info->scene; scene < (ssize_t) extent; scene++)
{
- (void) InterpretImageFilename(image_info,(Image *) NULL,filename,(int)
- scene,read_info->filename);
+ (void) InterpretImageFilename(image_info,(Image *) NULL,read_filename,
+ (int) scene,read_info->filename,exception);
image=ReadImage(read_info,exception);
if (image == (Image *) NULL)
continue;
read_info=DestroyImageInfo(read_info);
return(images);
}
- return(ReadImage(image_info,exception));
+ image=ReadImage(read_info,exception);
+ read_info=DestroyImageInfo(read_info);
+ return(image);
}
\f
/*
%
% The format of the WriteImage method is:
%
-% MagickBooleanType WriteImage(const ImageInfo *image_info,Image *image)
+% MagickBooleanType WriteImage(const ImageInfo *image_info,Image *image,
+% ExceptionInfo *exception)
%
% A description of each parameter follows:
%
%
% o image: the image.
%
+% o exception: return any errors or warnings in this structure.
+%
*/
MagickExport MagickBooleanType WriteImage(const ImageInfo *image_info,
- Image *image)
+ Image *image,ExceptionInfo *exception)
{
char
- filename[MaxTextExtent];
+ filename[MagickPathExtent];
const char
*option;
status,
temporary;
- MagickStatusType
- thread_support;
-
PolicyDomain
domain;
Determine image type from filename prefix or suffix (e.g. image.jpg).
*/
assert(image_info != (ImageInfo *) NULL);
- assert(image_info->signature == MagickSignature);
+ assert(image_info->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(image != (Image *) NULL);
- assert(image->signature == MagickSignature);
+ assert(image->signature == MagickCoreSignature);
+ assert(exception != (ExceptionInfo *) NULL);
sans_exception=AcquireExceptionInfo();
write_info=CloneImageInfo(image_info);
- (void) CopyMagickString(write_info->filename,image->filename,MaxTextExtent);
- if (*write_info->magick == '\0')
- (void) CopyMagickString(write_info->magick,image->magick,MaxTextExtent);
+ (void) CopyMagickString(write_info->filename,image->filename,MagickPathExtent);
(void) SetImageInfo(write_info,1,sans_exception);
- if (LocaleCompare(write_info->magick,"clipmask") == 0)
- {
- if (image->clip_mask == (Image *) NULL)
- {
- (void) ThrowMagickException(&image->exception,GetMagickModule(),
- OptionError,"NoClipPathDefined","`%s'",image->filename);
- return(MagickFalse);
- }
- image=image->clip_mask;
- (void) SetImageInfo(write_info,1,sans_exception);
- }
- (void) CopyMagickString(filename,image->filename,MaxTextExtent);
- (void) CopyMagickString(image->filename,write_info->filename,MaxTextExtent);
+ if (*write_info->magick == '\0')
+ (void) CopyMagickString(write_info->magick,image->magick,MagickPathExtent);
+ (void) CopyMagickString(filename,image->filename,MagickPathExtent);
+ (void) CopyMagickString(image->filename,write_info->filename,MagickPathExtent);
domain=CoderPolicyDomain;
rights=WritePolicyRights;
if (IsRightsAuthorized(domain,rights,write_info->magick) == MagickFalse)
{
sans_exception=DestroyExceptionInfo(sans_exception);
+ write_info=DestroyImageInfo(write_info);
errno=EPERM;
ThrowBinaryException(PolicyError,"NotAuthorized",filename);
}
+ /*
+ Call appropriate image reader based on image type.
+ */
magick_info=GetMagickInfo(write_info->magick,sans_exception);
sans_exception=DestroyExceptionInfo(sans_exception);
if (magick_info != (const MagickInfo *) NULL)
}
}
(void) SyncImageProfiles(image);
+ DisassociateImageStream(image);
option=GetImageOption(image_info,"delegate:bimodal");
- if ((option != (const char *) NULL) &&
- (IsMagickTrue(option) != MagickFalse) &&
+ if ((IfMagickTrue(IsStringTrue(option))) &&
(write_info->page == (char *) NULL) &&
(GetPreviousImageInList(image) == (Image *) NULL) &&
(GetNextImageInList(image) == (Image *) NULL) &&
- (IsTaintImage(image) == MagickFalse))
+ (IfMagickFalse(IsTaintImage(image))) )
{
- delegate_info=GetDelegateInfo(image->magick,write_info->magick,
- &image->exception);
+ delegate_info=GetDelegateInfo(image->magick,write_info->magick,exception);
if ((delegate_info != (const DelegateInfo *) NULL) &&
(GetDelegateMode(delegate_info) == 0) &&
(IsPathAccessible(image->magick_filename) != MagickFalse))
Process image with bi-modal delegate.
*/
(void) CopyMagickString(image->filename,image->magick_filename,
- MaxTextExtent);
+ MagickPathExtent);
status=InvokeDelegate(write_info,image,image->magick,
- write_info->magick,&image->exception);
+ write_info->magick,exception);
write_info=DestroyImageInfo(write_info);
- (void) CopyMagickString(image->filename,filename,MaxTextExtent);
+ (void) CopyMagickString(image->filename,filename,MagickPathExtent);
return(status);
}
}
(GetMagickSeekableStream(magick_info) != MagickFalse))
{
char
- filename[MaxTextExtent];
+ filename[MagickPathExtent];
- (void) CopyMagickString(filename,image->filename,MaxTextExtent);
- status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
- (void) CopyMagickString(image->filename,filename,MaxTextExtent);
+ (void) CopyMagickString(filename,image->filename,MagickPathExtent);
+ status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
+ (void) CopyMagickString(image->filename,filename,MagickPathExtent);
if (status != MagickFalse)
{
if (IsBlobSeekable(image) == MagickFalse)
*/
write_info->adjoin=MagickTrue;
(void) CopyMagickString(write_info->filename,image->filename,
- MaxTextExtent);
+ MagickPathExtent);
(void) AcquireUniqueFilename(image->filename);
temporary=MagickTrue;
}
(void) CloseBlob(image);
}
}
- if (constitute_semaphore == (SemaphoreInfo *) NULL)
- AcquireSemaphoreInfo(&constitute_semaphore);
if ((magick_info != (const MagickInfo *) NULL) &&
(GetImageEncoder(magick_info) != (EncodeImageHandler *) NULL))
{
/*
Call appropriate image writer based on image type.
*/
- thread_support=GetMagickThreadSupport(magick_info);
- if ((thread_support & EncoderThreadSupport) == 0)
- LockSemaphoreInfo(constitute_semaphore);
- status=GetImageEncoder(magick_info)(write_info,image);
- if ((thread_support & EncoderThreadSupport) == 0)
- UnlockSemaphoreInfo(constitute_semaphore);
+ if (GetMagickEncoderThreadSupport(magick_info) == MagickFalse)
+ LockSemaphoreInfo(magick_info->semaphore);
+ status=GetImageEncoder(magick_info)(write_info,image,exception);
+ if (GetMagickEncoderThreadSupport(magick_info) == MagickFalse)
+ UnlockSemaphoreInfo(magick_info->semaphore);
}
else
{
- delegate_info=GetDelegateInfo((char *) NULL,write_info->magick,
- &image->exception);
+ delegate_info=GetDelegateInfo((char *) NULL,write_info->magick,exception);
if (delegate_info != (DelegateInfo *) NULL)
{
/*
*/
*write_info->filename='\0';
if (GetDelegateThreadSupport(delegate_info) == MagickFalse)
- LockSemaphoreInfo(constitute_semaphore);
+ LockSemaphoreInfo(delegate_info->semaphore);
status=InvokeDelegate(write_info,image,(char *) NULL,
- write_info->magick,&image->exception);
+ write_info->magick,exception);
if (GetDelegateThreadSupport(delegate_info) == MagickFalse)
- UnlockSemaphoreInfo(constitute_semaphore);
- (void) CopyMagickString(image->filename,filename,MaxTextExtent);
+ UnlockSemaphoreInfo(delegate_info->semaphore);
+ (void) CopyMagickString(image->filename,filename,MagickPathExtent);
}
else
{
(magick_info == (const MagickInfo *) NULL))
{
(void) CopyMagickString(write_info->magick,image->magick,
- MaxTextExtent);
- magick_info=GetMagickInfo(write_info->magick,&image->exception);
+ MagickPathExtent);
+ magick_info=GetMagickInfo(write_info->magick,exception);
}
if ((magick_info == (const MagickInfo *) NULL) ||
(GetImageEncoder(magick_info) == (EncodeImageHandler *) NULL))
{
char
- extension[MaxTextExtent];
+ extension[MagickPathExtent];
GetPathComponent(image->filename,ExtensionPath,extension);
if (*extension != '\0')
- magick_info=GetMagickInfo(extension,&image->exception);
+ magick_info=GetMagickInfo(extension,exception);
else
- magick_info=GetMagickInfo(image->magick,&image->exception);
- (void) CopyMagickString(image->filename,filename,MaxTextExtent);
+ magick_info=GetMagickInfo(image->magick,exception);
+ (void) CopyMagickString(image->filename,filename,MagickPathExtent);
}
if ((magick_info == (const MagickInfo *) NULL) ||
(GetImageEncoder(magick_info) == (EncodeImageHandler *) NULL))
- (void) ThrowMagickException(&image->exception,GetMagickModule(),
- MissingDelegateError,"NoEncodeDelegateForThisImageFormat","`%s'",
- image->filename);
- else
+ {
+ magick_info=GetMagickInfo(image->magick,exception);
+ if ((magick_info == (const MagickInfo *) NULL) ||
+ (GetImageEncoder(magick_info) == (EncodeImageHandler *) NULL))
+ (void) ThrowMagickException(exception,GetMagickModule(),
+ MissingDelegateError,"NoEncodeDelegateForThisImageFormat",
+ "`%s'",write_info->magick);
+ else
+ (void) ThrowMagickException(exception,GetMagickModule(),
+ MissingDelegateWarning,"NoEncodeDelegateForThisImageFormat",
+ "`%s'",write_info->magick);
+ }
+ if ((magick_info != (const MagickInfo *) NULL) &&
+ (GetImageEncoder(magick_info) != (EncodeImageHandler *) NULL))
{
/*
Call appropriate image writer based on image type.
*/
- thread_support=GetMagickThreadSupport(magick_info);
- if ((thread_support & EncoderThreadSupport) == 0)
- LockSemaphoreInfo(constitute_semaphore);
- status=GetImageEncoder(magick_info)(write_info,image);
- if ((thread_support & EncoderThreadSupport) == 0)
- UnlockSemaphoreInfo(constitute_semaphore);
+ if (GetMagickEncoderThreadSupport(magick_info) == MagickFalse)
+ LockSemaphoreInfo(magick_info->semaphore);
+ status=GetImageEncoder(magick_info)(write_info,image,exception);
+ if (GetMagickEncoderThreadSupport(magick_info) == MagickFalse)
+ UnlockSemaphoreInfo(magick_info->semaphore);
}
}
}
- if (GetBlobError(image) != MagickFalse)
- ThrowFileException(&image->exception,FileOpenError,
- "AnErrorHasOccurredWritingToFile",image->filename);
- if (temporary == MagickTrue)
+ if (temporary != MagickFalse)
{
/*
Copy temporary image file to permanent.
*/
- status=OpenBlob(write_info,image,ReadBinaryBlobMode,&image->exception);
+ status=OpenBlob(write_info,image,ReadBinaryBlobMode,exception);
if (status != MagickFalse)
- status=ImageToFile(image,write_info->filename,&image->exception);
+ {
+ (void) RelinquishUniqueFileResource(write_info->filename);
+ status=ImageToFile(image,write_info->filename,exception);
+ }
(void) CloseBlob(image);
(void) RelinquishUniqueFileResource(image->filename);
(void) CopyMagickString(image->filename,write_info->filename,
- MaxTextExtent);
+ MagickPathExtent);
}
if ((LocaleCompare(write_info->magick,"info") != 0) &&
(write_info->verbose != MagickFalse))
- (void) IdentifyImage(image,stdout,MagickFalse);
+ (void) IdentifyImage(image,stdout,MagickFalse,exception);
write_info=DestroyImageInfo(write_info);
return(status);
}
{
#define WriteImageTag "Write/Image"
- BlobInfo
- *blob;
-
ExceptionInfo
*sans_exception;
*p;
assert(image_info != (const ImageInfo *) NULL);
- assert(image_info->signature == MagickSignature);
+ assert(image_info->signature == MagickCoreSignature);
assert(images != (Image *) NULL);
- assert(images->signature == MagickSignature);
+ assert(images->signature == MagickCoreSignature);
if (images->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",images->filename);
assert(exception != (ExceptionInfo *) NULL);
write_info=CloneImageInfo(image_info);
+ *write_info->magick='\0';
images=GetFirstImageInList(images);
- blob=CloneBlobInfo(images->blob); /* thread specific I/O handler */
- DestroyBlob(images);
- images->blob=blob;
if (filename != (const char *) NULL)
for (p=images; p != (Image *) NULL; p=GetNextImageInList(p))
- (void) CopyMagickString(p->filename,filename,MaxTextExtent);
- (void) CopyMagickString(write_info->filename,images->filename,MaxTextExtent);
- if (*write_info->magick == '\0')
- (void) CopyMagickString(write_info->magick,images->magick,MaxTextExtent);
+ (void) CopyMagickString(p->filename,filename,MagickPathExtent);
+ (void) CopyMagickString(write_info->filename,images->filename,MagickPathExtent);
sans_exception=AcquireExceptionInfo();
(void) SetImageInfo(write_info,(unsigned int) GetImageListLength(images),
sans_exception);
sans_exception=DestroyExceptionInfo(sans_exception);
+ if (*write_info->magick == '\0')
+ (void) CopyMagickString(write_info->magick,images->magick,MagickPathExtent);
p=images;
for ( ; GetNextImageInList(p) != (Image *) NULL; p=GetNextImageInList(p))
if (p->scene >= GetNextImageInList(p)->scene)
if (number_images != 1)
progress_monitor=SetImageProgressMonitor(p,(MagickProgressMonitor) NULL,
p->client_data);
- status&=WriteImage(write_info,p);
- GetImageException(p,exception);
+ status&=WriteImage(write_info,p,exception);
if (number_images != 1)
(void) SetImageProgressMonitor(p,progress_monitor,p->client_data);
if (write_info->adjoin != MagickFalse)