]> granicus.if.org Git - imagemagick/commitdiff
Add page_index and page_total to Image sturcture
authoranthony <anthony@git.imagemagick.org>
Sat, 19 Mar 2011 14:10:59 +0000 (14:10 +0000)
committeranthony <anthony@git.imagemagick.org>
Sat, 19 Mar 2011 14:10:59 +0000 (14:10 +0000)
so as to correctly implement %p, %n and %[fx:t], %[fx:n] resp.

ChangeLog
magick/constitute.c
magick/image.h
magick/list.c
magick/list.h
wand/identify.c
wand/mogrify.c

index e69a17c52e0c63fd957c67fd6dea814e29b0f266..66461aa50608bd684cd4f0f88b6d2bd99772aff9 100644 (file)
--- 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 <A.Thyssen@griffith...>
   * Backed out the patch for Variable Blur Composition that was added
index d5f5b05664b7600e11abcd0a6250df2017d00cf5..c4593bb193223bc1b8aec215da094c6d4a5c131e 100644 (file)
@@ -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);
index 18ab70bdced8731cf7ac58af419d9b338bb9587e..40251c97848118f7c1724cb23be819b227df7544 100644 (file)
@@ -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
index a597e077f666e5ac49e6c20565a215681804b8e6..a6a2a5e12d6d048ba66eed91d031fec0f3f82c78 100644 (file)
@@ -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;
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
 %   P r e p e n d I m a g e T o L i s t                                       %
 %                                                                             %
 %                                                                             %
index 3ea9ecfdfee97e4a4a66607655e2ab1d328cdce6..78c016d711925fb0fb1ef9946d5bcd9d0222c776 100644 (file)
@@ -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 **),
index c6fe54b41d0037d7c63942554b5043d1004603a2..8b95826c594ab7631aec857e4c46ef40d31715af 100644 (file)
@@ -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)
index 4e7e33ce94b3556602f5e457f00a2002bc2fbe64..bcc8134ec3c4e5764ee98962551adba35b0c10cd 100644 (file)
@@ -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);