diff --git a/.gitattributes b/.gitattributes
index 2246fcac5c5a1d59c09be43be5ff92170433c030..ed45cb04c4c8b8fcbdb640a7d93bfbaa16d599b4 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -508,7 +508,6 @@ testfont binary
 /src/modules/Image/encodings/xcf_constant_strings.h foreign_ident
 /src/modules/Image/encodings/xwd.c foreign_ident
 /src/modules/Image/font.c foreign_ident
-/src/modules/Image/image.c foreign_ident
 /src/modules/Image/image.h foreign_ident
 /src/modules/Image/image_module.c foreign_ident
 /src/modules/Image/initstuff.h foreign_ident
diff --git a/src/modules/Image/image.c b/src/modules/Image/image.c
index c34220dce72f2bfec15ab56abbc1817d50b105cf..913a9e59eafc5b946cf80633a883c2d241f878fc 100644
--- a/src/modules/Image/image.c
+++ b/src/modules/Image/image.c
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: image.c,v 1.235 2007/08/10 13:54:51 grubba Exp $
+|| $Id$
 */
 
 /*
@@ -106,6 +106,7 @@
 #include "pike_macros.h"
 #include "object.h"
 #include "interpret.h"
+#include "gc.h"
 #include "svalue.h"
 #include "threads.h"
 #include "array.h"
@@ -196,6 +197,13 @@ static void exit_image_struct(struct object *obj)
 	  */
 }
 
+static void gc_recurse_image_struct(struct object *UNUSED(obj))
+{
+  if (mc_count_bytes(Pike_fp->current_object) && THIS->img) {
+    mc_counted_bytes += sizeof(rgb_group)*THIS->xsize*(long)THIS->ysize;
+  }
+}
+
 /***************** internals ***********************************/
 
 #define apply_alpha(x,y,alpha) \
@@ -5127,6 +5135,8 @@ void init_image_image(void)
    set_init_callback(init_image_struct);
    set_exit_callback(exit_image_struct);
 
+   set_gc_recurse_callback(gc_recurse_image_struct);
+
 
 #ifndef FAKE_DYNAMIC_LOAD
    /* Added by per: Export all functions needed by _Image_GIF */