Skip to content

Commit

Permalink
1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
souvik-ghosh committed May 23, 2021
1 parent ae20881 commit 61907c5
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ createThumbnail({
| format | `String` (default `jpeg`) | Thumbnail format, can be one of: `jpeg`, or `png` |
| dirSize | `Number` (default `100`) | Maximum size of the cache directory (in megabytes) |
| headers | `Object` | Headers to load the video with. e.g. `{ Authorization: 'someAuthToken' }` |
| cacheName | `String` (optional) | Cache name for this thumbnail. If specify, this thumbnail will be stored and reuse next time. EX: `video-1` |
| cacheName | `String` (optional) | Cache name for this thumbnail to avoid duplicate generation. If specified, and a thumbnail already exists with the same cache name, it will be returned without generating a new one. |

## Response Object

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public void create(ReadableMap options, Promise promise) {
WritableMap map = Arguments.createMap();
map.putString("path", "file://" + thumbnailDir + '/' + fileName);
Bitmap image = BitmapFactory.decodeFile(file.getAbsolutePath());
map.putDouble("size", image.getByteCount());
map.putString("mime", "image/" + format);
map.putDouble("width", image.getWidth());
map.putDouble("height", image.getHeight());

Expand All @@ -68,9 +70,7 @@ public void create(ReadableMap options, Promise promise) {
long cacheDirSize = dirSize * 1024 * 1024;
OutputStream fOut = null;
try {
File dir = createDirIfNotExists(thumbnailDir);
Bitmap image = getBitmapAtTime(this.reactContext, filePath, timeStamp, headers);
File file = new File(thumbnailDir, fileName);
file.createNewFile();
fOut = new FileOutputStream(file);

Expand All @@ -92,6 +92,8 @@ public void create(ReadableMap options, Promise promise) {

WritableMap map = Arguments.createMap();
map.putString("path", "file://" + thumbnailDir + '/' + fileName);
map.putDouble("size", image.getByteCount());
map.putString("mime", "image/" + format);
map.putDouble("width", image.getWidth());
map.putDouble("height", image.getHeight());

Expand Down
2 changes: 1 addition & 1 deletion example/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function App() {

createThumbnail({
url: path,
timeStamp
timeStamp: parseInt(timeStamp)
})
.then(response => {
setThumbnail(response.path);
Expand Down
8 changes: 4 additions & 4 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ PODS:
- React-cxxreact (= 0.61.5)
- React-jsi (= 0.61.5)
- React-jsinspector (0.61.5)
- react-native-create-thumbnail (1.1.1):
- react-native-create-thumbnail (1.4.0):
- React
- React-RCTActionSheet (0.61.5):
- React-Core/RCTActionSheetHeaders (= 0.61.5)
Expand Down Expand Up @@ -253,7 +253,7 @@ DEPENDENCIES:
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)

SPEC REPOS:
https://github.com/CocoaPods/Specs.git:
trunk:
- boost-for-react-native

EXTERNAL SOURCES:
Expand Down Expand Up @@ -326,7 +326,7 @@ SPEC CHECKSUMS:
React-jsi: cb2cd74d7ccf4cffb071a46833613edc79cdf8f7
React-jsiexecutor: d5525f9ed5f782fdbacb64b9b01a43a9323d2386
React-jsinspector: fa0ecc501688c3c4c34f28834a76302233e29dc0
react-native-create-thumbnail: 98493415cc6e722e80fee6522e5412857a1eed3b
react-native-create-thumbnail: 679c9e15411bbf9aa5ee2ce33b69f69f9f1bc0fe
React-RCTActionSheet: 600b4d10e3aea0913b5a92256d2719c0cdd26d76
React-RCTAnimation: 791a87558389c80908ed06cc5dfc5e7920dfa360
React-RCTBlob: d89293cc0236d9cb0933d85e430b0bbe81ad1d72
Expand All @@ -341,4 +341,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 79310af6b976c356911a8a833e9b99c3399fdda3

COCOAPODS: 1.8.4
COCOAPODS: 1.10.1
2 changes: 2 additions & 0 deletions ios/CreateThumbnail.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ @implementation CreateThumbnail
UIImage *thumbnail = [UIImage imageWithData:imageData];
resolve(@{
@"path" : fullPath,
@"size" : [NSNumber numberWithFloat: data.length],
@"mime" : [NSString stringWithFormat: @"image/%@", format],
@"width" : [NSNumber numberWithFloat: thumbnail.size.width],
@"height" : [NSNumber numberWithFloat: thumbnail.size.height]
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "react-native-create-thumbnail",
"title": "React Native Create Thumbnail",
"version": "1.3.0",
"version": "1.4.0",
"description": "iOS/Android thumbnail generator with support for both local and remote videos",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 61907c5

Please sign in to comment.