Skip to content

Instantly share code, notes, and snippets.

@bekatom
Created April 13, 2017 07:50
Show Gist options
  • Save bekatom/01c3420b6e89c4670749bebba4ac9148 to your computer and use it in GitHub Desktop.
Save bekatom/01c3420b6e89c4670749bebba4ac9148 to your computer and use it in GitHub Desktop.
react native cached images
let imgAsync = Asset.fromModule(require('./image.jpg'))
await imgAsync.downloadAsync()
if (imgAsync.downloaded) {
console.log('> imgAsync, ', imgAsync)
const imageURL = imgAsync.localUri
Image.getSize(imageURL, (width, height) => {
var imageSize = {
size: {
width,
height
},
offset: {
x: 0,
y: 0,
},
}
ImageEditor.cropImage(imageURL, imageSize, (imageURI) => {
console.log(imageURI);
ImageStore.getBase64ForTag(imageURI, (base64Data) => {
this.handleBase64(base64Data)
ImageStore.removeImageForTag(imageURI);
}, (reason) => console.log(reason) )
}, (reason) => console.log(reason) )
}, (reason) => console.log(reason))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment