Closed acro5piano closed 9 months ago
Sorry my investigation was not enough.
Catch and show the code then it says ExifInterface only supports saving attributes on JPEG formats
.
try {
const data = await this.camera.takePictureAsync(options)
const hoge = await ImageEditor.cropImage(data.uri, {
offset: { x: 10, y: 10 },
size: { width: 10, height: 10 },
})
console.log(hoge)
} catch (e) {
console.error(e)
}
@acro5piano What is data
returned by takePictureAsync
function?
Thanks for your reply. I'm reinstalling it, so wait a moment please.
data
is something like this
{ uri: 'file:///data/user/0/com.mydomain.app/cache/Camera/29488e04-034f-4613-9108-29b42e6206d6.jpg',
height: 960,
width: 1280,
pictureOrientation: 1,
deviceOrientation: 1 }
I also tried data.base64
but no luck:
const data = await this.camera.takePictureAsync({ quality: 0.3, base64: true })
try {
const cropped = await ImageEditor.cropImage(`data:image/jpeg;base64,${data.base64}`, {
offset: { x: 10, y: 10 },
size: { width: 10, height: 10 },
})
If I commented out the following line, it seems to work correctly.
Is it okay to create a PR to disable copyExif
when given params is set to do so.
I know that is not the ideal solution but should be the current workaround.
@acro5piano Can you use your workaround for now? I need to dig deeper to apply the correct fix.
Thank you. I will use patch-package for now.
In the iOS lib, the cropped picture is being saved as a PNG instead of a JPEG. I have created a pull request for this. It may possibly solve this issue. #44
Any updates on the topic ? I'm facing the same issue on Android, althought it probably not related to this library. I use react-native-image-resizer as an input for cropping. I didn't really manage to find the exact patern that trigger the issue, but it seems to be more likely to happen when the image that you try to crop is small (like 100px X 100px ). So I suspect this is related to native-image-resizer not always handling well the resize process. I'm not sure my comments helps a lot, but well, some people might have the same problem. And indeed commenting the line in JAVA module where the copyExif is done solve the problem.
UPDATE: it solves to issue but brings a new one... Now, sometimes, output pictures are rotated. I don't know that much about exif, but eventually, it seems to be kind of usefull ... I ended up doing a try & catch in the JAVA lines related to copyExif. At least it deals with the 10% of errors I had without side effects on pictures that were doing fine.
Are there any news on this? We're getting the error as well but only on few devices. Can't reproduce this yet but we're using react-native-image-resizer as input for cropping as well. An issue were created there for an related topic too but this was already merged in January and we're running the newest version (just updated from 1.2.3 to 1.2.4 now).
Here the related PR: https://github.com/bamlab/react-native-image-resizer/pull/209
Data looks fine... this is from our logs:
Error while cropping image: ExifInterface only supports saving attributes on JPEG formats.
uri: file:///data/user/0/XXX/cache/Camera/5deb3737-0c94-4925-bb7f-695a83215ef2.jpg, width: 252, height: 320
resImageUri: file:///data/user/0/XXX/cache/1599207653198.JPEG, width: 180, height: 320
2nd line (uri: ...) contains the data input for react-native-image-resizer and 3rd line the resized image data returned by react-native-image-resizer.
Is the only solution currently to modify the code itself as mentioned by @acro5piano and additionally add the fix for orientation as pointed out by @MebDevelop or is there already a new configuartion option or anything else I may have missed?
react-native-camera
is deprecated. Please use react-native-vision-camera
instead
Hi, thank you for the great library. I am getting the following error when use with react-native-camera. Am I missing something? Thank you in advance.
Bug
Environment info
React native info output:
Library version: ^2.0.1
Steps To Reproduce
Describe what you expected to happen:
Reproducible sample code