phuochau / react-native-thumbnail

Get thumbnail from local media. Currently, it only supports for video.
MIT License
135 stars 104 forks source link

Return resized thumbnail (only Android) #28

Open zanfirovidius opened 6 years ago

zanfirovidius commented 6 years ago

Added getResized(String filePath, Integer maxSize, Promise promise) This will return the thumbnail resized to size that will not exceed (width or height) the maxSize parameter.

For our case-use we needed an way to optimise the loading of the thumbnails in an FlatList. And one of the steps was to resize theme to a smaller one based on the device screen and not load an 1080 thumbnail when we just need an 400.

The usage will be similar to the other function with the exception of an additional parameter which will define the size of the thumbnail.

import RNThumbnail from 'react-native-thumbnail';

RNThumbnail.getResized(filepath, 400).then((result) => {
  console.log(result.path); // thumbnail path
})

This will work only for Android!