Currently i am fetching memory issue because i am loading direct image in Flatlist of React Native. Issue is that due to high resolutions images memory limit reached and app get crashed on iPhone. Is there any way i can fetch direct thumb url like image url (e.g. url: 'assets-library://asset/asset.JPG?id=5BECA80C-33B3-46A0-AE44-CF28A838CECF&ext=JPG',) ?
Currently i am using 'React-native-photo-framework'.
Finally i have my own solution for this question. I have tried all ways to resolve but i am not able to resolve it. Lastly i come to know that new Photo Library provide options to fetch resized image but thats what not working with react-native-photos-framework. My native experience will help me to resolve my issue, hope this will help you. Here is link with detail description and code.
Let me add here code snippets.
Import Native Photo Library
#import <Photos/Photos.h>
CGSize retinaSquare = CGSizeMake(600, 600);
PHImageRequestOptions *cropToSquare = [[PHImageRequestOptions alloc] init];
cropToSquare.resizeMode = PHImageRequestOptionsResizeModeExact;
cropToSquare.deliveryMode = PHImageRequestOptionsDeliveryModeOpportunistic;
[cropToSquare setSynchronous:YES];
NSURL *imageurl = [NSURL URLWithString:@"youimagepath"];
PHFetchResult* asset =[PHAsset fetchAssetsWithALAssetURLs:[NSArray arrayWithObjects:imageurl, nil] options:nil];
[[PHImageManager defaultManager] requestImageForAsset:(PHAsset *)[asset objectAtIndex:0] targetSize:retinaSquare contentMode:PHImageContentModeAspectFit options:cropToSquare resultHandler:^(UIImage *fetchedImage, NSDictionary *info) {
NSData *imageData = UIImageJPEGRepresentation(fetchedImage,0.65);
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSTimeInterval timeStamp = [[NSDate date] timeIntervalSince1970];
NSString *filePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:[NSString stringWithFormat:@"%0.0f.jpg", timeStamp*1000]];
NSError *error = nil;
[imageData writeToFile:filePath options:NSDataWritingAtomic error:&error];
NSURL* fileUrl = [NSURL fileURLWithPath:filePath];
if(error){
fileUrl = imageurl;
}
NSString *resizedImagePath = [NSString stringWithFormat:@"%@",fileUrl];
}];