Verwendung

Choose capture quality and output.

tsx
// Choose capture quality and output.
import { Button, Camera, cameraRef, fileSystem, type PictureOptions } from 'kuito';

// Smaller files for an upload, with the bytes in memory so nothing reads the file again.
const forUpload: PictureOptions = { quality: 0.6, bytes: true };

function Uploader() {
  const camera = cameraRef();

  const send = async () => {
    const picture = await camera.current?.takePicture(forUpload);

    if (!picture?.bytes) return;
    await fetch('https://api.example.com/photos', { method: 'POST', body: picture.bytes });
    await fileSystem.delete(picture.uri);
  };

  return (
    <>
      <Camera ref={camera} flex={1} />
      <Button onPress={send}>Send</Button>
    </>
  );
}

Typdeklaration

ts
export type PictureOptions = SpecPictureOptions;

Mitglieder 2

NameTypErforderlichBeschreibung
qualitynumberNeinJPEG quality from 0 to 1; 1 by default.
bytesbooleanNeinAlso return the JPEG's bytes.
Generiert aus den öffentlichen TypeScript-Deklarationen: Signaturen, Props und Standardwerte stammen aus der geprüften Quelle, Beschreibungen aus deren JSDoc. Kein Standardwert ist erfunden.