bool trpgTexture::GetNumLayer(int &layers) const { if (!isValid()) return false; GetImageDepth(layers); return true; }
// Read function bool trpgTexture::Read(trpgReadBuffer &buf) { char texName[1024]; try { buf.Get(texName,1023); SetName(texName); buf.Get(useCount); mode = External; // New in 2.0 from here down unsigned char bval; buf.Get(bval); mode = (trpgTexture::ImageMode)bval; buf.Get(bval); type = (trpgTexture::ImageType)bval; GetImageDepth(numLayer); // heh buf.Get(sizeX); buf.Get(sizeY); buf.Get(addr.file); buf.Get(addr.offset); int32 ival; buf.Get(ival); // Read the handle if we can.. try { int32 tempHandle; if(buf.Get(tempHandle)) { writeHandle = true; handle = tempHandle; } else { handle = -1; } } catch (...) { handle = -1; } isMipmap = (ival) ? true : false; } catch (...) { return false; } if (!isValid()) return false; // calculate the mip level sizes CalcMipLevelSizes(); return true; }
MagickExport MagickBooleanType SetImageChannelDepth(Image *image, const ChannelType channel,const unsigned long depth) { CacheView *image_view; ExceptionInfo *exception; long y; MagickBooleanType status; QuantumAny range; assert(image != (Image *) NULL); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); assert(image->signature == MagickSignature); if (GetImageDepth(image,&image->exception) <= (unsigned long) MagickMin((double) depth,(double) MAGICKCORE_QUANTUM_DEPTH)) { image->depth=depth; return(MagickTrue); } /* Scale pixels to desired depth. */ status=MagickTrue; range=GetQuantumRange(depth); exception=(&image->exception); image_view=AcquireCacheView(image); #if defined(MAGICKCORE_OPENMP_SUPPORT) #pragma omp parallel for schedule(dynamic,4) shared(status) #endif for (y=0; y < (long) image->rows; y++) { register IndexPacket *restrict indexes; register long x; register PixelPacket *restrict q; if (status == MagickFalse) continue; q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1, exception); if (q == (PixelPacket *) NULL) { status=MagickFalse; continue; } indexes=GetCacheViewAuthenticIndexQueue(image_view); for (x=0; x < (long) image->columns; x++) { if ((channel & RedChannel) != 0) q->red=ScaleAnyToQuantum(ScaleQuantumToAny(q->red,range),range); if ((channel & GreenChannel) != 0) q->green=ScaleAnyToQuantum(ScaleQuantumToAny(q->green,range),range); if ((channel & BlueChannel) != 0) q->blue=ScaleAnyToQuantum(ScaleQuantumToAny(q->blue,range),range); if (((channel & OpacityChannel) != 0) && (image->matte != MagickFalse)) q->opacity=ScaleAnyToQuantum(ScaleQuantumToAny(q->opacity,range),range); if (((channel & IndexChannel) != 0) && (image->colorspace == CMYKColorspace)) indexes[x]=ScaleAnyToQuantum(ScaleQuantumToAny(indexes[x],range),range); q++; } if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse) { status=MagickFalse; continue; } } image_view=DestroyCacheView(image_view); if (image->storage_class == PseudoClass) { QuantumAny range; register long i; register PixelPacket *restrict p; p=image->colormap; range=GetQuantumRange(depth); #if defined(MAGICKCORE_OPENMP_SUPPORT) #pragma omp parallel for schedule(dynamic,4) shared(status) #endif for (i=0; i < (long) image->colors; i++) { if ((channel & RedChannel) != 0) p->red=ScaleAnyToQuantum(ScaleQuantumToAny(p->red,range),range); if ((channel & GreenChannel) != 0) p->green=ScaleAnyToQuantum(ScaleQuantumToAny(p->green,range),range); if ((channel & BlueChannel) != 0) p->blue=ScaleAnyToQuantum(ScaleQuantumToAny(p->blue,range),range); if ((channel & OpacityChannel) != 0) p->opacity=ScaleAnyToQuantum(ScaleQuantumToAny(p->opacity,range), range); p++; } }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % S e t I m a g e D e p t h % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % SetImageDepth() sets the depth of the image. % % The format of the SetImageDepth method is: % % MagickBooleanType SetImageDepth(Image *image,const size_t depth, % ExceptionInfo *exception) % % A description of each parameter follows: % % o image: the image. % % o channel: the channel. % % o depth: the image depth. % % o exception: return any errors or warnings in this structure. % */ MagickExport MagickBooleanType SetImageDepth(Image *image, const size_t depth,ExceptionInfo *exception) { CacheView *image_view; MagickBooleanType status; QuantumAny range; ssize_t y; assert(image != (Image *) NULL); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); assert(image->signature == MagickSignature); if (GetImageDepth(image,exception) <= (size_t) MagickMin((double) depth,(double) MAGICKCORE_QUANTUM_DEPTH)) { image->depth=depth; return(MagickTrue); } /* Scale pixels to desired depth. */ status=MagickTrue; range=GetQuantumRange(depth); image_view=AcquireCacheView(image); #if defined(MAGICKCORE_OPENMP_SUPPORT) #pragma omp parallel for schedule(static,4) shared(status) #endif for (y=0; y < (ssize_t) image->rows; y++) { register ssize_t x; register Quantum *restrict q; if (status == MagickFalse) continue; q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception); if (q == (Quantum *) NULL) { status=MagickFalse; continue; } for (x=0; x < (ssize_t) image->columns; x++) { register ssize_t i; for (i=0; i < (ssize_t) GetPixelChannels(image); i++) { PixelChannel channel; PixelTrait traits; channel=GetPixelChannelMapChannel(image,i); traits=GetPixelChannelMapTraits(image,channel); if (traits == UndefinedPixelTrait) continue; q[i]=ScaleAnyToQuantum(ScaleQuantumToAny(q[i],range),range); } q+=GetPixelChannels(image); } if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse) { status=MagickFalse; continue; } } image_view=DestroyCacheView(image_view); if (image->storage_class == PseudoClass) { register PixelInfo *restrict p; register ssize_t i; p=image->colormap; #if defined(MAGICKCORE_OPENMP_SUPPORT) #pragma omp parallel for schedule(static,4) shared(status) #endif for (i=0; i < (ssize_t) image->colors; i++) { if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) p->red=ScaleAnyToQuantum(ScaleQuantumToAny(p->red,range),range); if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) p->green=ScaleAnyToQuantum(ScaleQuantumToAny(p->green,range),range); if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) p->blue=ScaleAnyToQuantum(ScaleQuantumToAny(p->blue,range),range); if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) p->alpha=ScaleAnyToQuantum(ScaleQuantumToAny(p->alpha,range),range); p++; } } image->depth=depth; return(status); }
static int parse_header( Read *read ) { VipsImage *im = read->im; Image *image = read->image; Image *p; int i; #ifdef DEBUG printf( "parse_header: filename = %s\n", read->filename ); printf( "GetImageChannelDepth(AllChannels) = %zd\n", GetImageChannelDepth( image, AllChannels, &image->exception ) ); printf( "GetImageDepth() = %zd\n", GetImageDepth( image, &image->exception ) ); printf( "image->depth = %zd\n", image->depth ); printf( "GetImageType() = %d\n", GetImageType( image, &image->exception ) ); printf( "IsGrayImage() = %d\n", IsGrayImage( image, &image->exception ) ); printf( "IsMonochromeImage() = %d\n", IsMonochromeImage( image, &image->exception ) ); printf( "IsOpaqueImage() = %d\n", IsOpaqueImage( image, &image->exception ) ); printf( "image->columns = %zd\n", image->columns ); printf( "image->rows = %zd\n", image->rows ); #endif /*DEBUG*/ im->Xsize = image->columns; im->Ysize = image->rows; read->frame_height = image->rows; if( (im->Bands = get_bands( image )) < 0 ) return( -1 ); /* Depth can be 'fractional'. You'd think we should use * GetImageDepth() but that seems unreliable. 16-bit mono DICOM images * are reported as depth 1, for example. */ im->BandFmt = -1; if( image->depth >= 1 && image->depth <= 8 ) im->BandFmt = VIPS_FORMAT_UCHAR; if( image->depth >= 9 && image->depth <= 16 ) im->BandFmt = VIPS_FORMAT_USHORT; #ifdef UseHDRI if( image->depth == 32 ) im->BandFmt = VIPS_FORMAT_FLOAT; if( image->depth == 64 ) im->BandFmt = VIPS_FORMAT_DOUBLE; #else /*!UseHDRI*/ if( image->depth == 32 ) im->BandFmt = VIPS_FORMAT_UINT; #endif /*UseHDRI*/ if( im->BandFmt == -1 ) { vips_error( "magick2vips", _( "unsupported bit depth %d" ), (int) image->depth ); return( -1 ); } switch( image->colorspace ) { case GRAYColorspace: if( im->BandFmt == VIPS_FORMAT_USHORT ) im->Type = VIPS_INTERPRETATION_GREY16; else im->Type = VIPS_INTERPRETATION_B_W; break; case RGBColorspace: if( im->BandFmt == VIPS_FORMAT_USHORT ) im->Type = VIPS_INTERPRETATION_RGB16; else im->Type = VIPS_INTERPRETATION_RGB; break; case sRGBColorspace: if( im->BandFmt == VIPS_FORMAT_USHORT ) im->Type = VIPS_INTERPRETATION_RGB16; else im->Type = VIPS_INTERPRETATION_sRGB; break; case CMYKColorspace: im->Type = VIPS_INTERPRETATION_CMYK; break; default: vips_error( "magick2vips", _( "unsupported colorspace %d" ), (int) image->colorspace ); return( -1 ); } switch( image->units ) { case PixelsPerInchResolution: im->Xres = image->x_resolution / 25.4; im->Yres = image->y_resolution / 25.4; break; case PixelsPerCentimeterResolution: im->Xres = image->x_resolution / 10.0; im->Yres = image->y_resolution / 10.0; break; default: im->Xres = 1.0; im->Yres = 1.0; break; } /* Other fields. */ im->Coding = VIPS_CODING_NONE; vips_image_pipelinev( im, VIPS_DEMAND_STYLE_SMALLTILE, NULL ); /* Three ways to loop over attributes / properties :-( */ #ifdef HAVE_RESETIMAGEPROPERTYITERATOR { char *key; /* This is the most recent imagemagick API, test for this first. */ ResetImagePropertyIterator( image ); while( (key = GetNextImageProperty( image )) ) { char name_text[256]; VipsBuf name = VIPS_BUF_STATIC( name_text ); vips_buf_appendf( &name, "magick-%s", key ); vips_image_set_string( im, vips_buf_all( &name ), GetImageProperty( image, key ) ); } } #elif defined(HAVE_RESETIMAGEATTRIBUTEITERATOR) { const ImageAttribute *attr; /* magick6.1-ish and later, deprecated in 6.5ish. */ ResetImageAttributeIterator( image ); while( (attr = GetNextImageAttribute( image )) ) { char name_text[256]; VipsBuf name = VIPS_BUF_STATIC( name_text ); vips_buf_appendf( &name, "magick-%s", attr->key ); vips_image_set_string( im, vips_buf_all( &name ), attr->value ); } } #else { const ImageAttribute *attr; /* GraphicsMagick is missing the iterator: we have to loop ourselves. * ->attributes is marked as private in the header, but there's no * getter so we have to access it directly. */ for( attr = image->attributes; attr; attr = attr->next ) { char name_text[256]; VipsBuf name = VIPS_BUF_STATIC( name_text ); vips_buf_appendf( &name, "magick-%s", attr->key ); vips_image_set_string( im, vips_buf_all( &name ), attr->value ); } } #endif /* Do we have a set of equal-sized frames? Append them. FIXME ... there must be an attribute somewhere from dicom read which says this is a volumetric image */ read->n_frames = 0; for( p = image; p; (p = GetNextImageInList( p )) ) { if( p->columns != (unsigned int) im->Xsize || p->rows != (unsigned int) im->Ysize || get_bands( p ) != im->Bands ) break; read->n_frames += 1; } if( p ) /* Nope ... just do the first image in the list. */ read->n_frames = 1; #ifdef DEBUG printf( "image has %d frames\n", read->n_frames ); #endif /*DEBUG*/ /* If all_frames is off, just get the first one. */ if( !read->all_frames ) read->n_frames = 1; /* Record frame pointers. */ im->Ysize *= read->n_frames; if( !(read->frames = VIPS_ARRAY( NULL, read->n_frames, Image * )) ) return( -1 ); p = image; for( i = 0; i < read->n_frames; i++ ) { read->frames[i] = p; p = GetNextImageInList( p ); } return( 0 ); }
MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file, const MagickBooleanType verbose,ExceptionInfo *exception) { char color[MaxTextExtent], format[MaxTextExtent], key[MaxTextExtent]; ChannelFeatures *channel_features; ChannelStatistics *channel_statistics; ColorspaceType colorspace; const char *artifact, *name, *property, *registry, *value; const MagickInfo *magick_info; double elapsed_time, user_time; ImageType type; MagickBooleanType ping; register const Quantum *p; register ssize_t i, x; size_t distance, scale; ssize_t y; assert(image != (Image *) NULL); assert(image->signature == MagickSignature); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); if (file == (FILE *) NULL) file=stdout; *format='\0'; elapsed_time=GetElapsedTime(&image->timer); user_time=GetUserTime(&image->timer); GetTimerInfo(&image->timer); if (verbose == MagickFalse) { /* Display summary info about the image. */ if (*image->magick_filename != '\0') if (LocaleCompare(image->magick_filename,image->filename) != 0) (void) FormatLocaleFile(file,"%s=>",image->magick_filename); if ((GetPreviousImageInList(image) == (Image *) NULL) && (GetNextImageInList(image) == (Image *) NULL) && (image->scene == 0)) (void) FormatLocaleFile(file,"%s ",image->filename); else (void) FormatLocaleFile(file,"%s[%.20g] ",image->filename,(double) image->scene); (void) FormatLocaleFile(file,"%s ",image->magick); if ((image->magick_columns != 0) || (image->magick_rows != 0)) if ((image->magick_columns != image->columns) || (image->magick_rows != image->rows)) (void) FormatLocaleFile(file,"%.20gx%.20g=>",(double) image->magick_columns,(double) image->magick_rows); (void) FormatLocaleFile(file,"%.20gx%.20g ",(double) image->columns, (double) image->rows); if ((image->page.width != 0) || (image->page.height != 0) || (image->page.x != 0) || (image->page.y != 0)) (void) FormatLocaleFile(file,"%.20gx%.20g%+.20g%+.20g ",(double) image->page.width,(double) image->page.height,(double) image->page.x, (double) image->page.y); (void) FormatLocaleFile(file,"%.20g-bit ",(double) image->depth); if (image->type != UndefinedType) (void) FormatLocaleFile(file,"%s ",CommandOptionToMnemonic( MagickTypeOptions,(ssize_t) image->type)); if (image->storage_class == DirectClass) { (void) FormatLocaleFile(file,"DirectClass "); if (image->total_colors != 0) { (void) FormatMagickSize(image->total_colors,MagickFalse,format); (void) FormatLocaleFile(file,"%s ",format); } } else if (image->total_colors <= image->colors) (void) FormatLocaleFile(file,"PseudoClass %.20gc ",(double) image->colors); else (void) FormatLocaleFile(file,"PseudoClass %.20g=>%.20gc ",(double) image->total_colors,(double) image->colors); if (image->error.mean_error_per_pixel != 0.0) (void) FormatLocaleFile(file,"%.20g/%f/%fdb ",(double) (image->error.mean_error_per_pixel+0.5), image->error.normalized_mean_error, image->error.normalized_maximum_error); if (GetBlobSize(image) != 0) { (void) FormatMagickSize(GetBlobSize(image),MagickFalse,format); (void) FormatLocaleFile(file,"%s ",format); } (void) FormatLocaleFile(file,"%0.3fu %lu:%02lu.%03lu",user_time, (unsigned long) (elapsed_time/60.0),(unsigned long) floor(fmod( elapsed_time,60.0)),(unsigned long) (1000.0*(elapsed_time- floor(elapsed_time)))); (void) FormatLocaleFile(file,"\n"); (void) fflush(file); return(ferror(file) != 0 ? MagickFalse : MagickTrue); } /* Display verbose info about the image. */ p=GetVirtualPixels(image,0,0,1,1,exception); ping=p == (const Quantum *) NULL ? MagickTrue : MagickFalse; type=GetImageType(image,exception); (void) SignatureImage(image,exception); (void) FormatLocaleFile(file,"Image: %s\n",image->filename); if (*image->magick_filename != '\0') if (LocaleCompare(image->magick_filename,image->filename) != 0) { char filename[MaxTextExtent]; GetPathComponent(image->magick_filename,TailPath,filename); (void) FormatLocaleFile(file," Base filename: %s\n",filename); } magick_info=GetMagickInfo(image->magick,exception); if ((magick_info == (const MagickInfo *) NULL) || (*GetMagickDescription(magick_info) == '\0')) (void) FormatLocaleFile(file," Format: %s\n",image->magick); else (void) FormatLocaleFile(file," Format: %s (%s)\n",image->magick, GetMagickDescription(magick_info)); (void) FormatLocaleFile(file," Class: %s\n",CommandOptionToMnemonic( MagickClassOptions,(ssize_t) image->storage_class)); (void) FormatLocaleFile(file," Geometry: %.20gx%.20g%+.20g%+.20g\n",(double) image->columns,(double) image->rows,(double) image->tile_offset.x,(double) image->tile_offset.y); if ((image->magick_columns != 0) || (image->magick_rows != 0)) if ((image->magick_columns != image->columns) || (image->magick_rows != image->rows)) (void) FormatLocaleFile(file," Base geometry: %.20gx%.20g\n",(double) image->magick_columns,(double) image->magick_rows); if ((image->resolution.x != 0.0) && (image->resolution.y != 0.0)) { (void) FormatLocaleFile(file," Resolution: %gx%g\n",image->resolution.x, image->resolution.y); (void) FormatLocaleFile(file," Print size: %gx%g\n",(double) image->columns/image->resolution.x,(double) image->rows/ image->resolution.y); } (void) FormatLocaleFile(file," Units: %s\n",CommandOptionToMnemonic( MagickResolutionOptions,(ssize_t) image->units)); (void) FormatLocaleFile(file," Type: %s\n",CommandOptionToMnemonic( MagickTypeOptions,(ssize_t) type)); if (image->type != UndefinedType) (void) FormatLocaleFile(file," Base type: %s\n",CommandOptionToMnemonic( MagickTypeOptions,(ssize_t) image->type)); (void) FormatLocaleFile(file," Endianess: %s\n",CommandOptionToMnemonic( MagickEndianOptions,(ssize_t) image->endian)); /* Detail channel depth and extrema. */ (void) FormatLocaleFile(file," Colorspace: %s\n",CommandOptionToMnemonic( MagickColorspaceOptions,(ssize_t) image->colorspace)); channel_statistics=(ChannelStatistics *) NULL; channel_features=(ChannelFeatures *) NULL; colorspace=image->colorspace; scale=1; if (ping == MagickFalse) { size_t depth; channel_statistics=GetImageStatistics(image,exception); artifact=GetImageArtifact(image,"identify:features"); if (artifact != (const char *) NULL) { distance=StringToUnsignedLong(artifact); channel_features=GetImageFeatures(image,distance,exception); } depth=GetImageDepth(image,exception); if (image->depth == depth) (void) FormatLocaleFile(file," Depth: %.20g-bit\n",(double) image->depth); else (void) FormatLocaleFile(file," Depth: %.20g/%.20g-bit\n",(double) image->depth,(double) depth); (void) FormatLocaleFile(file," Channel depth:\n"); if (IsImageGray(image,exception) != MagickFalse) colorspace=GRAYColorspace; switch (colorspace) { case RGBColorspace: default: { (void) FormatLocaleFile(file," red: %.20g-bit\n",(double) channel_statistics[RedPixelChannel].depth); (void) FormatLocaleFile(file," green: %.20g-bit\n",(double) channel_statistics[GreenPixelChannel].depth); (void) FormatLocaleFile(file," blue: %.20g-bit\n",(double) channel_statistics[BluePixelChannel].depth); break; } case CMYKColorspace: { (void) FormatLocaleFile(file," cyan: %.20g-bit\n",(double) channel_statistics[CyanPixelChannel].depth); (void) FormatLocaleFile(file," magenta: %.20g-bit\n",(double) channel_statistics[MagentaPixelChannel].depth); (void) FormatLocaleFile(file," yellow: %.20g-bit\n",(double) channel_statistics[YellowPixelChannel].depth); (void) FormatLocaleFile(file," black: %.20g-bit\n",(double) channel_statistics[BlackPixelChannel].depth); break; } case GRAYColorspace: { (void) FormatLocaleFile(file," gray: %.20g-bit\n",(double) channel_statistics[GrayPixelChannel].depth); break; } } if (image->matte != MagickFalse) (void) FormatLocaleFile(file," alpha: %.20g-bit\n",(double) channel_statistics[AlphaPixelChannel].depth); scale=1; if (image->depth <= MAGICKCORE_QUANTUM_DEPTH) scale=QuantumRange/((size_t) QuantumRange >> ((size_t) MAGICKCORE_QUANTUM_DEPTH-image->depth)); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % I d e n t i f y I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % IdentifyImage() identifies an image by printing its attributes to the file. % Attributes include the image width, height, size, and others. % % The format of the IdentifyImage method is: % % MagickBooleanType IdentifyImage(Image *image,FILE *file, % const MagickBooleanType 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. % */ MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file, const MagickBooleanType verbose) { #define IdentifyFormat " %s:\n Min: " QuantumFormat \ " (%g)\n Max: " QuantumFormat " (%g)\n" \ " Mean: %g (%g)\n Standard deviation: %g (%g)\n" char color[MaxTextExtent], format[MaxTextExtent], key[MaxTextExtent]; ColorspaceType colorspace; const char *property, *value; const MagickInfo *magick_info; const PixelPacket *pixels; double elapsed_time, user_time; ExceptionInfo *exception; Image *p; ImageType type; long y; MagickBooleanType ping; register long i, x; unsigned long scale; assert(image != (Image *) NULL); assert(image->signature == MagickSignature); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); if (file == (FILE *) NULL) file=stdout; *format='\0'; elapsed_time=GetElapsedTime(&image->timer); user_time=GetUserTime(&image->timer); GetTimerInfo(&image->timer); if (verbose == MagickFalse) { /* Display summary info about the image. */ if (*image->magick_filename != '\0') if (LocaleCompare(image->magick_filename,image->filename) != 0) (void) fprintf(file,"%s=>",image->magick_filename); if ((GetPreviousImageInList(image) == (Image *) NULL) && (GetNextImageInList(image) == (Image *) NULL) && (image->scene == 0)) (void) fprintf(file,"%s ",image->filename); else (void) fprintf(file,"%s[%lu] ",image->filename,image->scene); (void) fprintf(file,"%s ",image->magick); if ((image->magick_columns != 0) || (image->magick_rows != 0)) if ((image->magick_columns != image->columns) || (image->magick_rows != image->rows)) (void) fprintf(file,"%lux%lu=>",image->magick_columns, image->magick_rows); (void) fprintf(file,"%lux%lu ",image->columns,image->rows); if ((image->page.width != 0) || (image->page.height != 0) || (image->page.x != 0) || (image->page.y != 0)) (void) fprintf(file,"%lux%lu%+ld%+ld ",image->page.width, image->page.height,image->page.x,image->page.y); if (image->storage_class == DirectClass) { (void) fprintf(file,"DirectClass "); if (image->total_colors != 0) { (void) FormatMagickSize(image->total_colors,format); (void) fprintf(file,"%s ",format); } } else if (image->total_colors <= image->colors) (void) fprintf(file,"PseudoClass %luc ",image->colors); else (void) fprintf(file,"PseudoClass %lu=>%luc ",image->total_colors, image->colors); (void) fprintf(file,"%lu-bit ",image->depth); if (image->error.mean_error_per_pixel != 0.0) (void) fprintf(file,"%ld/%f/%fdb ", (long) (image->error.mean_error_per_pixel+0.5), image->error.normalized_mean_error, image->error.normalized_maximum_error); if (GetBlobSize(image) != 0) { (void) FormatMagickSize(GetBlobSize(image),format); (void) fprintf(file,"%s ",format); } if (elapsed_time > 0.06) (void) fprintf(file,"%0.3fu %ld:%02ld",user_time, (long) (elapsed_time/60.0+0.5),(long) ceil(fmod(elapsed_time,60.0))); (void) fprintf(file,"\n"); (void) fflush(file); return(ferror(file) != 0 ? MagickFalse : MagickTrue); } /* Display verbose info about the image. */ exception=AcquireExceptionInfo(); pixels=AcquireImagePixels(image,0,0,1,1,exception); exception=DestroyExceptionInfo(exception); ping=pixels == (const PixelPacket *) NULL ? MagickTrue : MagickFalse; type=GetImageType(image,&image->exception); (void) SignatureImage(image); (void) fprintf(file,"Image: %s\n",image->filename); if (*image->magick_filename != '\0') if (LocaleCompare(image->magick_filename,image->filename) != 0) { char filename[MaxTextExtent]; GetPathComponent(image->magick_filename,TailPath,filename); (void) fprintf(file," Base filename: %s\n",filename); } magick_info=GetMagickInfo(image->magick,&image->exception); if ((magick_info == (const MagickInfo *) NULL) || (*GetMagickDescription(magick_info) == '\0')) (void) fprintf(file," Format: %s\n",image->magick); else (void) fprintf(file," Format: %s (%s)\n",image->magick, GetMagickDescription(magick_info)); (void) fprintf(file," Class: %s\n", MagickOptionToMnemonic(MagickClassOptions,(long) image->storage_class)); (void) fprintf(file," Geometry: %lux%lu%+ld%+ld\n",image->columns, image->rows,image->tile_offset.x,image->tile_offset.y); 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: %s\n",MagickOptionToMnemonic(MagickTypeOptions, (long) type)); (void) fprintf(file," Endianess: %s\n",MagickOptionToMnemonic( MagickEndianOptions,(long) image->endian)); /* Detail channel depth and extrema. */ colorspace=image->colorspace; if (IsGrayImage(image,&image->exception) != MagickFalse) colorspace=GRAYColorspace; (void) fprintf(file," Colorspace: %s\n", MagickOptionToMnemonic(MagickColorspaceOptions,(long) colorspace)); if (ping == MagickFalse) { ChannelStatistics *channel_statistics; (void) fprintf(file," Depth: %lu-bit\n",GetImageDepth(image, &image->exception)); channel_statistics=GetImageChannelStatistics(image,&image->exception); (void) fprintf(file," Channel depth:\n"); switch (colorspace) { case RGBColorspace: default: { (void) fprintf(file," Red: %lu-bit\n", channel_statistics[RedChannel].depth); (void) fprintf(file," Green: %lu-bit\n", channel_statistics[GreenChannel].depth); (void) fprintf(file," Blue: %lu-bit\n", channel_statistics[BlueChannel].depth); if (image->matte != MagickFalse) (void) fprintf(file," Alpha: %lu-bit\n", channel_statistics[OpacityChannel].depth); break; } case CMYKColorspace: { (void) fprintf(file," Cyan: %lu-bit\n", channel_statistics[CyanChannel].depth); (void) fprintf(file," Magenta: %lu-bit\n", channel_statistics[MagentaChannel].depth); (void) fprintf(file," Yellow: %lu-bit\n", channel_statistics[YellowChannel].depth); (void) fprintf(file," Black: %lu-bit\n", channel_statistics[BlackChannel].depth); if (image->matte != MagickFalse) (void) fprintf(file," Alpha: %lu-bit\n", channel_statistics[OpacityChannel].depth); break; } case GRAYColorspace: { (void) fprintf(file," Gray: %lu-bit\n", channel_statistics[GrayChannel].depth); if (image->matte != MagickFalse) (void) fprintf(file," Alpha: %lu-bit\n", channel_statistics[OpacityChannel].depth); break; } } scale=QuantumRange/((unsigned long) QuantumRange >> ((unsigned long) MAGICKCORE_QUANTUM_DEPTH-channel_statistics[AllChannels].depth)); (void) fprintf(file," Channel statistics:\n"); switch (colorspace) { case RGBColorspace: default: { (void) fprintf(file,IdentifyFormat,"Red",(Quantum) (channel_statistics[RedChannel].minima/scale),(double) channel_statistics[RedChannel].minima/(double) QuantumRange, (Quantum) (channel_statistics[RedChannel].maxima/scale),(double) channel_statistics[RedChannel].maxima/(double) QuantumRange, channel_statistics[RedChannel].mean/(double) scale, channel_statistics[RedChannel].mean/(double) QuantumRange, channel_statistics[RedChannel].standard_deviation/(double) scale, channel_statistics[RedChannel].standard_deviation/(double) QuantumRange); (void) fprintf(file,IdentifyFormat,"Green",(Quantum) (channel_statistics[GreenChannel].minima/scale),(double) channel_statistics[GreenChannel].minima/(double) QuantumRange, (Quantum) (channel_statistics[GreenChannel].maxima/scale),(double) channel_statistics[GreenChannel].maxima/(double) QuantumRange, channel_statistics[GreenChannel].mean/(double) scale, channel_statistics[GreenChannel].mean/(double) QuantumRange, channel_statistics[GreenChannel].standard_deviation/(double) scale, channel_statistics[GreenChannel].standard_deviation/(double) QuantumRange); (void) fprintf(file,IdentifyFormat,"Blue",(Quantum) (channel_statistics[BlueChannel].minima/scale),(double) channel_statistics[BlueChannel].minima/(double) QuantumRange, (Quantum) (channel_statistics[BlueChannel].maxima/scale),(double) channel_statistics[BlueChannel].maxima/(double) QuantumRange, channel_statistics[BlueChannel].mean/(double) scale, channel_statistics[BlueChannel].mean/(double) QuantumRange, channel_statistics[BlueChannel].standard_deviation/(double) scale, channel_statistics[BlueChannel].standard_deviation/(double) QuantumRange); break; } case CMYKColorspace: { (void) fprintf(file,IdentifyFormat,"Cyan",(Quantum) (channel_statistics[CyanChannel].minima/scale),(double) channel_statistics[CyanChannel].minima/(double) QuantumRange, (Quantum) (channel_statistics[CyanChannel].maxima/scale),(double) channel_statistics[CyanChannel].maxima/(double) QuantumRange, channel_statistics[CyanChannel].mean/(double) scale, channel_statistics[CyanChannel].mean/(double) QuantumRange, channel_statistics[CyanChannel].standard_deviation/(double) scale, channel_statistics[CyanChannel].standard_deviation/(double) QuantumRange); (void) fprintf(file,IdentifyFormat,"Magenta",(Quantum) (channel_statistics[MagentaChannel].minima/scale),(double) channel_statistics[MagentaChannel].minima/(double) QuantumRange, (Quantum) (channel_statistics[MagentaChannel].maxima/scale),(double) channel_statistics[MagentaChannel].maxima/(double) QuantumRange, channel_statistics[MagentaChannel].mean/(double) scale, channel_statistics[MagentaChannel].mean/(double) QuantumRange, channel_statistics[MagentaChannel].standard_deviation/(double) scale,channel_statistics[MagentaChannel].standard_deviation/(double) QuantumRange); (void) fprintf(file,IdentifyFormat,"Yellow",(Quantum) (channel_statistics[YellowChannel].minima/scale),(double) channel_statistics[YellowChannel].minima/(double) QuantumRange, (Quantum) (channel_statistics[YellowChannel].maxima/scale),(double) channel_statistics[YellowChannel].maxima/(double) QuantumRange, channel_statistics[YellowChannel].mean/(double) scale, channel_statistics[YellowChannel].mean/(double) QuantumRange, channel_statistics[YellowChannel].standard_deviation/(double) scale, channel_statistics[YellowChannel].standard_deviation/(double) QuantumRange); (void) fprintf(file,IdentifyFormat,"Black",(Quantum) (channel_statistics[BlackChannel].minima/scale),(double) channel_statistics[BlackChannel].minima/(double) QuantumRange, (Quantum) (channel_statistics[BlackChannel].maxima/scale),(double) channel_statistics[BlackChannel].maxima/(double) QuantumRange, channel_statistics[BlackChannel].mean/(double) scale, channel_statistics[BlackChannel].mean/(double) QuantumRange, channel_statistics[BlackChannel].standard_deviation/(double) scale, channel_statistics[BlackChannel].standard_deviation/(double) QuantumRange); break; } case GRAYColorspace: { (void) fprintf(file,IdentifyFormat,"Gray",(Quantum) (channel_statistics[GrayChannel].minima/scale),(double) channel_statistics[GrayChannel].minima/(double) QuantumRange, (Quantum) (channel_statistics[GrayChannel].maxima/scale),(double) channel_statistics[GrayChannel].maxima/(double) QuantumRange, channel_statistics[GrayChannel].mean/(double) scale, channel_statistics[GrayChannel].mean/(double) QuantumRange, channel_statistics[GrayChannel].standard_deviation/(double) scale, channel_statistics[GrayChannel].standard_deviation/(double) QuantumRange); break; } } if (image->matte != MagickFalse) (void) fprintf(file,IdentifyFormat,"Opacity",(Quantum) (channel_statistics[OpacityChannel].minima/scale),(double) channel_statistics[OpacityChannel].minima/(double) QuantumRange, (Quantum) (channel_statistics[OpacityChannel].maxima/scale),(double) channel_statistics[OpacityChannel].maxima/(double) QuantumRange, channel_statistics[OpacityChannel].mean/(double) scale, channel_statistics[OpacityChannel].mean/(double) QuantumRange, channel_statistics[OpacityChannel].standard_deviation/(double) scale, channel_statistics[OpacityChannel].standard_deviation/(double) QuantumRange); channel_statistics=(ChannelStatistics *) RelinquishMagickMemory( channel_statistics); if (colorspace == CMYKColorspace) (void) fprintf(file," Total ink density: %.0f%%\n",100.0* GetImageTotalInkDensity(image)/(double) QuantumRange); x=0; p=NewImageList(); if (image->matte != MagickFalse) { register const IndexPacket *indexes; register const PixelPacket *p; p=(PixelPacket *) NULL; indexes=(IndexPacket *) 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; indexes=AcquireIndexes(image); for (x=0; x < (long) image->columns; x++) { if (p->opacity == (Quantum) TransparentOpacity) break; p++; } if (x < (long) image->columns) break; } if ((x < (long) image->columns) || (y < (long) image->rows)) { char tuple[MaxTextExtent]; MagickPixelPacket pixel; GetMagickPixelPacket(image,&pixel); SetMagickPixelPacket(image,p,indexes+x,&pixel); (void) QueryMagickColorname(image,&pixel,SVGCompliance, MagickFalse,tuple,&image->exception); (void) fprintf(file," Alpha: %s ",tuple); (void) QueryMagickColorname(image,&pixel,SVGCompliance,MagickTrue, tuple,&image->exception); (void) fprintf(file," %s\n",tuple); } } if ((ping == MagickFalse) && (IsHistogramImage(image,&image->exception) != MagickFalse)) { (void) fprintf(file," Histogram:\n"); (void) GetNumberColors(image,file,&image->exception); } }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % 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; } }