souvik-ghosh / react-native-create-thumbnail

iOS/Android thumbnail generator with support for both local and remote videos
MIT License
246 stars 105 forks source link

Improve thumbnail image quality #95

Open satyabrata-dash5 opened 1 year ago

satyabrata-dash5 commented 1 year ago

I have used this create thumbnail to show on my social media app but the problem is that it degrade the image quality.

How to improve image quality

tsogzark commented 4 months ago

I am using this library to solve the problem that react-native-view-shot cannot capture video screen shot on IOS. And I encountered the qulaity problem, too. This is my solution and you can use patch-package to apply it.

diff --git a/node_modules/react-native-create-thumbnail/ios/CreateThumbnail.m b/node_modules/react-native-create-thumbnail/ios/CreateThumbnail.m
index 7c6879e..f20b25d 100644
--- a/node_modules/react-native-create-thumbnail/ios/CreateThumbnail.m
+++ b/node_modules/react-native-create-thumbnail/ios/CreateThumbnail.m
@@ -113,7 +113,7 @@ - (void) cleanDir:(NSString *)path forSpace:(unsigned long long)size {
 - (void) generateThumbImage:(AVURLAsset *)asset atTime:(int)timeStamp completion:(void (^)(UIImage* thumbnail))completion failure:(void (^)(NSError* error))failure {
     AVAssetImageGenerator *generator = [[AVAssetImageGenerator alloc] initWithAsset:asset];
     generator.appliesPreferredTrackTransform = YES;
-    generator.maximumSize = CGSizeMake(512, 512);    
+    generator.maximumSize = CGSizeMake(4096, 4096);    
     generator.requestedTimeToleranceBefore = CMTimeMake(0, 1000);
     generator.requestedTimeToleranceAfter = CMTimeMake(0, 1000);
     CMTime time = CMTimeMake(timeStamp, 1000);