我只是想获得一个方形图像并尽可能减小图像的尺寸,同时保持图像文本清晰。
这是我的尝试,但没有成功。
const capturePhoto = async () => {
const options = {
qualityPrioritization: 'speed',
skipMetadata: true,
flash: 'off',
width: 500,
height: 500,
};
if (camera.current !== null) {
const photo = await camera.current.takePhoto(options);
const {height, width, path} = photo;
console.log(
`The photo has a height of ${height} and a width of ${width}.`,
);
}
};
你必须使用它的格式,并且必须在相机组件中添加格式道具
就像这样。
const screenAspectRatio = SCREEN_WIDTH / SCREEN_HEIGHT;
const format = useCameraFormat(device, [
{ fps: targetFps },
{ videoAspectRatio: screenAspectRatio },
{ videoStabilizationMode: 'auto' },
{ iso: 'max' },
{ videoHdr: true },
{ videoResolution: 'max' },
{ photoAspectRatio: screenAspectRatio },
{ photoResolution: 'max' },
{ pixelFormat: 'native' },
]);