UIImage *newImg = [self scaleAndRotateImage:image];
UIImage *timestamped;
CGSize imgSize = newImg.size;
UIGraphicsBeginImageContext(imgSize);
[newImg drawInRect:CGRectMake(0, 0, newImg.size.width, newImg.size.height)];
NSDate *now = [NSDate date];
NSCalendar *cal = [[NSCalendar alloc] initWithCalendarIdentifier: NSGregorianCalendar];
//Create the dateformatter object
NSDateFormatter *formatter = [[[NSDateFormatter alloc] init] autorelease];
//Set the required date format
[formatter setDateFormat:@"MM/dd/yyyy"];
NSMutableString *month;
NSMutableString *day;
NSMutableString *year;
unsigned unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit;
NSDateComponents *components = [cal components:unitFlags fromDate:now];
month = [NSString stringWithFormat:@"%i", [components month]];
day = [NSString stringWithFormat:@"%i", [components day]];
year = [NSString stringWithFormat:@"%i", [components year]];
NSMutableString *dateString = [[NSMutableString alloc] init];
[dateString appendString:month];
[dateString appendString:@"/"];
[dateString appendString:day];
[dateString appendString:@"/"];
[dateString appendString:year];
//draw the text
CGSize theSize;
theSize = [dateString sizeWithFont:[UIFont systemFontOfSize:44.0f] constrainedToSize:CGSizeMake(newImg.size.width / 2, FLT_MAX) lineBreakMode:NSLineBreakByWordWrapping];
UIColor *orange = [UIColor colorWithRed:1.0 green:128 / 255.0 blue:0.0 / 255.0 alpha:1.0];
[orange set];
CGRect textRect = CGRectMake(newImg.size.width - theSize.width - 20, newImg.size.height - theSize.height - 15, theSize.width, theSize.height);
[dateString drawInRect:textRect withFont:[UIFont systemFontOfSize:44.0f]];
[dateString release];
[cal release];
timestamped = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();