- (CGFloat)getImageSizeWithURL:(NSURL *)url
{
CGImageSourceRef image = CGImageSourceCreateWithURL((CFURLRef)url, NULL);
CGFloat width = 0.0f, height = 0.0f;
if (image)
{
CFDictionaryRef imageAcc = CGImageSourceCopyPropertiesAtIndex(image, 0, NULL);
if (imageAcc != NULL)
{
CFNumberRef widthNumber = CFDictionaryGetValue(imageAcc, kCGImagePropertyPixelWidth);
if (widthNumber != NULL) {
CFNumberGetValue(widthNumber, kCFNumberFloatType, &width);
NSString *widthStr = [NSString stringWithFormat:@"%@",widthNumber];
width = widthStr.floatValue;
NSLog(@"%f",width);
}
CFNumberRef heightNumber = CFDictionaryGetValue(imageAcc, kCGImagePropertyPixelHeight);
if (heightNumber != NULL) {
CFNumberGetValue(heightNumber, kCFNumberFloatType, &height);
NSString *heightStr = [NSString stringWithFormat:@"%@",heightNumber];
height = heightStr.floatValue;
NSLog(@"%f",height);
}
CFRelease(imageAcc);
}
CFRelease(image);
}
NSLog(@"%f",height/width);
return height/width;
}