mozmorris / react-webcam

Webcam component
https://codepen.io/mozmorris/pen/JLZdoP
MIT License
1.65k stars 281 forks source link

Image become totally green after taking selfie #333

Open codebarz opened 2 years ago

codebarz commented 2 years ago

Please follow the general troubleshooting steps first:

Bug reports:

There is an issue where the image shows a green background on certain devices after taking selfies with the library. I have tested this use the codepen demo here https://codepen.io/mozmorris/pen/gOOoqpw and attached below is the screenshot

MicrosoftTeams-image

The browser this was taken from is google chrome mobile and device is Infinix HOT 8

This is my code sample in react


 const webcamRef = useRef<Webcam>(null);

const captureSelfie = useCallback(() => {
    const imgSrc = webcamRef.current!.getScreenshot();
    if (imgSrc) setFormValues((prev) => ({ ...prev, selfie_image: imgSrc }));
  }, [webcamRef]);

<Webcam audio={false} ref={webcamRef} screenshotFormat="image/jpeg" />

<Button
      type="button"
      onClick={() => {
      if (!formValues.selfie_image) {
            captureSelfie();
      } else {
            setFormValues((prev) => ({ ...prev, selfie_image: "" }));
       }
      }}
>
      {formValues.selfie_image ? "Retake Selfie" : "Capture Selfie"} <Camera />
</Button>
The-Lone-Druid commented 1 year ago

Have you found the solution, because I'm facing the same issue as well...