summaryrefslogtreecommitdiff
path: root/MagickCore/image.c
diff options
context:
space:
mode:
Diffstat (limited to 'MagickCore/image.c')
-rw-r--r--MagickCore/image.c190
1 files changed, 100 insertions, 90 deletions
diff --git a/MagickCore/image.c b/MagickCore/image.c
index 311d1fe51..c609e9361 100644
--- a/MagickCore/image.c
+++ b/MagickCore/image.c
@@ -1640,15 +1640,15 @@ MagickExport size_t InterpretImageFilename(const ImageInfo *image_info,
char
*q;
+ const char
+ *p;
+
int
c;
MagickBooleanType
canonical;
- const char
- *p;
-
ssize_t
field_width,
offset;
@@ -1656,6 +1656,8 @@ MagickExport size_t InterpretImageFilename(const ImageInfo *image_info,
canonical=MagickFalse;
offset=0;
(void) CopyMagickString(filename,format,MagickPathExtent);
+ if (IsStringTrue(GetImageOption(image_info,"filename:literal")) != MagickFalse)
+ return(strlen(filename));
for (p=strchr(format,'%'); p != (char *) NULL; p=strchr(p+1,'%'))
{
q=(char *) p+1;
@@ -2698,15 +2700,83 @@ MagickExport MagickBooleanType SetImageExtent(Image *image,const size_t columns,
% o exception: return any errors or warnings in this structure.
%
*/
+
+static const MagickInfo *SetImageInfoFromExtension(ImageInfo *image_info,
+ const char *component,char *magic,ExceptionInfo *exception)
+{
+ const MagickInfo
+ *magick_info;
+
+ MagickFormatType
+ format_type;
+
+ ssize_t
+ i;
+
+ static const char
+ *format_type_formats[] =
+ {
+ "AUTOTRACE",
+ "BROWSE",
+ "DCRAW",
+ "EDIT",
+ "LAUNCH",
+ "MPEG:DECODE",
+ "MPEG:ENCODE",
+ "PRINT",
+ "PS:ALPHA",
+ "PS:CMYK",
+ "PS:COLOR",
+ "PS:GRAY",
+ "PS:MONO",
+ "SCAN",
+ "SHOW",
+ "WIN",
+ (char *) NULL
+ };
+
+ /*
+ User specified image format.
+ */
+ (void) CopyMagickString(magic,component,MagickPathExtent);
+ LocaleUpper(magic);
+ /*
+ Look for explicit image formats.
+ */
+ format_type=UndefinedFormatType;
+ magick_info=GetMagickInfo(magic,exception);
+ if ((magick_info != (const MagickInfo *) NULL) &&
+ (magick_info->format_type != UndefinedFormatType))
+ format_type=magick_info->format_type;
+ i=0;
+ while ((format_type == UndefinedFormatType) &&
+ (format_type_formats[i] != (char *) NULL))
+ {
+ if ((*magic == *format_type_formats[i]) &&
+ (LocaleCompare(magic,format_type_formats[i]) == 0))
+ format_type=ExplicitFormatType;
+ i++;
+ }
+ if (format_type == UndefinedFormatType)
+ (void) CopyMagickString(image_info->magick,magic,MagickPathExtent);
+ else
+ if (format_type == ExplicitFormatType)
+ {
+ image_info->affirm=MagickTrue;
+ (void) CopyMagickString(image_info->magick,magic,MagickPathExtent);
+ }
+ if (LocaleCompare(magic,"RGB") == 0)
+ image_info->affirm=MagickFalse; /* maybe SGI disguised as RGB */
+ return(magick_info);
+}
+
MagickExport MagickBooleanType SetImageInfo(ImageInfo *image_info,
const unsigned int frames,ExceptionInfo *exception)
{
char
component[MagickPathExtent],
magic[MagickPathExtent],
-#if defined(MAGICKCORE_ZLIB_DELEGATE) || defined(MAGICKCORE_BZLIB_DELEGATE)
path[MagickPathExtent],
-#endif
*q;
const MagicInfo
@@ -2784,92 +2854,19 @@ MagickExport MagickBooleanType SetImageInfo(ImageInfo *image_info,
*component='\0';
if (*image_info->magick == '\0')
GetPathComponent(image_info->filename,ExtensionPath,component);
-#if defined(MAGICKCORE_ZLIB_DELEGATE)
- if (*component != '\0')
- if ((LocaleCompare(component,"gz") == 0) ||
- (LocaleCompare(component,"Z") == 0) ||
- (LocaleCompare(component,"svgz") == 0) ||
- (LocaleCompare(component,"wmz") == 0))
- {
- (void) CopyMagickString(path,image_info->filename,MagickPathExtent);
- path[strlen(path)-strlen(component)-1]='\0';
- GetPathComponent(path,ExtensionPath,component);
- }
-#endif
-#if defined(MAGICKCORE_BZLIB_DELEGATE)
if (*component != '\0')
- if (LocaleCompare(component,"bz2") == 0)
- {
- (void) CopyMagickString(path,image_info->filename,MagickPathExtent);
- path[strlen(path)-strlen(component)-1]='\0';
- GetPathComponent(path,ExtensionPath,component);
- }
-#endif
- image_info->affirm=MagickFalse;
- sans_exception=AcquireExceptionInfo();
- if ((*component != '\0') && (IsGlob(component) == MagickFalse))
{
- MagickFormatType
- format_type;
-
- ssize_t
- i;
-
- static const char
- *format_type_formats[] =
- {
- "AUTOTRACE",
- "BROWSE",
- "DCRAW",
- "EDIT",
- "LAUNCH",
- "MPEG:DECODE",
- "MPEG:ENCODE",
- "PRINT",
- "PS:ALPHA",
- "PS:CMYK",
- "PS:COLOR",
- "PS:GRAY",
- "PS:MONO",
- "SCAN",
- "SHOW",
- "WIN",
- (char *) NULL
- };
-
- /*
- User specified image format.
- */
- (void) CopyMagickString(magic,component,MagickPathExtent);
- LocaleUpper(magic);
/*
- Look for explicit image formats.
+ Base path sans any compression extension.
*/
- format_type=UndefinedFormatType;
- magick_info=GetMagickInfo(magic,sans_exception);
- if ((magick_info != (const MagickInfo *) NULL) &&
- (magick_info->format_type != UndefinedFormatType))
- format_type=magick_info->format_type;
- i=0;
- while ((format_type == UndefinedFormatType) &&
- (format_type_formats[i] != (char *) NULL))
- {
- if ((*magic == *format_type_formats[i]) &&
- (LocaleCompare(magic,format_type_formats[i]) == 0))
- format_type=ExplicitFormatType;
- i++;
- }
- if (format_type == UndefinedFormatType)
- (void) CopyMagickString(image_info->magick,magic,MagickPathExtent);
- else
- if (format_type == ExplicitFormatType)
- {
- image_info->affirm=MagickTrue;
- (void) CopyMagickString(image_info->magick,magic,MagickPathExtent);
- }
- if (LocaleCompare(magic,"RGB") == 0)
- image_info->affirm=MagickFalse; /* maybe SGI disguised as RGB */
+ GetPathComponent(image_info->filename,BasePathSansCompressExtension,path);
+ GetPathComponent(path,ExtensionPath,component);
}
+ image_info->affirm=MagickFalse;
+ sans_exception=AcquireExceptionInfo();
+ if ((*component != '\0') && (IsGlob(component) == MagickFalse))
+ magick_info=SetImageInfoFromExtension(image_info,component,magic,
+ sans_exception);
/*
Look for explicit 'format:image' in filename.
*/
@@ -2895,9 +2892,22 @@ MagickExport MagickBooleanType SetImageInfo(ImageInfo *image_info,
*/
LocaleUpper(magic);
magick_info=GetMagickInfo(magic,sans_exception);
- delegate_info=GetDelegateInfo(magic,"*",sans_exception);
- if (delegate_info == (const DelegateInfo *) NULL)
- delegate_info=GetDelegateInfo("*",magic,sans_exception);
+ delegate_info=(const DelegateInfo *) NULL;
+ if (magick_info == (const MagickInfo *) NULL)
+ {
+ delegate_info=GetDelegateInfo(magic,"*",sans_exception);
+ if (delegate_info == (const DelegateInfo *) NULL)
+ delegate_info=GetDelegateInfo("*",magic,sans_exception);
+ if ((delegate_info == (const DelegateInfo *) NULL) &&
+ ((*component != '\0') && (IsGlob(component) == MagickFalse)))
+ {
+ /*
+ Retry in case GetMagickInfo loaded a custom module.
+ */
+ magick_info=SetImageInfoFromExtension(image_info,component,magic,
+ sans_exception);
+ }
+ }
if (((magick_info != (const MagickInfo *) NULL) ||
(delegate_info != (const DelegateInfo *) NULL)) &&
(IsMagickConflict(magic) == MagickFalse))
@@ -3827,10 +3837,10 @@ MagickExport MagickBooleanType StripImage(Image *image,ExceptionInfo *exception)
MagickBooleanType
status;
+ magick_unreferenced(exception);
assert(image != (Image *) NULL);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
- (void) exception;
DestroyImageProfiles(image);
(void) DeleteImageProperty(image,"comment");
(void) DeleteImageProperty(image,"date:create");