How to get thumb image from Photolibrary image?

I am currently getting a memory error because I am uploading a live image to Flatlist of React Native. The problem is that due to the high resolution of the memory, the memory limit has been reached, and the application has become crashed on the iPhone. Is there a way to get a direct thumb pointer, such as an image URL (e.g. url: 'assets-library: //asset/asset.JPG? Id = 5BECA80C-33B3-46A0-AE44-CF28A838CECF & ext = JPG',) ?

I am currently using the "React-native-photo-framework".

+5
source share
1 answer

getAssets takes a prepareForSizeDisplay prop. This uses the PHCachingImageManager to request images of assets with a given size.

Example:

 RNPhotosFramework.getAssets({ startIndex: 0, endIndex: 100, prepareForSizeDisplay: Rect(100,100), fetchOptions: { sourceTypes: ['userLibrary'], sortDescriptors: [{ key: 'creationDate', ascending: true, }] } }).then((response) => console.log(response.assets)); 

When the user deletes a row in FlatList , you can get a full-sized asset. Do not download a full-sized asset until you need to display it.

+1
source

Source: https://habr.com/ru/post/1275909/


All Articles