From 1e4df87b705a8421682b7d9168e306e1dd4f5024 Mon Sep 17 00:00:00 2001 From: anthony Date: Sat, 19 Mar 2011 14:10:59 +0000 Subject: [PATCH] Add page_index and page_total to Image sturcture so as to correctly implement %p, %n and %[fx:t], %[fx:n] resp. --- ChangeLog | 3 ++ magick/constitute.c | 1 + magick/image.h | 77 ++++++++++++++++++++++++--------------------- magick/list.c | 54 +++++++++++++++++++++++++++++++ magick/list.h | 1 + wand/identify.c | 1 + wand/mogrify.c | 7 +++-- 7 files changed, 106 insertions(+), 38 deletions(-) diff --git a/ChangeLog b/ChangeLog index e69a17c52..66461aa50 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,9 @@ * Replaced Minus and Divide Composition methods with Dst and Src equivalents. Now users can decide how these non-commutative mathematical operators are applied the to the images being composited. + * Fix the percent escape values for %p, %n and %[fx:t], %[fx:n] to + respectivally mean a the current images index and the total number of + images within the current image sequence. 2011-03-17 6.6.8-5 Anthony Thyssen * Backed out the patch for Variable Blur Composition that was added diff --git a/magick/constitute.c b/magick/constitute.c index d5f5b0566..c4593bb19 100644 --- a/magick/constitute.c +++ b/magick/constitute.c @@ -635,6 +635,7 @@ MagickExport Image *ReadImage(const ImageInfo *image_info, *profile; next->taint=MagickFalse; + next->page_index = next->page_total= 0; GetPathComponent(magick_filename,MagickPath,magick_path); if (*magick_path == '\0') (void) CopyMagickString(next->magick,magick,MaxTextExtent); diff --git a/magick/image.h b/magick/image.h index 18ab70bdc..40251c978 100644 --- a/magick/image.h +++ b/magick/image.h @@ -150,32 +150,32 @@ struct _Image storage_class; ColorspaceType - colorspace; + colorspace; /* colorspace of image data */ CompressionType - compression; + compression; /* compression of image when read/write */ size_t - quality; + quality; /* compression quality setting, meaning varies */ OrientationType - orientation; + orientation; /* photo orientation of image */ MagickBooleanType - taint, - matte; + taint, /* has image been modified since reading */ + matte; /* is transparency channel defined and active */ size_t - columns, + columns, /* physical size of image */ rows, - depth, - colors; + depth, /* depth of image on read/write */ + colors; /* size of color table on read */ PixelPacket *colormap, - background_color, - border_color, - matte_color; + background_color, /* current background color attribute */ + border_color, /* current bordercolor attribute */ + matte_color; /* current mattecolor attribute */ double gamma; @@ -190,7 +190,7 @@ struct _Image *profiles; ResolutionType - units; + units; /* resolution/density ppi or ppc */ char *montage, @@ -201,46 +201,46 @@ struct _Image offset; double - x_resolution, + x_resolution, /* image resolution/density */ y_resolution; RectangleInfo - page, + page, /* virtual canvas size and offset of image */ extract_info, - tile_info; /* deprecated */ + tile_info; /* deprecated */ double bias, - blur, /* deprecated */ - fuzz; + blur, /* deprecated */ + fuzz; /* current color fuzz attribute */ FilterTypes - filter; + filter; /* resize/distort filter to apply */ InterlaceType interlace; EndianType - endian; + endian; /* raw data integer ordering on read/write */ GravityType - gravity; + gravity; /* Gravity attribute for positioning in image */ CompositeOperator - compose; + compose; /* alpha composition method for layered images */ DisposeType - dispose; + dispose; /* GIF animation disposal method */ struct _Image *clip_mask; size_t - scene, - delay; + scene, /* index of image in multi-image file */ + delay; /* Animation delay time */ ssize_t - ticks_per_second; + ticks_per_second; /* units for delay time, default 100 for GIF */ size_t iterations, @@ -261,7 +261,7 @@ struct _Image void *client_data, *cache, - *attributes; /* deprecated */ + *attributes; /* deprecated */ Ascii85Info *ascii85; @@ -270,7 +270,7 @@ struct _Image *blob; char - filename[MaxTextExtent], + filename[MaxTextExtent], /* images input filename */ magick_filename[MaxTextExtent], magick[MaxTextExtent]; @@ -279,10 +279,10 @@ struct _Image magick_rows; ExceptionInfo - exception; + exception; /* Error handling report */ MagickBooleanType - debug; + debug; /* debug output attribute */ volatile ssize_t reference_count; @@ -302,18 +302,18 @@ struct _Image signature; struct _Image - *previous, + *previous, /* Image sequence list links */ *list, *next; InterpolatePixelMethod - interpolate; + interpolate; /* Interpolation of color for between pixel lookups */ MagickBooleanType black_point_compensation; PixelPacket - transparent_color; + transparent_color; /* color for 'transparent' color index in GIF */ struct _Image *mask; @@ -322,22 +322,27 @@ struct _Image tile_offset; void - *properties, - *artifacts; + *properties, /* per image properities */ + *artifacts; /* per image sequence image artifacts */ ImageType type; MagickBooleanType - dither; + dither; /* dithering method during color reduction */ MagickSizeType extent; MagickBooleanType ping; + + size_t + page_index, /* %p current index in working image sequence */ + page_total; /* %n total pages in working image sequence */ }; + struct _ImageInfo { CompressionType diff --git a/magick/list.c b/magick/list.c index a597e077f..a6a2a5e12 100644 --- a/magick/list.c +++ b/magick/list.c @@ -842,6 +842,60 @@ MagickExport Image *NewImageList(void) % % % % % % ++ P a g e I n d e x I m a g e L i s t % +% % +% % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% PageIndexImageList() synchronizes the page_index and page_total values +% in the image list. +% +% These values are used by InterpretImageProperties() to set %p and %n +% percent escapes. The value is preserved, even if the image is later removed +% from the list using RemoveFirstImageFromList() for individual image +% processing. +% +% The format of the PageIndexImageList method is: +% +% void PageIndexImageList(Image *images) +% +% A description of each parameter follows: +% +% o images: the image list. +% +*/ +MagickExport void PageIndexImageList(Image *images) +{ + register ssize_t + p,n; + + if (images == (Image *) NULL) + return; + assert(images->signature == MagickSignature); + if (images->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",images->filename); + + /* find start for image counting */ + while (images->previous != (Image *) NULL) + images=images->previous; + + /* count up images - find end */ + n=1; + while (images->next != (Image *) NULL) + images=images->next, n++; + + /* set page_index and page_total attributes */ + p=n-1; + for (; images != (Image *) NULL; images=images->previous) + images->page_index=p--, images->page_total=n; +} + +/* +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% % +% % % P r e p e n d I m a g e T o L i s t % % % % % diff --git a/magick/list.h b/magick/list.h index 3ea9ecfdf..78c016d71 100644 --- a/magick/list.h +++ b/magick/list.h @@ -51,6 +51,7 @@ extern MagickExport void DeleteImageFromList(Image **), DeleteImages(Image **,const char *,ExceptionInfo *), InsertImageInList(Image **,Image *), + PageIndexImageList(Image *), PrependImageToList(Image **,Image *), ReplaceImageInList(Image **,Image *), ReverseImageList(Image **), diff --git a/wand/identify.c b/wand/identify.c index c6fe54b41..8b95826c5 100644 --- a/wand/identify.c +++ b/wand/identify.c @@ -322,6 +322,7 @@ WandExport MagickBooleanType IdentifyImageCommand(ImageInfo *image_info, continue; AppendImageStack(images); FinalizeImageSettings(image_info,image,MagickFalse); + PageIndexImageList(images); for ( ; image != (Image *) NULL; image=GetNextImageInList(image)) { if (image->scene == 0) diff --git a/wand/mogrify.c b/wand/mogrify.c index 4e7e33ce9..bcc8134ec 100644 --- a/wand/mogrify.c +++ b/wand/mogrify.c @@ -411,6 +411,7 @@ static Image *SparseColorOption(const Image *image,const ChannelType channel, number_colors++; if ((channels & OpacityChannel) != 0) number_colors++; + /* Read string, to determine number of arguments needed, */ @@ -7984,6 +7985,7 @@ WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info, *fx_image; (void) SyncImagesSettings(mogrify_info,*images); + PageIndexImageList(*images); fx_image=FxImageChannel(*images,channel,argv[i+1],exception); if (fx_image == (Image *) NULL) { @@ -8627,11 +8629,12 @@ WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info, return(MagickTrue); (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL, (void *) NULL); - mogrify_images=NewImageList(); - number_images=GetImageListLength(*images); status=0; if (post == MagickFalse) status&=MogrifyImageList(image_info,argc,argv,images,exception); + PageIndexImageList(*images); + number_images=(*images)->page_total; + mogrify_images=NewImageList(); for (i=0; i < (ssize_t) number_images; i++) { image=RemoveFirstImageFromList(images); -- 2.40.0