//根据图片的链接获取图片的宽高
- (CGSize)downloadImageSizeWithURL:(id)imageURL
{
NSURL*URL =nil;if([imageURL isKindOfClass:[NSURL class]]){
URL=imageURL;
}if([imageURL isKindOfClass:[NSString class]]){
URL=[NSURL URLWithString:imageURL];
}if(URL ==nil)returnCGSizeZero;#ifdefdispatch_main_sync_safeif([[SDImageCache sharedImageCache] diskImageExistsWithKey:absoluteString]){
UIImage* image =[[SDImageCache sharedImageCache] imageFromMemoryCacheForKey:absoluteString];if(!image){
NSData* data =[[SDImageCache sharedImageCache] performSelector:@selector(diskImageDataBySearchingAllPathsForKey:) withObject:URL.absoluteString];
image=[UIImage imageWithData:data];
}if(image){returnimage.size;
}
}#endifCGSize size=CGSizeZero;
NSMutableURLRequest*request =[[NSMutableURLRequest alloc] initWithURL:URL];
NSString*pathExtendsion =[URL.pathExtension lowercaseString];if([pathExtendsion isEqualToString:@"png"]){
size=[self downloadPNGImageSizeWithRequest:request];
}else if([pathExtendsion isEqual:@"gif"]){
size=[self downloadGIFImageSizeWithRequest:request];
}else{
size=[self downloadJPGImageSizeWithRequest:request];
}if(CGSizeEqualToSize(CGSizeZero, size)){
NSData* data =[NSURLConnection sendSynchronousRequest:[NSURLRequest requestWithURL:URL] returningResponse:nil error:nil];
UIImage* image =[UIImage imageWithData:data];if(image){#ifdefdispatch_main_sync_safe
[[SDImageCache sharedImageCache] storeImage:image recalculateFromImage:YES imageData:data forKey:URL.absoluteString toDisk:YES];#endifsize=image.size;
}
}return