I have just checked your code and found that extent
is infinite here i.e. you are getting a nil
image. I just made a little change here, give extent to your frame
CGRect extent = CGRectMake(0.0, 0.0, image.size.width, image.size.height);
OR
CGRect extent = [aimage extent];
and then try.