Skip to content

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

Open

Description

@krupal811

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');
}
});
};

Activity

  1. 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[/+] on Jan 18, 2024
  2. muyushifang07 commented on Sep 10, 2024

    @muyushifang07

    me too, On the Android platform, the height of the screenshot is blurry when the height exceeds 1000。

  3. newoved commented on Feb 12, 2025

    @newoved

    me too, On the Android platform, the height of the screenshot is blurry when the height exceeds 1000。

    @muyushifang07 This issue has been confirmed on Android too, do you know how to solve it?

  4. dtyrrell commented on May 9, 2025

    @dtyrrell

    I'm also experiencing this problem, has anyone found a solution?

  5. gre commented on May 2, 2026

    @gre
    Owner

    Hi @krupal811 and others on this thread,

    Image quality issues on Android can come from a few different places, so let's narrow it down before drawing conclusions.

    In the snippet you shared, you await viewShotRef.current.capture() (default returns a tmpfile PNG), then RNFS.readFile(uri, 'base64') and RNFS.writeFile(...) to a .jpg extension. That re-encode chain can lose quality if any step re-compresses the bytes — and depending on how RNFetchBlob then handles the file, you can lose more on each round-trip.

    Could you please re-test on react-native-view-shot@5.0.0 with the simplest possible pattern, and report back?

    const uri = await viewShotRef.current.capture({
      format: 'jpg',
      quality: 0.95,
      result: 'tmpfile',
    });
    // uri is already a JPG file — copy / share it directly without re-encoding

    If quality is still degraded with that pattern, please share:

    • the exact format / quality / width / height options you pass,
    • device model + Android API level,
    • the on-screen size of the captured view vs the resolution of the captured image,
    • a side-by-side: original vs captured.

    Leaving open until we have a confirmed repro on v5.0.0 with a minimal pattern.

    Release notes: https://github.com/gre/react-native-view-shot/releases/tag/v5.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions