[q-lang-cvs] q/modules/magick magick.c,1.6,1.7 magick.q,1.7,1.8
                
                Brought to you by:
                
                    agraef
                    
                
            
            
        
        
        
    | 
     
      
      
      From: <ag...@us...> - 2003-12-26 14:26:54
      
     
   | 
Update of /cvsroot/q-lang/q/modules/magick
In directory sc8-pr-cvs1:/tmp/cvs-serv23799
Modified Files:
	magick.c magick.q 
Log Message:
new ping_image operation
Index: magick.c
===================================================================
RCS file: /cvsroot/q-lang/q/modules/magick/magick.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** magick.c	26 Dec 2003 11:11:09 -0000	1.6
--- magick.c	26 Dec 2003 14:26:51 -0000	1.7
***************
*** 489,492 ****
--- 489,547 ----
  }
  
+ FUNCTION(magick,ping_image,argc,argv)
+ {
+   char *s;
+   expr *xv;
+   int n = 0;
+   if (argc == 2 && isstr(argv[0], &s) &&
+       (istuple(argv[1], &n, &xv) || isvoid(argv[1])) &&
+       n <= 5) {
+     ImageInfo *info = CloneImageInfo(NULL);
+     Image *img;
+     int matte;
+     if (!info) return __ERROR;
+     if (!parse_info(n, xv, info, &matte)) {
+       DestroyImageInfo(info);
+       return __FAIL;
+     }
+     strncpy(info->filename, s, MaxTextExtent-1);
+     img = PingImage(info, &exception);
+     DestroyImageInfo(info);
+     if (check_exception(&exception))
+       return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg)));
+     if (!img)
+       return __FAIL;
+     else if (img->next) {
+       expr x = mknil;
+       Image *imgs;
+       if (matte >= 0)
+ 	for (imgs = img; imgs; imgs = imgs->next)
+ 	  imgs->matte = (unsigned)matte;
+       /* convert image sequence into list of images */
+       for (imgs = img; imgs->next; imgs = imgs->next)
+ 	;
+       /* imgs now points at the last image in the sequence */
+       while (x && imgs) {
+ 	Image *tmp = imgs->previous;
+ 	if (tmp) {
+ 	  tmp->next = NULL;
+ 	  imgs->previous = NULL;
+ 	}
+ 	x = mkcons(mkobj(type(Image), imgs), x);
+ 	imgs = tmp;
+       }
+       if (!x) {
+ 	DestroyImageList(img);
+ 	return __ERROR;
+       }
+       return x;
+     } else {
+       if (matte >= 0) img->matte = (unsigned)matte;
+       return mkobj(type(Image), img);
+     }
+   } else
+     return __FAIL;
+ }
+ 
  FUNCTION(magick,write_image,argc,argv)
  {
Index: magick.q
===================================================================
RCS file: /cvsroot/q-lang/q/modules/magick/magick.q,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** magick.q	26 Dec 2003 11:11:09 -0000	1.7
--- magick.q	26 Dec 2003 14:26:51 -0000	1.8
***************
*** 126,129 ****
--- 126,134 ----
     see ImageMagick(1) for details.
  
+    The ping_image function is like read_image, but does *not* read the actual
+    pixel data of an image. This is typically used in conjuction with
+    image_info, in order to inspect the properties of an image or image
+    sequence without wasting resources for reading the pixels into memory.
+ 
     The write_image function writes the given image to the given target,
     designated by a name in the same syntax as for read_image. If the input
***************
*** 135,139 ****
     written, see again ImageMagick(1) for details. */
  
! public extern read_image NAME INFO, write_image NAME IMG;
  
  /* Convert an image to a "blob" ("binary large object", represented as a byte
--- 140,145 ----
     written, see again ImageMagick(1) for details. */
  
! public extern read_image NAME INFO, ping_image NAME INFO;
! public extern write_image NAME IMG;
  
  /* Convert an image to a "blob" ("binary large object", represented as a byte
 |