Пример #1
0
/*
    Extern:     rm_pixelpacket_to_color_name
    Purpose:    Map the color intensity to a named color
    Returns:    the named color as a String
    Notes:      See below for the equivalent function that accepts an Info
                structure instead of an Image.
*/
VALUE
rm_pixelpacket_to_color_name(Image *image, PixelPacket *color)
{
    char name[MaxTextExtent];
    ExceptionInfo exception;

    GetExceptionInfo(&exception);

    (void) QueryColorname(image, color, X11Compliance, name, &exception);
    CHECK_EXCEPTION()
    (void) DestroyExceptionInfo(&exception);

    return rb_str_new2(name);
}
Пример #2
0
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                             %
%                                                                             %
%                                                                             %
%   W r i t e T X T I m a g e                                                 %
%                                                                             %
%                                                                             %
%                                                                             %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  WriteTXTImage writes the pixel values as text numbers.
%
%  The format of the WriteTXTImage method is:
%
%      MagickBooleanType WriteTXTImage(const ImageInfo *image_info,
%        Image *image,ExceptionInfo *exception)
%
%  A description of each parameter follows.
%
%    o image_info: the image info.
%
%    o image:  The image.
%
%    o exception: return any errors or warnings in this structure.
%
*/
static MagickBooleanType WriteTXTImage(const ImageInfo *image_info,Image *image,
                                       ExceptionInfo *exception)
{
    char
    buffer[MagickPathExtent],
           colorspace[MagickPathExtent],
           tuple[MagickPathExtent];

    MagickBooleanType
    status;

    MagickOffsetType
    scene;

    PixelInfo
    pixel;

    register const Quantum
    *p;

    register ssize_t
    x;

    ssize_t
    y;

    /*
      Open output image file.
    */
    assert(image_info != (const ImageInfo *) NULL);
    assert(image_info->signature == MagickCoreSignature);
    assert(image != (Image *) NULL);
    assert(image->signature == MagickCoreSignature);
    if (image->debug != MagickFalse)
        (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
    status=OpenBlob(image_info,image,WriteBlobMode,exception);
    if (status == MagickFalse)
        return(status);
    scene=0;
    do
    {
        ComplianceType
        compliance;

        const char
        *value;

        (void) CopyMagickString(colorspace,CommandOptionToMnemonic(
                                    MagickColorspaceOptions,(ssize_t) image->colorspace),MagickPathExtent);
        LocaleLower(colorspace);
        image->depth=GetImageQuantumDepth(image,MagickTrue);
        if (image->alpha_trait != UndefinedPixelTrait)
            (void) ConcatenateMagickString(colorspace,"a",MagickPathExtent);
        compliance=NoCompliance;
        value=GetImageOption(image_info,"txt:compliance");
        if (value != (char *) NULL)
            compliance=(ComplianceType) ParseCommandOption(MagickComplianceOptions,
                       MagickFalse,value);
        if (LocaleCompare(image_info->magick,"SPARSE-COLOR") != 0)
        {
            size_t
            depth;

            depth=compliance == SVGCompliance ? image->depth :
                  MAGICKCORE_QUANTUM_DEPTH;
            (void) FormatLocaleString(buffer,MagickPathExtent,
                                      "# ImageMagick pixel enumeration: %.20g,%.20g,%.20g,%s\n",(double)
                                      image->columns,(double) image->rows,(double) ((MagickOffsetType)
                                              GetQuantumRange(depth)),colorspace);
            (void) WriteBlobString(image,buffer);
        }
        GetPixelInfo(image,&pixel);
        for (y=0; y < (ssize_t) image->rows; y++)
        {
            p=GetVirtualPixels(image,0,y,image->columns,1,exception);
            if (p == (const Quantum *) NULL)
                break;
            for (x=0; x < (ssize_t) image->columns; x++)
            {
                GetPixelInfoPixel(image,p,&pixel);
                if (pixel.colorspace == LabColorspace)
                {
                    pixel.green-=(QuantumRange+1)/2.0;
                    pixel.blue-=(QuantumRange+1)/2.0;
                }
                if (LocaleCompare(image_info->magick,"SPARSE-COLOR") == 0)
                {
                    /*
                      Sparse-color format.
                    */
                    if (GetPixelAlpha(image,p) == (Quantum) OpaqueAlpha)
                    {
                        GetColorTuple(&pixel,MagickFalse,tuple);
                        (void) FormatLocaleString(buffer,MagickPathExtent,
                                                  "%.20g,%.20g,",(double) x,(double) y);
                        (void) WriteBlobString(image,buffer);
                        (void) WriteBlobString(image,tuple);
                        (void) WriteBlobString(image," ");
                    }
                    p+=GetPixelChannels(image);
                    continue;
                }
                (void) FormatLocaleString(buffer,MagickPathExtent,"%.20g,%.20g: ",
                                          (double) x,(double) y);
                (void) WriteBlobString(image,buffer);
                (void) CopyMagickString(tuple,"(",MagickPathExtent);
                if (pixel.colorspace == GRAYColorspace)
                    ConcatenateColorComponent(&pixel,GrayPixelChannel,compliance,
                                              tuple);
                else
                {
                    ConcatenateColorComponent(&pixel,RedPixelChannel,compliance,tuple);
                    (void) ConcatenateMagickString(tuple,",",MagickPathExtent);
                    ConcatenateColorComponent(&pixel,GreenPixelChannel,compliance,
                                              tuple);
                    (void) ConcatenateMagickString(tuple,",",MagickPathExtent);
                    ConcatenateColorComponent(&pixel,BluePixelChannel,compliance,tuple);
                }
                if (pixel.colorspace == CMYKColorspace)
                {
                    (void) ConcatenateMagickString(tuple,",",MagickPathExtent);
                    ConcatenateColorComponent(&pixel,BlackPixelChannel,compliance,
                                              tuple);
                }
                if (pixel.alpha_trait != UndefinedPixelTrait)
                {
                    (void) ConcatenateMagickString(tuple,",",MagickPathExtent);
                    ConcatenateColorComponent(&pixel,AlphaPixelChannel,compliance,
                                              tuple);
                }
                (void) ConcatenateMagickString(tuple,")",MagickPathExtent);
                (void) WriteBlobString(image,tuple);
                (void) WriteBlobString(image,"  ");
                GetColorTuple(&pixel,MagickTrue,tuple);
                (void) FormatLocaleString(buffer,MagickPathExtent,"%s",tuple);
                (void) WriteBlobString(image,buffer);
                (void) WriteBlobString(image,"  ");
                (void) QueryColorname(image,&pixel,SVGCompliance,tuple,exception);
                (void) WriteBlobString(image,tuple);
                (void) WriteBlobString(image,"\n");
                p+=GetPixelChannels(image);
            }
            status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
                                    image->rows);
            if (status == MagickFalse)
                break;
        }
        if (GetNextImageInList(image) == (Image *) NULL)
            break;
        image=SyncNextImageInList(image);
        status=SetImageProgress(image,SaveImagesTag,scene++,
                                GetImageListLength(image));
        if (status == MagickFalse)
            break;
    } while (image_info->adjoin != MagickFalse);
    (void) CloseBlob(image);
    return(MagickTrue);
}
Пример #3
0
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                             %
%                                                                             %
%                                                                             %
%   W r i t e P I C O N I m a g e                                             %
%                                                                             %
%                                                                             %
%                                                                             %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  WritePICONImage() writes an image to a file in the Personal Icon format.
%
%  The format of the WritePICONImage method is:
%
%      MagickBooleanType WritePICONImage(const ImageInfo *image_info,
%        Image *image,ExceptionInfo *exception)
%
%  A description of each parameter follows.
%
%    o image_info: the image info.
%
%    o image:  The image.
%
%    o exception: return any errors or warnings in this structure.
%
*/
static MagickBooleanType WritePICONImage(const ImageInfo *image_info,
        Image *image,ExceptionInfo *exception)
{
#define ColormapExtent  155
#define GraymapExtent  95
#define PiconGeometry  "48x48>"

    static unsigned char
    Colormap[]=
    {
        0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x06, 0x00, 0x05, 0x00, 0xf4, 0x05,
        0x00, 0x00, 0x00, 0x00, 0x2f, 0x4f, 0x4f, 0x70, 0x80, 0x90, 0x7e, 0x7e,
        0x7e, 0xdc, 0xdc, 0xdc, 0xff, 0xff, 0xff, 0x00, 0x00, 0x80, 0x00, 0x00,
        0xff, 0x1e, 0x90, 0xff, 0x87, 0xce, 0xeb, 0xe6, 0xe6, 0xfa, 0x00, 0xff,
        0xff, 0x80, 0x00, 0x80, 0xb2, 0x22, 0x22, 0x2e, 0x8b, 0x57, 0x32, 0xcd,
        0x32, 0x00, 0xff, 0x00, 0x98, 0xfb, 0x98, 0xff, 0x00, 0xff, 0xff, 0x00,
        0x00, 0xff, 0x63, 0x47, 0xff, 0xa5, 0x00, 0xff, 0xd7, 0x00, 0xff, 0xff,
        0x00, 0xee, 0x82, 0xee, 0xa0, 0x52, 0x2d, 0xcd, 0x85, 0x3f, 0xd2, 0xb4,
        0x8c, 0xf5, 0xde, 0xb3, 0xff, 0xfa, 0xcd, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x21, 0xf9, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00,
        0x00, 0x00, 0x06, 0x00, 0x05, 0x00, 0x00, 0x05, 0x18, 0x20, 0x10, 0x08,
        0x03, 0x51, 0x18, 0x07, 0x92, 0x28, 0x0b, 0xd3, 0x38, 0x0f, 0x14, 0x49,
        0x13, 0x55, 0x59, 0x17, 0x96, 0x69, 0x1b, 0xd7, 0x85, 0x00, 0x3b,
    },
    Graymap[]=
    {
        0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x04, 0x00, 0x04, 0x00, 0xf3, 0x0f,
        0x00, 0x00, 0x00, 0x00, 0x12, 0x12, 0x12, 0x21, 0x21, 0x21, 0x33, 0x33,
        0x33, 0x45, 0x45, 0x45, 0x54, 0x54, 0x54, 0x66, 0x66, 0x66, 0x78, 0x78,
        0x78, 0x87, 0x87, 0x87, 0x99, 0x99, 0x99, 0xab, 0xab, 0xab, 0xba, 0xba,
        0xba, 0xcc, 0xcc, 0xcc, 0xde, 0xde, 0xde, 0xed, 0xed, 0xed, 0xff, 0xff,
        0xff, 0x21, 0xf9, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00,
        0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x04, 0x0c, 0x10, 0x04, 0x31,
        0x48, 0x31, 0x07, 0x25, 0xb5, 0x58, 0x73, 0x4f, 0x04, 0x00, 0x3b,
    };

#define MaxCixels  92

    static const char
    Cixel[MaxCixels+1] = " .XoO+@#$%&*=-;:>,<1234567890qwertyuipasdfghjk"
                         "lzxcvbnmMNBVCZASDFGHJKLPIUYTREWQ!~^/()_`'][{}|";

    char
    buffer[MaxTextExtent],
           basename[MaxTextExtent],
           name[MaxTextExtent],
           symbol[MaxTextExtent];

    Image
    *affinity_image,
    *picon;

    ImageInfo
    *blob_info;

    MagickBooleanType
    status,
    transparent;

    PixelInfo
    pixel;

    QuantizeInfo
    *quantize_info;

    RectangleInfo
    geometry;

    register const Quantum
    *p;

    register ssize_t
    i,
    x;

    register Quantum
    *q;

    size_t
    characters_per_pixel,
    colors;

    ssize_t
    j,
    k,
    y;

    /*
      Open output image file.
    */
    assert(image_info != (const ImageInfo *) NULL);
    assert(image_info->signature == MagickSignature);
    assert(image != (Image *) NULL);
    assert(image->signature == MagickSignature);
    if (image->debug != MagickFalse)
        (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
    assert(exception != (ExceptionInfo *) NULL);
    assert(exception->signature == MagickSignature);
    status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
    if (status == MagickFalse)
        return(status);
    if (IsRGBColorspace(image->colorspace) == MagickFalse)
        (void) TransformImageColorspace(image,sRGBColorspace,exception);
    SetGeometry(image,&geometry);
    (void) ParseMetaGeometry(PiconGeometry,&geometry.x,&geometry.y,
                             &geometry.width,&geometry.height);
    picon=ResizeImage(image,geometry.width,geometry.height,TriangleFilter,
                      exception);
    blob_info=CloneImageInfo(image_info);
    (void) AcquireUniqueFilename(blob_info->filename);
    if ((image_info->type != TrueColorType) &&
            (IsImageGray(image,exception) != MagickFalse))
        affinity_image=BlobToImage(blob_info,Graymap,GraymapExtent,exception);
    else
        affinity_image=BlobToImage(blob_info,Colormap,ColormapExtent,exception);
    (void) RelinquishUniqueFileResource(blob_info->filename);
    blob_info=DestroyImageInfo(blob_info);
    if ((picon == (Image *) NULL) || (affinity_image == (Image *) NULL))
        return(MagickFalse);
    quantize_info=AcquireQuantizeInfo(image_info);
    status=RemapImage(quantize_info,picon,affinity_image,exception);
    quantize_info=DestroyQuantizeInfo(quantize_info);
    affinity_image=DestroyImage(affinity_image);
    transparent=MagickFalse;
    if (picon->storage_class == PseudoClass)
    {
        (void) CompressImageColormap(picon,exception);
        if (picon->matte != MagickFalse)
            transparent=MagickTrue;
    }
    else
    {
        /*
          Convert DirectClass to PseudoClass picon.
        */
        if (picon->matte != MagickFalse)
        {
            /*
              Map all the transparent pixels.
            */
            for (y=0; y < (ssize_t) picon->rows; y++)
            {
                q=GetAuthenticPixels(picon,0,y,picon->columns,1,exception);
                if (q == (Quantum *) NULL)
                    break;
                for (x=0; x < (ssize_t) picon->columns; x++)
                {
                    if (GetPixelAlpha(image,q) == (Quantum) TransparentAlpha)
                        transparent=MagickTrue;
                    else
                        SetPixelAlpha(picon,OpaqueAlpha,q);
                    q+=GetPixelChannels(picon);
                }
                if (SyncAuthenticPixels(picon,exception) == MagickFalse)
                    break;
            }
        }
        (void) SetImageType(picon,PaletteType,exception);
    }
    colors=picon->colors;
    if (transparent != MagickFalse)
    {
        colors++;
        picon->colormap=(PixelInfo *) ResizeQuantumMemory((void **)
                        picon->colormap,(size_t) colors,sizeof(*picon->colormap));
        if (picon->colormap == (PixelInfo *) NULL)
            ThrowWriterException(ResourceLimitError,"MemoryAllocationError");
        for (y=0; y < (ssize_t) picon->rows; y++)
        {
            q=GetAuthenticPixels(picon,0,y,picon->columns,1,exception);
            if (q == (Quantum *) NULL)
                break;
            for (x=0; x < (ssize_t) picon->columns; x++)
            {
                if (GetPixelAlpha(image,q) == (Quantum) TransparentAlpha)
                    SetPixelIndex(picon,picon->colors,q);
                q+=GetPixelChannels(picon);
            }
            if (SyncAuthenticPixels(picon,exception) == MagickFalse)
                break;
        }
    }
    /*
      Compute the character per pixel.
    */
    characters_per_pixel=1;
    for (k=MaxCixels; (ssize_t) colors > k; k*=MaxCixels)
        characters_per_pixel++;
    /*
      XPM header.
    */
    (void) WriteBlobString(image,"/* XPM */\n");
    GetPathComponent(picon->filename,BasePath,basename);
    (void) FormatLocaleString(buffer,MaxTextExtent,
                              "static char *%s[] = {\n",basename);
    (void) WriteBlobString(image,buffer);
    (void) WriteBlobString(image,"/* columns rows colors chars-per-pixel */\n");
    (void) FormatLocaleString(buffer,MaxTextExtent,
                              "\"%.20g %.20g %.20g %.20g\",\n",(double) picon->columns,(double)
                              picon->rows,(double) colors,(double) characters_per_pixel);
    (void) WriteBlobString(image,buffer);
    GetPixelInfo(image,&pixel);
    for (i=0; i < (ssize_t) colors; i++)
    {
        /*
          Define XPM color.
        */
        pixel=picon->colormap[i];
        pixel.colorspace=RGBColorspace;
        pixel.depth=8;
        pixel.alpha=(MagickRealType) OpaqueAlpha;
        (void) QueryColorname(image,&pixel,XPMCompliance,name,exception);
        if (transparent != MagickFalse)
        {
            if (i == (ssize_t) (colors-1))
                (void) CopyMagickString(name,"grey75",MaxTextExtent);
        }
        /*
          Write XPM color.
        */
        k=i % MaxCixels;
        symbol[0]=Cixel[k];
        for (j=1; j < (ssize_t) characters_per_pixel; j++)
        {
            k=((i-k)/MaxCixels) % MaxCixels;
            symbol[j]=Cixel[k];
        }
        symbol[j]='\0';
        (void) FormatLocaleString(buffer,MaxTextExtent,"\"%s c %s\",\n",
                                  symbol,name);
        (void) WriteBlobString(image,buffer);
    }
    /*
      Define XPM pixels.
    */
    (void) WriteBlobString(image,"/* pixels */\n");
    for (y=0; y < (ssize_t) picon->rows; y++)
    {
        p=GetVirtualPixels(picon,0,y,picon->columns,1,exception);
        if (p == (const Quantum *) NULL)
            break;
        (void) WriteBlobString(image,"\"");
        for (x=0; x < (ssize_t) picon->columns; x++)
        {
            k=((ssize_t) GetPixelIndex(picon,p) % MaxCixels);
            symbol[0]=Cixel[k];
            for (j=1; j < (ssize_t) characters_per_pixel; j++)
            {
                k=(((int) GetPixelIndex(picon,p)-k)/MaxCixels) % MaxCixels;
                symbol[j]=Cixel[k];
            }
            symbol[j]='\0';
            (void) CopyMagickString(buffer,symbol,MaxTextExtent);
            (void) WriteBlobString(image,buffer);
            p+=GetPixelChannels(image);
        }
        (void) FormatLocaleString(buffer,MaxTextExtent,"\"%s\n",
                                  y == (ssize_t) (picon->rows-1) ? "" : ",");
        (void) WriteBlobString(image,buffer);
        status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
                                picon->rows);
        if (status == MagickFalse)
            break;
    }
    picon=DestroyImage(picon);
    (void) WriteBlobString(image,"};\n");
    (void) CloseBlob(image);
    return(MagickTrue);
}
Пример #4
0
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                             %
%                                                                             %
%                                                                             %
%   W r i t e X P M I m a g e                                                 %
%                                                                             %
%                                                                             %
%                                                                             %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  WriteXPMImage() writes an image to a file in the X pixmap format.
%
%  The format of the WriteXPMImage method is:
%
%      MagickBooleanType WriteXPMImage(const ImageInfo *image_info,
%        Image *image,ExceptionInfo *exception)
%
%  A description of each parameter follows.
%
%    o image_info: the image info.
%
%    o image:  The image.
%
%    o exception: return any errors or warnings in this structure.
%
*/
static MagickBooleanType WriteXPMImage(const ImageInfo *image_info,Image *image,
                                       ExceptionInfo *exception)
{
#define MaxCixels  92

    static const char
    Cixel[MaxCixels+1] = " .XoO+@#$%&*=-;:>,<1234567890qwertyuipasdfghjk"
                         "lzxcvbnmMNBVCZASDFGHJKLPIUYTREWQ!~^/()_`'][{}|";

    char
    buffer[MaxTextExtent],
           basename[MaxTextExtent],
           name[MaxTextExtent],
           symbol[MaxTextExtent];

    MagickBooleanType
    status;

    PixelInfo
    pixel;

    register const Quantum
    *p;

    register ssize_t
    i,
    x;

    size_t
    characters_per_pixel;

    ssize_t
    j,
    k,
    opacity,
    y;

    /*
      Open output image file.
    */
    assert(image_info != (const ImageInfo *) NULL);
    assert(image_info->signature == MagickSignature);
    assert(image != (Image *) NULL);
    assert(image->signature == MagickSignature);
    if (image->debug != MagickFalse)
        (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
    assert(exception != (ExceptionInfo *) NULL);
    assert(exception->signature == MagickSignature);
    status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
    if (status == MagickFalse)
        return(status);
    if (IsRGBColorspace(image->colorspace) == MagickFalse)
        (void) TransformImageColorspace(image,sRGBColorspace,exception);
    opacity=(-1);
    if (image->matte == MagickFalse)
    {
        if ((image->storage_class == DirectClass) || (image->colors > 256))
            (void) SetImageType(image,PaletteType,exception);
    }
    else
    {
        MagickRealType
        alpha,
        beta;

        /*
          Identify transparent colormap index.
        */
        if ((image->storage_class == DirectClass) || (image->colors > 256))
            (void) SetImageType(image,PaletteBilevelMatteType,exception);
        for (i=0; i < (ssize_t) image->colors; i++)
            if (image->colormap[i].alpha != OpaqueAlpha)
            {
                if (opacity < 0)
                {
                    opacity=i;
                    continue;
                }
                alpha=(MagickRealType) TransparentAlpha-(MagickRealType)
                      image->colormap[i].alpha;
                beta=(MagickRealType) TransparentAlpha-(MagickRealType)
                     image->colormap[opacity].alpha;
                if (alpha < beta)
                    opacity=i;
            }
        if (opacity == -1)
        {
            (void) SetImageType(image,PaletteBilevelMatteType,exception);
            for (i=0; i < (ssize_t) image->colors; i++)
                if (image->colormap[i].alpha != OpaqueAlpha)
                {
                    if (opacity < 0)
                    {
                        opacity=i;
                        continue;
                    }
                    alpha=(Quantum) TransparentAlpha-(MagickRealType)
                          image->colormap[i].alpha;
                    beta=(Quantum) TransparentAlpha-(MagickRealType)
                         image->colormap[opacity].alpha;
                    if (alpha < beta)
                        opacity=i;
                }
        }
        if (opacity >= 0)
        {
            image->colormap[opacity].red=image->transparent_color.red;
            image->colormap[opacity].green=image->transparent_color.green;
            image->colormap[opacity].blue=image->transparent_color.blue;
        }
    }
    /*
      Compute the character per pixel.
    */
    characters_per_pixel=1;
    for (k=MaxCixels; (ssize_t) image->colors > k; k*=MaxCixels)
        characters_per_pixel++;
    /*
      XPM header.
    */
    (void) WriteBlobString(image,"/* XPM */\n");
    GetPathComponent(image->filename,BasePath,basename);
    if (isalnum((int) ((unsigned char) *basename)) == 0)
    {
        (void) FormatLocaleString(buffer,MaxTextExtent,"xpm_%s",basename);
        (void) CopyMagickString(basename,buffer,MaxTextExtent);
    }
    if (isalpha((int) ((unsigned char) basename[0])) == 0)
        basename[0]='_';
    for (i=1; basename[i] != '\0'; i++)
        if (isalnum((int) ((unsigned char) basename[i])) == 0)
            basename[i]='_';
    (void) FormatLocaleString(buffer,MaxTextExtent,
                              "static char *%s[] = {\n",basename);
    (void) WriteBlobString(image,buffer);
    (void) WriteBlobString(image,"/* columns rows colors chars-per-pixel */\n");
    (void) FormatLocaleString(buffer,MaxTextExtent,
                              "\"%.20g %.20g %.20g %.20g \",\n",(double) image->columns,(double)
                              image->rows,(double) image->colors,(double) characters_per_pixel);
    (void) WriteBlobString(image,buffer);
    GetPixelInfo(image,&pixel);
    for (i=0; i < (ssize_t) image->colors; i++)
    {
        /*
          Define XPM color.
        */
        pixel=image->colormap[i];
        pixel.colorspace=RGBColorspace;
        pixel.depth=8;
        pixel.alpha=(MagickRealType) OpaqueAlpha;
        (void) QueryColorname(image,&pixel,XPMCompliance,name,exception);
        if (i == opacity)
            (void) CopyMagickString(name,"None",MaxTextExtent);
        /*
          Write XPM color.
        */
        k=i % MaxCixels;
        symbol[0]=Cixel[k];
        for (j=1; j < (ssize_t) characters_per_pixel; j++)
        {
            k=((i-k)/MaxCixels) % MaxCixels;
            symbol[j]=Cixel[k];
        }
        symbol[j]='\0';
        (void) FormatLocaleString(buffer,MaxTextExtent,"\"%s c %s\",\n",symbol,
                                  name);
        (void) WriteBlobString(image,buffer);
    }
    /*
      Define XPM pixels.
    */
    (void) WriteBlobString(image,"/* pixels */\n");
    for (y=0; y < (ssize_t) image->rows; y++)
    {
        p=GetVirtualPixels(image,0,y,image->columns,1,exception);
        if (p == (const Quantum *) NULL)
            break;
        (void) WriteBlobString(image,"\"");
        for (x=0; x < (ssize_t) image->columns; x++)
        {
            k=((ssize_t) GetPixelIndex(image,p) % MaxCixels);
            symbol[0]=Cixel[k];
            for (j=1; j < (ssize_t) characters_per_pixel; j++)
            {
                k=(((int) GetPixelIndex(image,p)-k)/MaxCixels) % MaxCixels;
                symbol[j]=Cixel[k];
            }
            symbol[j]='\0';
            (void) CopyMagickString(buffer,symbol,MaxTextExtent);
            (void) WriteBlobString(image,buffer);
            p+=GetPixelChannels(image);
        }
        (void) FormatLocaleString(buffer,MaxTextExtent,"\"%s\n",
                                  (y == (ssize_t) (image->rows-1) ? "" : ","));
        (void) WriteBlobString(image,buffer);
        if (image->previous == (Image *) NULL)
        {
            status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
                                    image->rows);
            if (status == MagickFalse)
                break;
        }
    }
    (void) WriteBlobString(image,"};\n");
    (void) CloseBlob(image);
    return(MagickTrue);
}
Пример #5
0
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                             %
%                                                                             %
%                                                                             %
%   D e s c r i b e I m a g e                                                 %
%                                                                             %
%                                                                             %
%                                                                             %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  DescribeImage() describes an image by printing its attributes to the file.
%  Attributes include the image width, height, size, and others.
%
%  The format of the DescribeImage method is:
%
%      void DescribeImage(Image *image,FILE *file,const MagickBool verbose)
%
%  A description of each parameter follows:
%
%    o image: The image.
%
%    o file: The file, typically stdout.
%
%    o verbose: A value other than zero prints more detailed information
%      about the image. Values greater than one enable counting the number of
%      colors in the image.
%
%
*/
MagickExport MagickPassFail DescribeImage(Image *image,FILE *file,
        const MagickBool verbose)
{
    char
    color[MaxTextExtent],
          format[MaxTextExtent];

    const unsigned char
    *profile;

    size_t
    profile_length;

    const ImageAttribute
    *attribute;

    const MagickInfo
    *magick_info;

    double
    elapsed_time,
    user_time;

    unsigned long
    columns,
    rows;

    magick_int64_t
    pixels_per_second;

    Image
    *p;

    long
    y;

    register long
    i,
    x;

    unsigned long
    count;

    assert(image != (Image *) NULL);
    assert(image->signature == MagickSignature);
    assert(file != (FILE *) NULL);
    elapsed_time=GetElapsedTime(&image->timer);
    user_time=GetUserTime(&image->timer);
    GetTimerInfo(&image->timer);
    if (!verbose)
    {
        /*
          Display summary info about the image.
        */
        if (*image->magick_filename != '\0')
            if (LocaleCompare(image->magick_filename,image->filename) != 0)
                (void) fprintf(file,"%.1024s=>",image->magick_filename);
        if ((image->previous == (Image *) NULL) &&
                (image->next == (Image *) NULL) && (image->scene == 0))
            (void) fprintf(file,"%.1024s ",image->filename);
        else
            (void) fprintf(file,"%.1024s[%lu] ",image->filename,image->scene);
        (void) fprintf(file,"%.1024s ",image->magick);
        columns=image->columns;
        rows=image->rows;
        if ((image->magick_columns != 0) || (image->magick_rows != 0))
            if ((image->magick_columns != image->columns) ||
                    (image->magick_rows != image->rows))
            {
                columns=image->magick_columns;
                rows=image->magick_rows;
                (void) fprintf(file,"%lux%lu=>",image->magick_columns,
                               image->magick_rows);
            }
        (void) fprintf(file,"%lux%lu%+ld%+ld ",image->columns,image->rows,
                       image->page.x,image->page.y);
        if (image->storage_class == DirectClass)
        {
            (void) fprintf(file,"DirectClass ");
            if (image->total_colors != 0)
            {
                FormatSize(image->total_colors,format);
                (void) fprintf(file,"%.1024s ",format);
            }
        }
        else if (image->total_colors <= image->colors)
            (void) fprintf(file,"PseudoClass %uc ",image->colors);
        else
        {
            (void) fprintf(file,"PseudoClass %lu=>%uc ",image->total_colors,
                           image->colors);
            (void) fprintf(file,"%ld/%.6f/%.6fe ",
                           (long) image->error.mean_error_per_pixel,
                           image->error.normalized_mean_error,
                           image->error.normalized_maximum_error);
        }
        (void) fprintf(file,"%u-bit ",image->depth);
        if (GetBlobSize(image) != 0)
        {
            FormatSize(GetBlobSize(image),format);
            (void) fprintf(file,"%.1024s ",format);
        }
        (void) fprintf(file,"%0.3fu %ld:%02ld",user_time,
                       (long) (elapsed_time/60.0),
                       (long) ceil(fmod(elapsed_time,60.0)));
        /*
          Only display pixel read rate if the time accumulated is at
          least six times the timer's resolution (typically 0.01 on
          Unix).
        */
        if (elapsed_time >= GetTimerResolution()*6)
        {
            pixels_per_second=(magick_int64_t) ((double) rows*columns/ elapsed_time);
            FormatSize(pixels_per_second,format);
            (void) fprintf(file," (%s pixels/s)",format);
        }
        (void) fprintf(file,"\n");

        return (ferror(file) ? MagickFail : MagickPass);
    }
    /*
      Display verbose info about the image.
    */
    (void) SignatureImage(image);
    if (verbose > 1)
        image->total_colors=GetNumberColors(image,(FILE *) NULL,&image->exception);
    (void) fprintf(file,"Image: %.1024s\n",image->filename);
    magick_info=GetMagickInfo(image->magick,&image->exception);
    if ((magick_info == (const MagickInfo *) NULL) ||
            (*magick_info->description == '\0'))
        (void) fprintf(file,"  Format: %.1024s\n",image->magick);
    else
        (void) fprintf(file,"  Format: %.1024s (%.1024s)\n",image->magick,
                       magick_info->description);
    (void) fprintf(file,"  Geometry: %lux%lu\n",image->columns,image->rows);
    if (image->storage_class == DirectClass)
        (void) fprintf(file,"  Class: DirectClass\n");
    else
        (void) fprintf(file,"  Class: PseudoClass\n");
    if ((image->magick_columns != 0) || (image->magick_rows != 0))
        if ((image->magick_columns != image->columns) ||
                (image->magick_rows != image->rows))
            (void) fprintf(file,"  Base geometry: %lux%lu\n",image->magick_columns,
                           image->magick_rows);
    (void) fprintf(file,"  Type: ");
    switch (GetImageType(image,&image->exception))
    {
    case BilevelType:
        (void) fprintf(file,"bilevel");
        break;
    case GrayscaleType:
        (void) fprintf(file,"grayscale");
        break;
    case GrayscaleMatteType:
        (void) fprintf(file,"grayscale with transparency");
        break;
    case PaletteType:
        (void) fprintf(file,"palette");
        break;
    case PaletteMatteType:
        (void) fprintf(file,"palette with transparency");
        break;
    case TrueColorType:
        (void) fprintf(file,"true color");
        break;
    case TrueColorMatteType:
        (void) fprintf(file,"true color with transparency");
        break;
    case ColorSeparationType:
        (void) fprintf(file,"color separated");
        break;
    case ColorSeparationMatteType:
        (void) fprintf(file,"color separated with transparency");
        break;
    default:
        (void) fprintf(file,"undefined");
        break;
    }
    (void) fprintf(file,"\n");
    (void) fprintf(file,"  Depth: %lu bits-per-pixel component\n",
                   GetImageDepth(image,&image->exception));
    (void) fprintf(file,"  Channel Depths:\n");
    if (image->colorspace == CMYKColorspace)
    {
        (void) fprintf(file,"    Cyan:     %u bits\n",
                       GetImageChannelDepth(image,CyanChannel,&image->exception));
        (void) fprintf(file,"    Magenta:  %u bits\n",
                       GetImageChannelDepth(image,MagentaChannel,&image->exception));
        (void) fprintf(file,"    Yellow:   %u bits\n",
                       GetImageChannelDepth(image,YellowChannel,&image->exception));
        (void) fprintf(file,"    Black:    %u bits\n",
                       GetImageChannelDepth(image,BlackChannel,&image->exception));
    }
    else if ((IsGrayColorspace(image->colorspace)) ||
             (image->is_grayscale == True))
    {
        (void) fprintf(file,"    Gray:     %u bits\n",
                       GetImageChannelDepth(image,RedChannel,&image->exception));
    }
    else
    {
        (void) fprintf(file,"    Red:      %u bits\n",
                       GetImageChannelDepth(image,RedChannel,&image->exception));
        (void) fprintf(file,"    Green:    %u bits\n",
                       GetImageChannelDepth(image,GreenChannel,&image->exception));
        (void) fprintf(file,"    Blue:     %u bits\n",
                       GetImageChannelDepth(image,BlueChannel,&image->exception));
    }
    if (image->matte)
        (void) fprintf(file,"    Opacity:  %u bits\n",
                       GetImageChannelDepth(image,OpacityChannel,&image->exception));
    (void) fprintf(file,"  Channel Statistics:\n");
    {
        ImageStatistics
        statistics;

        (void) GetImageStatistics(image,&statistics,&image->exception);

        if (image->colorspace == CMYKColorspace)
        {
            (void) fprintf(file,"    Cyan:\n");
            (void) fprintf(file,"      Minimum:            %13.02lf (%1.4f)\n",
                           MaxRGB*statistics.red.minimum,
                           statistics.red.minimum);
            (void) fprintf(file,"      Maximum:            %13.02lf (%1.4f)\n",
                           MaxRGB*statistics.red.maximum,
                           statistics.red.maximum);
            (void) fprintf(file,"      Mean:               %13.02lf (%1.4f)\n",
                           MaxRGB*statistics.red.mean,
                           statistics.red.mean);
            (void) fprintf(file,"      Standard Deviation: %13.02lf (%1.4f)\n",
                           MaxRGB*statistics.red.standard_deviation,
                           statistics.red.standard_deviation);
            (void) fprintf(file,"    Magenta:\n");
            (void) fprintf(file,"      Minimum:            %13.02lf (%1.4f)\n",
                           MaxRGB*statistics.green.minimum,
                           statistics.green.minimum);
            (void) fprintf(file,"      Maximum:            %13.02lf (%1.4f)\n",
                           MaxRGB*statistics.green.maximum,
                           statistics.green.maximum);
            (void) fprintf(file,"      Mean:               %13.02lf (%1.4f)\n",
                           MaxRGB*statistics.green.mean,
                           statistics.green.mean);
            (void) fprintf(file,"      Standard Deviation: %13.02lf (%1.4f)\n",
                           MaxRGB*statistics.green.standard_deviation,
                           statistics.green.standard_deviation);
            (void) fprintf(file,"    Yellow:\n");
            (void) fprintf(file,"      Minimum:            %13.02lf (%1.4f)\n",
                           MaxRGB*statistics.blue.minimum,
                           statistics.blue.minimum);
            (void) fprintf(file,"      Maximum:            %13.02lf (%1.4f)\n",
                           MaxRGB*statistics.blue.maximum,
                           statistics.blue.maximum);
            (void) fprintf(file,"      Mean:               %13.02lf (%1.4f)\n",
                           MaxRGB*statistics.blue.mean,
                           statistics.blue.mean);
            (void) fprintf(file,"      Standard Deviation: %13.02lf (%1.4f)\n",
                           MaxRGB*statistics.blue.standard_deviation,
                           statistics.blue.standard_deviation);
            (void) fprintf(file,"    Black:\n");
            (void) fprintf(file,"      Minimum:            %13.02lf (%1.4f)\n",
                           MaxRGB*statistics.opacity.minimum,
                           statistics.opacity.minimum);
            (void) fprintf(file,"      Maximum:            %13.02lf (%1.4f)\n",
                           MaxRGB*statistics.opacity.maximum,
                           statistics.opacity.maximum);
            (void) fprintf(file,"      Mean:               %13.02lf (%1.4f)\n",
                           MaxRGB*statistics.opacity.mean,
                           statistics.opacity.mean);
            (void) fprintf(file,"      Standard Deviation: %13.02lf (%1.4f)\n",
                           MaxRGB*statistics.opacity.standard_deviation,
                           statistics.opacity.standard_deviation);
            /*
            if (image->matte)
              (void) fprintf(file,"    Opacity:\n");
            */
        }
        else if ((IsGrayColorspace(image->colorspace)) ||
                 (image->is_grayscale == True))
        {
            (void) fprintf(file,"    Gray:\n");
            (void) fprintf(file,"      Minimum:            %13.02lf (%1.4f)\n",
                           MaxRGB*statistics.red.minimum,
                           statistics.red.minimum);
            (void) fprintf(file,"      Maximum:            %13.02lf (%1.4f)\n",
                           MaxRGB*statistics.red.maximum,
                           statistics.red.maximum);
            (void) fprintf(file,"      Mean:               %13.02lf (%1.4f)\n",
                           MaxRGB*statistics.red.mean,
                           statistics.red.mean);
            (void) fprintf(file,"      Standard Deviation: %13.02lf (%1.4f)\n",
                           MaxRGB*statistics.red.standard_deviation,
                           statistics.red.standard_deviation);
            if (image->matte)
            {
                (void) fprintf(file,"    Opacity:\n");
                (void) fprintf(file,"      Minimum:            %13.02lf (%1.4f)\n",
                               MaxRGB*statistics.opacity.minimum,
                               statistics.opacity.minimum);
                (void) fprintf(file,"      Maximum:            %13.02lf (%1.4f)\n",
                               MaxRGB*statistics.opacity.maximum,
                               statistics.opacity.maximum);
                (void) fprintf(file,"      Mean:               %13.02lf (%1.4f)\n",
                               MaxRGB*statistics.opacity.mean,
                               statistics.opacity.mean);
                (void) fprintf(file,"      Standard Deviation: %13.02lf (%1.4f)\n",
                               MaxRGB*statistics.opacity.standard_deviation,
                               statistics.opacity.standard_deviation);
            }
        }
        else
        {
            (void) fprintf(file,"    Red:\n");
            (void) fprintf(file,"      Minimum:            %13.02lf (%1.4f)\n",
                           MaxRGB*statistics.red.minimum,
                           statistics.red.minimum);
            (void) fprintf(file,"      Maximum:            %13.02lf (%1.4f)\n",
                           MaxRGB*statistics.red.maximum,
                           statistics.red.maximum);
            (void) fprintf(file,"      Mean:               %13.02lf (%1.4f)\n",
                           MaxRGB*statistics.red.mean,
                           statistics.red.mean);
            (void) fprintf(file,"      Standard Deviation: %13.02lf (%1.4f)\n",
                           MaxRGB*statistics.red.standard_deviation,
                           statistics.red.standard_deviation);
            (void) fprintf(file,"    Green:\n");
            (void) fprintf(file,"      Minimum:            %13.02lf (%1.4f)\n",
                           MaxRGB*statistics.green.minimum,
                           statistics.green.minimum);
            (void) fprintf(file,"      Maximum:            %13.02lf (%1.4f)\n",
                           MaxRGB*statistics.green.maximum,
                           statistics.green.maximum);
            (void) fprintf(file,"      Mean:               %13.02lf (%1.4f)\n",
                           MaxRGB*statistics.green.mean,
                           statistics.green.mean);
            (void) fprintf(file,"      Standard Deviation: %13.02lf (%1.4f)\n",
                           MaxRGB*statistics.green.standard_deviation,
                           statistics.green.standard_deviation);
            (void) fprintf(file,"    Blue:\n");
            (void) fprintf(file,"      Minimum:            %13.02lf (%1.4f)\n",
                           MaxRGB*statistics.blue.minimum,
                           statistics.blue.minimum);
            (void) fprintf(file,"      Maximum:            %13.02lf (%1.4f)\n",
                           MaxRGB*statistics.blue.maximum,
                           statistics.blue.maximum);
            (void) fprintf(file,"      Mean:               %13.02lf (%1.4f)\n",
                           MaxRGB*statistics.blue.mean,
                           statistics.blue.mean);
            (void) fprintf(file,"      Standard Deviation: %13.02lf (%1.4f)\n",
                           MaxRGB*statistics.blue.standard_deviation,
                           statistics.blue.standard_deviation);
            if (image->matte)
            {
                (void) fprintf(file,"    Opacity:\n");
                (void) fprintf(file,"      Minimum:            %13.02lf (%1.4f)\n",
                               MaxRGB*statistics.opacity.minimum,
                               statistics.opacity.minimum);
                (void) fprintf(file,"      Maximum:            %13.02lf (%1.4f)\n",
                               MaxRGB*statistics.opacity.maximum,
                               statistics.opacity.maximum);
                (void) fprintf(file,"      Mean:               %13.02lf (%1.4f)\n",
                               MaxRGB*statistics.opacity.mean,
                               statistics.opacity.mean);
                (void) fprintf(file,"      Standard Deviation: %13.02lf (%1.4f)\n",
                               MaxRGB*statistics.opacity.standard_deviation,
                               statistics.opacity.standard_deviation);
            }
        }
    }
    x=0;
    p=(Image *) NULL;
    if ((image->matte && (strcmp(image->magick,"GIF") != 0)) || image->taint)
    {
        char
        tuple[MaxTextExtent];

        register const PixelPacket
        *p;

        p=(PixelPacket *) NULL;
        for (y=0; y < (long) image->rows; y++)
        {
            p=AcquireImagePixels(image,0,y,image->columns,1,&image->exception);
            if (p == (const PixelPacket *) NULL)
                break;
            for (x=0; x < (long) image->columns; x++)
            {
                if (p->opacity == TransparentOpacity)
                    break;
                p++;
            }
            if (x < (long) image->columns)
                break;
        }
        if ((x < (long) image->columns) || (y < (long) image->rows))
        {
            GetColorTuple(p,image->depth,image->matte,False,tuple);
            (void) fprintf(file,"  Opacity: %.1024s\t",tuple);
            GetColorTuple(p,image->depth,image->matte,True,tuple);
            (void) fprintf(file,"  %.1024s\n",tuple);
        }
    }
    if (image->storage_class == DirectClass)
    {
        if (image->total_colors != 0)
            (void) fprintf(file,"  Colors: %lu\n",image->total_colors);
    }
    else
    {
        if (image->total_colors <= image->colors)
            (void) fprintf(file,"  Colors: %u\n",image->colors);
        else
            (void) fprintf(file,"  Colors: %lu=>%u\n",image->total_colors,
                           image->colors);
    }
    if (image->storage_class == DirectClass)
    {
        if (image->total_colors < 1024)
            if (verbose > 1)
                (void) GetNumberColors(image,file,&image->exception);
    }
    else
    {
        char
        name[MaxTextExtent];

        register PixelPacket
        *p;

        /*
          Display image colormap.
        */
        p=image->colormap;
        for (i=0; i < (long) image->colors; i++)
        {
            char
            tuple[MaxTextExtent];

            GetColorTuple(p,image->depth,image->matte,False,tuple);
            (void) fprintf(file,"    %lu: %.1024s",i,tuple);
            (void) fprintf(file,"\t");
            (void) QueryColorname(image,p,SVGCompliance,name,&image->exception);
            (void) fprintf(file,"  %.1024s",name);
            (void) fprintf(file,"\n");
            p++;
        }
    }
    if (image->error.mean_error_per_pixel != 0.0)
        (void) fprintf(file,"  Mean Exception Per Pixel: %ld\n",
                       (long) image->error.mean_error_per_pixel);
    if (image->error.normalized_mean_error != 0.0)
        (void) fprintf(file,"  Normalized Mean Exception: %g\n",
                       image->error.normalized_mean_error);
    if (image->error.normalized_maximum_error != 0.0)
        (void) fprintf(file,"  Normalized Maximum Exception: %gn",
                       image->error.normalized_maximum_error);
    if (image->rendering_intent == SaturationIntent)
        (void) fprintf(file,"  Rendering-Intent: saturation\n");
    else if (image->rendering_intent == PerceptualIntent)
        (void) fprintf(file,"  Rendering-Intent: perceptual\n");
    else if (image->rendering_intent == AbsoluteIntent)
        (void) fprintf(file,"  Rendering-Intent: absolute\n");
    else if (image->rendering_intent == RelativeIntent)
        (void) fprintf(file,"  Rendering-Intent: relative\n");
    if (image->gamma != 0.0)
        (void) fprintf(file,"  Gamma: %g\n",image->gamma);
    if ((image->chromaticity.red_primary.x != 0.0) ||
            (image->chromaticity.green_primary.x != 0.0) ||
            (image->chromaticity.blue_primary.x != 0.0) ||
            (image->chromaticity.white_point.x != 0.0))
    {
        /*
          Display image chromaticity.
        */
        (void) fprintf(file,"  Chromaticity:\n");
        (void) fprintf(file,"    red primary: (%g,%g)\n",
                       image->chromaticity.red_primary.x,image->chromaticity.red_primary.y);
        (void) fprintf(file,"    green primary: (%g,%g)\n",
                       image->chromaticity.green_primary.x,
                       image->chromaticity.green_primary.y);
        (void) fprintf(file,"    blue primary: (%g,%g)\n",
                       image->chromaticity.blue_primary.x,image->chromaticity.blue_primary.y);
        (void) fprintf(file,"    white point: (%g,%g)\n",
                       image->chromaticity.white_point.x,image->chromaticity.white_point.y);
    }
    if ((image->tile_info.width*image->tile_info.height) != 0)
        (void) fprintf(file,"  Tile geometry: %lux%lu%+ld%+ld\n",
                       image->tile_info.width,image->tile_info.height,image->tile_info.x,
                       image->tile_info.y);
    if ((image->x_resolution != 0.0) && (image->y_resolution != 0.0))
    {
        /*
          Display image resolution.
        */
        (void) fprintf(file,"  Resolution: %gx%g",image->x_resolution,
                       image->y_resolution);
        if (image->units == UndefinedResolution)
            (void) fprintf(file," pixels\n");
        else if (image->units == PixelsPerInchResolution)
            (void) fprintf(file," pixels/inch\n");
        else if (image->units == PixelsPerCentimeterResolution)
            (void) fprintf(file," pixels/centimeter\n");
        else
            (void) fprintf(file,"\n");
    }
    FormatSize(GetBlobSize(image),format);
    (void) fprintf(file,"  Filesize: %.1024s\n",format);
    fprintf(file,"  Interlace: %s\n",
            InterlaceTypeToString(image->interlace == UndefinedInterlace ?
                                  NoInterlace : image->interlace));
    (void) fprintf(file,"  Orientation: %s\n", OrientationTypeToString(image->orientation));
    (void) QueryColorname(image,&image->background_color,SVGCompliance,color,
                          &image->exception);
    (void) fprintf(file,"  Background Color: %.1024s\n",color);
    (void) QueryColorname(image,&image->border_color,SVGCompliance,color,
                          &image->exception);
    (void) fprintf(file,"  Border Color: %.1024s\n",color);
    (void) QueryColorname(image,&image->matte_color,SVGCompliance,color,
                          &image->exception);
    (void) fprintf(file,"  Matte Color: %.1024s\n",color);
    if ((image->page.width != 0) && (image->page.height != 0))
        (void) fprintf(file,"  Page geometry: %lux%lu%+ld%+ld\n",image->page.width,
                       image->page.height,image->page.x,image->page.y);
    (void) fprintf(file,"  Compose: %s\n",
                   CompositeOperatorToString(image->compose));
    (void) fprintf(file,"  Dispose: ");
    switch (image->dispose)
    {
    case UndefinedDispose:
        (void) fprintf(file,"Undefined\n");
        break;
    case NoneDispose:
        (void) fprintf(file,"None\n");
        break;
    case BackgroundDispose:
        (void) fprintf(file,"Background\n");
        break;
    case PreviousDispose:
        (void) fprintf(file,"Previous\n");
        break;
    default:
        (void) fprintf(file,"\n");
        break;
    }
    if (image->delay != 0)
        (void) fprintf(file,"  Delay: %lu\n",image->delay);
    if (image->iterations != 1)
        (void) fprintf(file,"  Iterations: %lu\n",image->iterations);
    p=image;
    while (p->previous != (Image *) NULL)
        p=p->previous;
    for (count=1; p->next != (Image *) NULL; count++)
        p=p->next;
    if (count > 1)
        (void) fprintf(file,"  Scene: %lu of %lu\n",image->scene,count);
    else if (image->scene != 0)
        (void) fprintf(file,"  Scene: %lu\n",image->scene);
    (void) fprintf(file,"  Compression: %s\n",
                   CompressionTypeToString(image->compression));
    /*
      Display formatted image attributes. This must happen before we access
      any pseudo attributes like EXIF since doing so causes real attributes
      to be created and we would get duplicates in the output.
    */
    attribute=GetImageAttribute(image,(char *) NULL);
    {
        for ( ; attribute != (const ImageAttribute *) NULL; attribute=attribute->next)
        {
            if (LocaleNCompare("EXIF",attribute->key,4) != 0)
            {
                (void) fprintf(file,"  %c", toupper((int)attribute->key[0]));
                if (strlen(attribute->key) > 1)
                    (void) fprintf(file,"%.1024s",attribute->key+1);

                (void) fprintf(file,": ");
                (void) fprintf(file,"%s\n",attribute->value);
            }
        }
    }
    if((profile=GetImageProfile(image,"ICM",&profile_length)) != 0)
        (void) fprintf(file,"  Profile-color: %lu bytes\n",(unsigned long)
                       profile_length);
    if((profile=GetImageProfile(image,"IPTC",&profile_length)) != 0)
    {
        char
        *tag,
        *text;

        size_t
        length;

        /*
          Describe IPTC data.
        */
        (void) fprintf(file,"  Profile-iptc: %lu bytes\n",(unsigned long)
                       profile_length);
        for (i=0; i < (long) profile_length; )
        {
            if (profile[i] != 0x1c)
            {
                i++;
                continue;
            }
            i++;  /* skip file separator */
            i++;  /* skip record number */
            switch (profile[i])
            {
            case 5:
                tag=(char *) "Image Name";
                break;
            case 7:
                tag=(char *) "Edit Status";
                break;
            case 10:
                tag=(char *) "Priority";
                break;
            case 15:
                tag=(char *) "Category";
                break;
            case 20:
                tag=(char *) "Supplemental Category";
                break;
            case 22:
                tag=(char *) "Fixture Identifier";
                break;
            case 25:
                tag=(char *) "Keyword";
                break;
            case 30:
                tag=(char *) "Release Date";
                break;
            case 35:
                tag=(char *) "Release Time";
                break;
            case 40:
                tag=(char *) "Special Instructions";
                break;
            case 45:
                tag=(char *) "Reference Service";
                break;
            case 47:
                tag=(char *) "Reference Date";
                break;
            case 50:
                tag=(char *) "Reference Number";
                break;
            case 55:
                tag=(char *) "Created Date";
                break;
            case 60:
                tag=(char *) "Created Time";
                break;
            case 65:
                tag=(char *) "Originating Program";
                break;
            case 70:
                tag=(char *) "Program Version";
                break;
            case 75:
                tag=(char *) "Object Cycle";
                break;
            case 80:
                tag=(char *) "Byline";
                break;
            case 85:
                tag=(char *) "Byline Title";
                break;
            case 90:
                tag=(char *) "City";
                break;
            case 95:
                tag=(char *) "Province State";
                break;
            case 100:
                tag=(char *) "Country Code";
                break;
            case 101:
                tag=(char *) "Country";
                break;
            case 103:
                tag=(char *) "Original Transmission Reference";
                break;
            case 105:
                tag=(char *) "Headline";
                break;
            case 110:
                tag=(char *) "Credit";
                break;
            case 115:
                tag=(char *) "Source";
                break;
            case 116:
                tag=(char *) "Copyright String";
                break;
            case 120:
                tag=(char *) "Caption";
                break;
            case 121:
                tag=(char *) "Local Caption";
                break;
            case 122:
                tag=(char *) "Caption Writer";
                break;
            case 200:
                tag=(char *) "Custom Field 1";
                break;
            case 201:
                tag=(char *) "Custom Field 2";
                break;
            case 202:
                tag=(char *) "Custom Field 3";
                break;
            case 203:
                tag=(char *) "Custom Field 4";
                break;
            case 204:
                tag=(char *) "Custom Field 5";
                break;
            case 205:
                tag=(char *) "Custom Field 6";
                break;
            case 206:
                tag=(char *) "Custom Field 7";
                break;
            case 207:
                tag=(char *) "Custom Field 8";
                break;
            case 208:
                tag=(char *) "Custom Field 9";
                break;
            case 209:
                tag=(char *) "Custom Field 10";
                break;
            case 210:
                tag=(char *) "Custom Field 11";
                break;
            case 211:
                tag=(char *) "Custom Field 12";
                break;
            case 212:
                tag=(char *) "Custom Field 13";
                break;
            case 213:
                tag=(char *) "Custom Field 14";
                break;
            case 214:
                tag=(char *) "Custom Field 15";
                break;
            case 215:
                tag=(char *) "Custom Field 16";
                break;
            case 216:
                tag=(char *) "Custom Field 17";
                break;
            case 217:
                tag=(char *) "Custom Field 18";
                break;
            case 218:
                tag=(char *) "Custom Field 19";
                break;
            case 219:
                tag=(char *) "Custom Field 20";
                break;
            default:
                tag=(char *) "unknown";
                break;
            }
            i++;
            (void) fprintf(file,"    %.1024s:\n",tag);
            length=profile[i++] << 8;
            length|=profile[i++];
            text=MagickAllocateMemory(char *,length+1);
            if (text != (char *) NULL)
            {
                char
                **textlist;

                register long
                j;

                (void) strncpy(text,(char *) profile+i,length);
                text[length]='\0';
                textlist=StringToList(text);
                if (textlist != (char **) NULL)
                {
                    for (j=0; textlist[j] != (char *) NULL; j++)
                    {
                        (void) fprintf(file,"  %s\n",textlist[j]);
                        MagickFreeMemory(textlist[j]);
                    }
                    MagickFreeMemory(textlist);
                }
                MagickFreeMemory(text);
            }
            i+=length;
        }
    }