I need to read the properties of an image without load or download it. In fact i have implemented a simple method that use the CGImageSourceCreateWithUrl for accomplish this. My problem is that it is returning always error because seems that the imageSource is null. So what can i do for fix it? In the NSURL object i pass urls like: "http://www.example.com/wp-content/uploads/image.jpg" but also ALAssets library Id used to retrieve images inside the phone like "assets-library://asset/asset.JPG?id=E5F41458-962D-47DD-B5EF-E606E2A8AC7A&ext=JPG". This is my method:
-(NSString *) getPhotoInfo:(NSString *)paths{
NSString *xmlList = @“test”;
NSURL * imageFileURL = [NSURL fileURLWithPath:paths];
NSLog(@"imageFileURL %@", imageFileURL);
CGImageSourceRef imageSource = CGImageSourceCreateWithURL((__bridge CFURLRef)(imageFileURL), NULL);
if (imageSource == NULL) {
// Error loading image
NSLog(@"Error loading image");
}
CGFloat width = 0.0f, height = 0.0f;
CFDictionaryRef imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, NULL);
NSLog(@"image source %@", imageSource);
return xmlList;
}
I have saw this posts for try to fix it but nothing seems working:
- CGImageSourceRef imageSource = CGImageSourceCreateWithURL returns NULL
- CGImageSourceCreateWithURL with authentication
- accessing UIImage properties without loading in memory the image
In my project ARC is enabled.
Thanks