diff --git a/.gitattributes b/.gitattributes
index 6db10311a84159ec989721c83895d1758ac2e3b1..995051f52b37a5d2052d7586602d7a4ae9522c0a 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -172,6 +172,7 @@ testfont binary
 /src/modules/Image/configure.in foreign_ident
 /src/modules/Image/dct.c foreign_ident
 /src/modules/Image/encodings/Makefile.in foreign_ident
+/src/modules/Image/encodings/any.c foreign_ident
 /src/modules/Image/encodings/configure.in foreign_ident
 /src/modules/Image/encodings/gif.c foreign_ident
 /src/modules/Image/encodings/gif_lzw.c foreign_ident
diff --git a/src/modules/Image/encodings/Makefile.in b/src/modules/Image/encodings/Makefile.in
index c59333403ebe9d47f840ad2e6a9a672807fd5741..063efe53df6927580340264d8fac5373902af268 100644
--- a/src/modules/Image/encodings/Makefile.in
+++ b/src/modules/Image/encodings/Makefile.in
@@ -1,7 +1,7 @@
-# $Id: Makefile.in,v 1.15 1998/04/01 05:37:24 mirar Exp $
+# $Id: Makefile.in,v 1.16 1999/02/24 03:18:07 mirar Exp $
 SRCDIR=@srcdir@
 VPATH=@srcdir@:@srcdir@/../../..:../../..
-OBJS = gif.o gif_lzw.o  pnm.o x.o xwd.o png.o
+OBJS = gif.o gif_lzw.o  pnm.o x.o xwd.o png.o any.o
 
 @SET_MAKE@
 
diff --git a/src/modules/Image/encodings/any.c b/src/modules/Image/encodings/any.c
new file mode 100644
index 0000000000000000000000000000000000000000..634168ad7f13d1565dd60d1622aa7302333497e7
--- /dev/null
+++ b/src/modules/Image/encodings/any.c
@@ -0,0 +1,141 @@
+/* $Id: any.c,v 1.1 1999/02/24 03:18:08 mirar Exp $ */
+
+/*
+**! module Image
+**! note
+**!	$Id: any.c,v 1.1 1999/02/24 03:18:08 mirar Exp $
+**! submodule ANY
+**!
+**!	This method calls the other decoding methods
+**!	and has some heuristics for what type of image
+**!	this is.
+**!
+**!	Methods:
+**!	<ref>decode</ref>, <ref>decode_trans</ref>,
+**!	<ref>_decode</ref>
+**!
+**! see also: Image
+**!
+*/
+#include "global.h"
+
+#include <math.h>
+#include <ctype.h>
+
+#include "stralloc.h"
+RCSID("$Id: any.c,v 1.1 1999/02/24 03:18:08 mirar Exp $");
+#include "pike_macros.h"
+#include "object.h"
+#include "constants.h"
+#include "interpret.h"
+#include "svalue.h"
+#include "threads.h"
+#include "array.h"
+#include "error.h"
+#include "threads.h"
+
+void image_any__decode(INT32 args)
+{
+   if (args!=1 || sp[-args].type!=T_STRING)
+      error("Image.ANY.decode: illegal arguments\n");
+   
+   if (sp[-args].u.string->len<4)
+      error("Image.ANY.decode: too short string\n");
+
+#define CHAR2(a,b) (((a)<<8)|(b))
+   /* ok, try the heuristics */
+   switch (CHAR2(sp[-args].u.string->str[0],sp[-args].u.string->str[1]))
+   {
+      case CHAR2('P','1'):
+      case CHAR2('P','2'):
+      case CHAR2('P','3'):
+      case CHAR2('P','4'):
+      case CHAR2('P','5'):
+      case CHAR2('P','6'):
+      case CHAR2('P','7'):
+	 /* ok, a PNM */
+	 img_pnm_decode(1);
+	 push_text("image/x-pnm");
+	 goto simple_image;
+
+      case CHAR2('J','F'):
+	 /* JFIF */
+	 push_text("Image");
+	 push_int(0);
+	 SAFE_APPLY_MASTER("resolv",2);
+	 push_text("JPEG");
+	 f_index(2);
+	 push_text("decode");
+	 f_index(2);
+	 stack_swap();
+	 f_call_function(2);
+	 goto simple_image;
+
+      case CHAR2('P','N'):
+	 /* PNG */
+	 push_text("Image");
+	 push_int(0);
+	 SAFE_APPLY_MASTER("resolv",2);
+	 push_text("PNG");
+	 f_index(2);
+	 push_text("_decode");
+	 f_index(2);
+	 stack_swap();
+	 f_call_function(2);
+	 return;
+
+      case CHAR2('G','I'):
+	 /* GIF */
+	 image_gif__decode(1);
+	 error("can't handle gif's yet\n");
+	 return;
+
+      case CHAR2(0,0):
+	 switch (CHAR2(sp[-args].u.string->str[2],sp[-args].u.string->str[3]))
+	 {
+	    case CHAR2(0,'k'):
+	       /* XWD */
+	       image_xwd__decode(1);
+	       return; /* done */
+	 }
+	 
+      default:
+	 error("Unknown image format.\n");	 
+   }
+
+simple_image:
+   /* on stack: object image,string type */
+   f_aggregate(2);
+   push_text("image");
+   push_text("type");
+   f_aggregate(2);
+   f_mkmapping(2);
+   return;
+}
+
+/** module *******************************************/
+
+void init_image_any(void)
+{
+   struct program *p;
+
+   start_new_program();
+   
+   add_function("_decode",image_any__decode,
+		"function(string:mapping)",0);
+   /** done **/
+
+   p=end_program();
+   push_object(clone_object(p,0));
+   {
+     struct pike_string *s=make_shared_string("ANY");
+     add_constant(s,sp-1,0);
+     free_string(s);
+   }
+   free_program(p);
+   pop_stack();
+}
+
+void exit_image_any(void)
+{
+}
diff --git a/src/modules/Image/encodings/xwd.c b/src/modules/Image/encodings/xwd.c
index e6307c302eda66ba9c3169734ab04b72df33505d..030aab725d3f4dcccf3be0d8e866ec8e8cd4cbd8 100644
--- a/src/modules/Image/encodings/xwd.c
+++ b/src/modules/Image/encodings/xwd.c
@@ -1,9 +1,9 @@
-/* $Id: xwd.c,v 1.7 1998/05/12 11:43:40 mirar Exp $ */
+/* $Id: xwd.c,v 1.8 1999/02/24 03:18:09 mirar Exp $ */
 
 /*
 **! module Image
 **! note
-**!	$Id: xwd.c,v 1.7 1998/05/12 11:43:40 mirar Exp $
+**!	$Id: xwd.c,v 1.8 1999/02/24 03:18:09 mirar Exp $
 **! submodule XWD
 **!
 **!	This submodule keeps the XWD (X Windows Dump) 
@@ -25,7 +25,7 @@
 #include <ctype.h>
 
 #include "stralloc.h"
-RCSID("$Id: xwd.c,v 1.7 1998/05/12 11:43:40 mirar Exp $");
+RCSID("$Id: xwd.c,v 1.8 1999/02/24 03:18:09 mirar Exp $");
 #include "pike_macros.h"
 #include "object.h"
 #include "constants.h"
@@ -82,7 +82,7 @@ static INLINE unsigned long int_from_16bit(unsigned char *data)
 
 #define CARD32n(S,N) int_from_32bit((unsigned char*)(S)->str+(N)*4)
 
-static void image_xwd__decode(INT32 args)
+void image_xwd__decode(INT32 args)
 {
    struct object *co=NULL;
 
diff --git a/src/modules/Image/image.c b/src/modules/Image/image.c
index 41098896f13206f24e80e7c74145a76f3eb28cbb..29f20e6c75149ffd3da5524d00b770d33fe2a599 100644
--- a/src/modules/Image/image.c
+++ b/src/modules/Image/image.c
@@ -1,9 +1,9 @@
-/* $Id: image.c,v 1.112 1999/02/10 21:48:28 hubbe Exp $ */
+/* $Id: image.c,v 1.113 1999/02/24 03:18:03 mirar Exp $ */
 
 /*
 **! module Image
 **! note
-**!	$Id: image.c,v 1.112 1999/02/10 21:48:28 hubbe Exp $
+**!	$Id: image.c,v 1.113 1999/02/24 03:18:03 mirar Exp $
 **! class image
 **!
 **!	The main object of the <ref>Image</ref> module, this object
@@ -97,7 +97,7 @@
 
 #include "stralloc.h"
 #include "global.h"
-RCSID("$Id: image.c,v 1.112 1999/02/10 21:48:28 hubbe Exp $");
+RCSID("$Id: image.c,v 1.113 1999/02/24 03:18:03 mirar Exp $");
 #include "pike_macros.h"
 #include "object.h"
 #include "constants.h"
@@ -3475,6 +3475,8 @@ extern void init_image_xwd(void);
 extern void exit_image_xwd(void);
 extern void init_image_x(void);
 extern void exit_image_x(void);
+extern void init_image_any(void);
+extern void exit_image_any(void);
 
 /* dynamic encoders (dependent on other modules, loaded dynamically) */
 
@@ -3805,6 +3807,7 @@ void pike_module_init(void)
    init_image_gif();
    init_image_pnm();
    init_image_xwd();
+   init_image_any();
    init_image_x();
 }
 
@@ -3822,6 +3825,7 @@ void pike_module_exit(void)
   exit_image_gif();
   exit_image_pnm();
   exit_image_xwd();
+  exit_image_any();
   if (png_object) 
   {
      free_object(png_object);