Skip to content

Commit 55be4fa

Browse files
replaced the loading method with its call to a lower method that passes in the same valued, with the exception being the target size. In the previous call it was sending a CGSizeZero for the size, which when going through the React_ImageLoader, would load the whole image at full size, but also make a uncompressed version of that image as a CGImage, which would then be transformed and resized buy the method, but by passing in the desired target size here, we are able to load the image in the correct size and be lighter on the memory usage for large images, and then the rest of the transform can take place. (#248)
1 parent 14961fd commit 55be4fa

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

ios/RCTImageResizer/RCTImageResizer.m

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,16 @@ void transformImage(UIImage *image,
368368
return;
369369
}
370370

371-
372-
[[self.bridge moduleForName:@"ImageLoader" lazilyLoadIfNecessary:YES] loadImageWithURLRequest:[RCTConvert NSURLRequest:path] callback:^(NSError *error, UIImage *image) {
371+
RCTImageLoader *loader = [self.bridge moduleForName:@"ImageLoader" lazilyLoadIfNecessary:YES];
372+
NSURLRequest *request = [RCTConvert NSURLRequest:path];
373+
[loader loadImageWithURLRequest:request
374+
size:newSize
375+
scale:1
376+
clipped:YES
377+
resizeMode:RCTResizeModeStretch
378+
progressBlock:nil
379+
partialLoadBlock:nil
380+
completionBlock:^(NSError *error, UIImage *image) {
373381
if (error) {
374382
callback(@[@"Can't retrieve the file from the path.", @""]);
375383
return;

0 commit comments

Comments
 (0)