| 63 | }, []); |
| 64 | |
| 65 | async function cut(): Promise<string> { |
| 66 | const start = Date.now(); |
| 67 | console.log(""); |
| 68 | console.log("Cut"); |
| 69 | |
| 70 | console.log(camera.pictureSize); |
| 71 | // const ratios = await camera.getSupportedRatiosAsync() |
| 72 | // console.log(ratios) |
| 73 | // const sizes = await camera.getAvailablePictureSizeAsync("2:1") |
| 74 | // console.log(sizes) |
| 75 | |
| 76 | console.log("> taking image..."); |
| 77 | const opts = { skipProcessing: true, exif: false, quality: 0 }; |
| 78 | // const opts = {}; |
| 79 | let photo = await camera.takePictureAsync(opts); |
| 80 | |
| 81 | console.log("> resizing..."); |
| 82 | const { uri } = await ImageManipulator.manipulateAsync( |
| 83 | photo.uri, |
| 84 | [ |
| 85 | { resize: { width: 256, height: 512 } }, |
| 86 | { crop: { originX: 0, originY: 128, width: 256, height: 256 } }, |
| 87 | // { resize: { width: 256, height: 457 } }, |
| 88 | // { crop: { originX: 0, originY: 99, width: 256, height: 256 } }, |
| 89 | // { resize: { width: 256, height: 341 } }, |
| 90 | // { crop: { originX: 0, originY: 42, width: 256, height: 256 } }, |
| 91 | ] |
| 92 | // { compress: 0, format: ImageManipulator.SaveFormat.JPEG, base64: false } |
| 93 | ); |
| 94 | |
| 95 | console.log("> sending to /cut..."); |
| 96 | const resp = await server.cut(uri); |
| 97 | |
| 98 | console.log(`Done in ${((Date.now() - start) / 1000).toFixed(3)}s`); |
| 99 | return resp; |
| 100 | } |
| 101 | |
| 102 | async function paste() { |
| 103 | const start = Date.now(); |