diff -r -c php-4.2.3/ext/gd/gd.c php-4.2.3-NEW/ext/gd/gd.c
*** php-4.2.3/ext/gd/gd.c	Tue Sep  3 06:09:29 2002
--- php-4.2.3-NEW/ext/gd/gd.c	Mon Nov 25 09:30:09 2002
***************
*** 134,139 ****
--- 134,140 ----
  	PHP_FE(imagecolorclosestalpha,					NULL)
  	PHP_FE(imagecolorexactalpha,					NULL)
  	PHP_FE(imagecopyresampled,						NULL)
+ 	PHP_FE(imagecopyrotated,						NULL)
  	PHP_FE(imagesettile,							NULL)
  
  	PHP_FE(imagesetbrush,							NULL)
***************
*** 887,892 ****
--- 888,936 ----
  }
  /* }}} */	
  
+ /* {{{ proto int imagecopyrotated(int dst_im, int src_im, double dst_x, double dst_y, int src_x, int src_y, int src_w, int src_h, int angle)
+    Copy and rotate part of an image by an arbitrary number of integer degrees */
+ PHP_FUNCTION(imagecopyrotated)
+ {
+ #if HAVE_LIBGD20
+ 	zval **SIM, **DIM, **SX, **SY, **SW, **SH, **DX, **DY, **ANGLE;
+ 	gdImagePtr im_dst, im_src;
+ 	int srcH, srcW, srcY, srcX, angle;
+ 	double dstY, dstX;
+ 
+ 	if (ZEND_NUM_ARGS() != 9 ||
+ 		zend_get_parameters_ex(9, &DIM, &SIM, &DX, &DY, &SX, &SY, &SW, &SH, &ANGLE) == FAILURE) {
+ 		ZEND_WRONG_PARAM_COUNT();
+ 	}
+ 
+ 	ZEND_FETCH_RESOURCE(im_dst, gdImagePtr, DIM, -1, "Image", le_gd);
+ 	ZEND_FETCH_RESOURCE(im_src, gdImagePtr, SIM, -1, "Image", le_gd);
+ 
+ 	convert_to_long_ex(SX);
+ 	convert_to_long_ex(SY);
+ 	convert_to_long_ex(SW);
+ 	convert_to_long_ex(SH);
+ 	convert_to_double_ex(DX);
+ 	convert_to_double_ex(DY);
+ 	convert_to_long_ex(ANGLE);
+ 
+ 	srcX = Z_LVAL_PP(SX);
+ 	srcY = Z_LVAL_PP(SY);
+ 	srcH = Z_LVAL_PP(SH);
+ 	srcW = Z_LVAL_PP(SW);
+ 	dstX = Z_DVAL_PP(DX);
+ 	dstY = Z_DVAL_PP(DY);
+ 	angle = Z_LVAL_PP(ANGLE);
+ 
+ 	gdImageCopyRotated(im_dst, im_src, dstX, dstY, srcX, srcY, srcW, srcH, angle);
+ 	RETURN_TRUE;
+ #else
+ 	zend_error(E_WARNING, "%s(): requires GD 2.0 or later", get_active_function_name(TSRMLS_C));
+ #endif
+ }
+ /* }}} */	
+ 
+ 
  /* {{{ proto int imagesettile(resource image, resource tile)
     Set the tile image to $tile when filling $image with the "IMG_COLOR_TILED" color */
  PHP_FUNCTION(imagesettile)
***************
*** 1011,1020 ****
  		io_ctx = gdNewDynamicCtx (8, data);
  		if (io_ctx) {
  			if (getmbi(gdGetC, io_ctx) == 0 && skipheader(gdGetC, io_ctx) == 0 ) {
! 				io_ctx->free(io_ctx);
  				return PHP_GDIMG_TYPE_WBM;
  			} else
! 				io_ctx->free(io_ctx);
  		}
  	}
  #endif
--- 1055,1064 ----
  		io_ctx = gdNewDynamicCtx (8, data);
  		if (io_ctx) {
  			if (getmbi(gdGetC, io_ctx) == 0 && skipheader(gdGetC, io_ctx) == 0 ) {
! 				io_ctx->gd_free(io_ctx);
  				return PHP_GDIMG_TYPE_WBM;
  			} else
! 				io_ctx->gd_free(io_ctx);
  		}
  	}
  #endif
***************
*** 1206,1212 ****
  		} else {
  			im = (*ioctx_func_p)(io_ctx);
  		}
! 		io_ctx->free(io_ctx);
  #endif
  	} else {
  		if (image_type == PHP_GDIMG_TYPE_GD2PART) {
--- 1250,1256 ----
  		} else {
  			im = (*ioctx_func_p)(io_ctx);
  		}
! 		io_ctx->gd_free(io_ctx);
  #endif
  	} else {
  		if (image_type == PHP_GDIMG_TYPE_GD2PART) {
diff -r -c php-4.2.3/ext/gd/gd_ctx.c php-4.2.3-NEW/ext/gd/gd_ctx.c
*** php-4.2.3/ext/gd/gd_ctx.c	Sun Aug  5 09:21:29 2001
--- php-4.2.3-NEW/ext/gd/gd_ctx.c	Mon Nov 25 09:08:04 2002
***************
*** 67,73 ****
  		ctx = emalloc(sizeof(gdIOCtx));
  		ctx->putC = _php_image_output_putc;
  		ctx->putBuf = _php_image_output_putbuf;
! 		ctx->free = _php_image_output_ctxfree;
  
  #if APACHE && defined(CHARSET_EBCDIC)
  		/* XXX this is unlikely to work any more thies@thieso.net */
--- 67,73 ----
  		ctx = emalloc(sizeof(gdIOCtx));
  		ctx->putC = _php_image_output_putc;
  		ctx->putBuf = _php_image_output_putbuf;
! 		ctx->gd_free = _php_image_output_ctxfree;
  
  #if APACHE && defined(CHARSET_EBCDIC)
  		/* XXX this is unlikely to work any more thies@thieso.net */
***************
*** 95,101 ****
  			break;
  	}
  	
! 	ctx->free(ctx);
  
  	if(fp) {
  		fflush(fp);
--- 95,101 ----
  			break;
  	}
  	
! 	ctx->gd_free(ctx);
  
  	if(fp) {
  		fflush(fp);
diff -r -c php-4.2.3/ext/gd/php_gd.h php-4.2.3-NEW/ext/gd/php_gd.h
*** php-4.2.3/ext/gd/php_gd.h	Thu Feb 28 00:26:12 2002
--- php-4.2.3-NEW/ext/gd/php_gd.h	Mon Nov 25 09:15:35 2002
***************
*** 102,107 ****
--- 102,108 ----
  PHP_FUNCTION(imagecolorclosestalpha);
  PHP_FUNCTION(imagecolorexactalpha);
  PHP_FUNCTION(imagecopyresampled);
+ PHP_FUNCTION(imagecopyrotated);
  PHP_FUNCTION(imagesetthickness);
  PHP_FUNCTION(imagesettile);
  PHP_FUNCTION(imagecopymergegray);
