Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image Quality is too low while i am taking view shot of my screen #505

Open
krupal811 opened this issue Jan 18, 2024 · 0 comments
Open

Image Quality is too low while i am taking view shot of my screen #505

krupal811 opened this issue Jan 18, 2024 · 0 comments

Comments

@krupal811
Copy link

const onFinalSave = async () => {
const targetPath =
Platform.OS === 'ios'
? ${RNFS.DocumentDirectoryPath}/${imageName}
: ${RNFS.DownloadDirectoryPath}/${imageName};
const uri = await viewShotRef.current.capture();
const imageBuffer = await RNFS.readFile(uri, 'base64');
const imagePath = ${RNFS.DocumentDirectoryPath}/Pictures/${v4()}.jpg;
await RNFS.writeFile(imagePath, imageBuffer, 'base64');
RNFS.exists(imagePath).then(async status => {
if (status) {
if (Platform.OS === 'ios') {
RNFetchBlob.config({
fileCache: true,
appendExt: 'jpg',
})
.fetch('GET', file://${imagePath})
.then(res => {
console.log({res});
CameraRoll.save(res.data, {type: 'photo'})
.then(() => {
setTimeout(() => {
navigation.navigate('Result', {
img_data: {
path: file://${imagePath},
...imgActualDimension,
},
});
}, 500);
analyticsFunction('image_saved_to_download', {isSaved: true});
})
.catch(err => {
Alert.alert(
'Save Image',
'Failed to save Image: ' + err.message,
[{text: 'OK', onPress: () => console.log('OK Pressed')}],
{cancelable: false},
);
});
})
.catch(error => {
Alert.alert(
I18n.t('Save_Image'),
I18n.t('Failed_to_save_Image') + error.message,
[
{
text: I18n.t('ok'),
onPress: () => console.log('OK Pressed'),
},
],
{cancelable: false},
);
});
} else {
await RNFS.copyFile(file://${imagePath}, targetPath)
.then(() => {
RNFS.scanFile(targetPath)
.then(() => {
setTimeout(() => {
navigation.navigate('Result', {
img_data: {
path: file://${imagePath},
...imgActualDimension,
},
});
}, 500);
analyticsFunction('image_saved_to_download', {isSaved: true});
})
.catch(scanError => {
console.log('Error scanning file:', scanError);
});
})
.catch(err => {
Alert.alert(
'Save Image',
'Failed to save Image: ' + err.message,
[{text: 'OK', onPress: () => console.log('OK Pressed')}],
{cancelable: false},
);
});
}
} else {
console.log('File not exists');
}
});
};

@krupal811 krupal811 changed the title Image Quality is too low while i am taking view show of my screen Image Quality is too low while i am taking view shot of my screen Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant