CocoaPods trunk is moving to be read-only. Read more on the blog, there are 9 months to go.
| TestsTested | ✗ |
| LangLanguage | Obj-CObjective C |
| License | MIT |
| ReleasedLast Release | Dec 2014 |
Maintained by Balachander.
ஒற்றன் - Ottran Tamil meaning of Scout
Ottran is a Objective C implementation of ImageScout, which works in swift too.
It allows you to find the size and type of a remote image by downloading as little as possible. Now supports PNG, JPEG, GIF & BMP
Sometimes you need to know the size of a remote image before downloading it, such as
using a custom layout in a UICollectionView.
Ottran parses the image data as it is downloaded. As soon as it finds out the size and type of image, it stops the download. The downloaded data is below 60 KB in most cases.
Just copy and paste those Ottran.h(&).m files to your project.
The only method you will be using is scoutImageWithURI: andOttranCompletion:, with the following full signature:
- (void)scoutImageWithURI:(NSString *)uri andOttranCompletion:(OttranCompletionBlock)completion;
(^OttranCompletionBlock) (NSError *, CGSize, OttranImageType);Here's an example:
Ottran *anScouter = [[Ottran alloc] init];
[anScouter scoutImageWithURI:path andOttranCompletion:^(NSError *error, CGSize size, OttranImageType imageType) {
if (error) {
NSLog(@"Error = %@", error);
} else {
NSLog(@"Image Size = %@",NSStringFromCGSize(size));
switch (imageType) {
case GIF: NSLog(@"Image Type = GIF"); break;
case PNG: NSLog(@"Image Type = PNG"); break;
case JPEG: NSLog(@"Image Type = JPEG"); break;
case BMP: NSLog(@"Image Type = BMP"); break;
case Unsupported: NSLog(@"Image Type = UnSupported"); break;
default: break;
}
}
}];If the image is not successfully parsed, the error will contain more info about the reason.
In that case, the size is going to be CGSizeZero and the type Unsupported.
See LICENSE.