% MagickCore Methods to Consitute an Image %
% %
% Software Design %
-% John Cristy %
+% Cristy %
% October 1998 %
% %
% %
-% Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2014 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/string_.h"
#include "MagickCore/string-private.h"
#include "MagickCore/timer.h"
+#include "MagickCore/token.h"
#include "MagickCore/transform.h"
#include "MagickCore/utility.h"
#include "MagickCore/utility-private.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)
-%
-*/
-MagickPrivate 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)
-%
-*/
-MagickPrivate void ConstituteComponentTerminus(void)
-{
- if (constitute_semaphore == (SemaphoreInfo *) NULL)
- AcquireSemaphoreInfo(&constitute_semaphore);
- DestroySemaphoreInfo(&constitute_semaphore);
-}
-\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;
%
% 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[MaxTextExtent];
Image
*image,
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
+ (void) SetImageOption(image_info,"filename",filename);
+ (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
(void) InterpretImageFilename(image_info,(Image *) NULL,image_info->filename,
- (int) image_info->scene,filename,exception);
- 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,MaxTextExtent);
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,exception);
+ (void) InterpretImageFilename(image_info,(Image *) NULL,ping_filename,
+ (int) scene,read_info->filename,exception);
image=PingImage(read_info,exception);
if (image == (Image *) NULL)
continue;
errno=EPERM;
(void) ThrowMagickException(exception,GetMagickModule(),PolicyError,
"NotAuthorized","`%s'",read_info->filename);
+ read_info=DestroyImageInfo(read_info);
return((Image *) NULL);
}
/*
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,MaxTextExtent);
+ 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);
+ LockSemaphoreInfo(magick_info->semaphore);
image=GetImageDecoder(magick_info)(read_info,exception);
if ((thread_support & DecoderThreadSupport) == 0)
- UnlockSemaphoreInfo(constitute_semaphore);
+ 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);
MaxTextExtent);
*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);
}
thread_support=GetMagickThreadSupport(magick_info);
if ((thread_support & DecoderThreadSupport) == 0)
- LockSemaphoreInfo(constitute_semaphore);
+ LockSemaphoreInfo(magick_info->semaphore);
image=(Image *) (GetImageDecoder(magick_info))(read_info,exception);
if ((thread_support & DecoderThreadSupport) == 0)
- UnlockSemaphoreInfo(constitute_semaphore);
+ UnlockSemaphoreInfo(magick_info->semaphore);
}
if (read_info->temporary != MagickFalse)
{
}
}
if (GetBlobError(image) != MagickFalse)
- {
- ThrowFileException(exception,FileOpenError,
- "AnErrorHasOccurredReadingFromFile",read_info->filename);
- image=DestroyImageList(image);
- read_info=DestroyImageInfo(read_info);
- return((Image *) NULL);
- }
+ ThrowFileException(exception,FileOpenError,
+ "AnErrorHasOccurredReadingFromFile",read_info->filename);
for (next=image; next != (Image *) NULL; next=GetNextImageInList(next))
{
char
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);
}
%
% 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[MaxTextExtent];
Image
*image,
(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,exception);
- if (LocaleCompare(filename,image_info->filename) != 0)
+ (void) SetImageOption(image_info,"filename",filename);
+ (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
+ (void) InterpretImageFilename(image_info,(Image *) NULL,filename,
+ (int) image_info->scene,read_filename,exception);
+ if (LocaleCompare(read_filename,image_info->filename) != 0)
{
ExceptionInfo
*sans;
read_info=DestroyImageInfo(read_info);
return(ReadImage(image_info,exception));
}
- (void) CopyMagickString(filename,read_info->filename,MaxTextExtent);
+ (void) CopyMagickString(read_filename,read_info->filename,MaxTextExtent);
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,exception);
+ (void) InterpretImageFilename(image_info,(Image *) NULL,read_filename,
+ (int) scene,read_info->filename,exception);
image=ReadImage(read_info,exception);
if (image == (Image *) NULL)
continue;
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);
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,exception);
if ((delegate_info != (const DelegateInfo *) NULL) &&
(void) CloseBlob(image);
}
}
- if (constitute_semaphore == (SemaphoreInfo *) NULL)
- AcquireSemaphoreInfo(&constitute_semaphore);
if ((magick_info != (const MagickInfo *) NULL) &&
(GetImageEncoder(magick_info) != (EncodeImageHandler *) NULL))
{
*/
thread_support=GetMagickThreadSupport(magick_info);
if ((thread_support & EncoderThreadSupport) == 0)
- LockSemaphoreInfo(constitute_semaphore);
+ LockSemaphoreInfo(magick_info->semaphore);
status=GetImageEncoder(magick_info)(write_info,image,exception);
if ((thread_support & EncoderThreadSupport) == 0)
- UnlockSemaphoreInfo(constitute_semaphore);
+ UnlockSemaphoreInfo(magick_info->semaphore);
}
else
{
*/
*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,exception);
if (GetDelegateThreadSupport(delegate_info) == MagickFalse)
- UnlockSemaphoreInfo(constitute_semaphore);
+ UnlockSemaphoreInfo(delegate_info->semaphore);
(void) CopyMagickString(image->filename,filename,MaxTextExtent);
}
else
}
if ((magick_info == (const MagickInfo *) NULL) ||
(GetImageEncoder(magick_info) == (EncodeImageHandler *) NULL))
- (void) ThrowMagickException(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);
+ LockSemaphoreInfo(magick_info->semaphore);
status=GetImageEncoder(magick_info)(write_info,image,exception);
if ((thread_support & EncoderThreadSupport) == 0)
- UnlockSemaphoreInfo(constitute_semaphore);
+ UnlockSemaphoreInfo(magick_info->semaphore);
}
}
}
if (GetBlobError(image) != MagickFalse)
ThrowFileException(exception,FileOpenError,
"AnErrorHasOccurredWritingToFile",image->filename);
- if (temporary == MagickTrue)
+ if (temporary != MagickFalse)
{
/*
Copy temporary image file to permanent.