@asaddevworld/image-crop 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +94 -2
- package/lib/module/ImageCropper.js +369 -0
- package/lib/module/ImageCropper.js.map +1 -0
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +4 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/utils/geometry.js +102 -0
- package/lib/module/utils/geometry.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/ImageCropper.d.ts +3 -0
- package/lib/typescript/src/ImageCropper.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +40 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/lib/typescript/src/utils/geometry.d.ts +27 -0
- package/lib/typescript/src/utils/geometry.d.ts.map +1 -0
- package/package.json +165 -4
- package/src/ImageCropper.tsx +482 -0
- package/src/index.tsx +14 -0
- package/src/types.ts +40 -0
- package/src/utils/geometry.ts +129 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Asad Ali
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,95 @@
|
|
|
1
|
-
#
|
|
1
|
+
# rn-image-crop
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@asaddevworld/image-crop)
|
|
4
|
+
|
|
5
|
+
An image cropper for React Native. The picture sits under a fixed frame: pinch to zoom around your fingers, drag to move, rotate with two fingers or in quarter turns, pick an aspect preset, and the image never leaves the frame empty. Crop exports the frame at any pixel size through Skia. Gestures run on the UI thread with Reanimated and Gesture Handler.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
<a href="https://github.com/asadDevWorld/rn-image-crop/blob/main/docs/demo.mp4"><img src="https://raw.githubusercontent.com/asadDevWorld/rn-image-crop/main/docs/demo.gif" width="300" alt="rn-image-crop demo" /></a>
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
_Demo recorded on the iOS Simulator from the example app, shown at 2x speed. Full video: [docs/demo.mp4](docs/demo.mp4)._
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @asaddevworld/image-crop @shopify/react-native-skia react-native-reanimated react-native-worklets react-native-gesture-handler
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
With Expo:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npx expo install @asaddevworld/image-crop @shopify/react-native-skia react-native-reanimated react-native-worklets react-native-gesture-handler
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Requires React Native 0.76 or newer, Skia 2, Reanimated 4, and Gesture Handler 3, with `GestureHandlerRootView` at the root.
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
import { useImage } from '@shopify/react-native-skia';
|
|
32
|
+
import { ImageCropper, type ImageCropperHandle } from '@asaddevworld/image-crop';
|
|
33
|
+
|
|
34
|
+
const image = useImage(uri);
|
|
35
|
+
const ref = useRef<ImageCropperHandle>(null);
|
|
36
|
+
|
|
37
|
+
{image ? <ImageCropper ref={ref} image={image} aspect={1} frameRadius={12} /> : null}
|
|
38
|
+
|
|
39
|
+
const { base64, width, height } = await ref.current!.crop({ width: 1080 });
|
|
40
|
+
ref.current?.rotate(90);
|
|
41
|
+
ref.current?.reset();
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## API
|
|
45
|
+
|
|
46
|
+
### `ImageCropper` props
|
|
47
|
+
|
|
48
|
+
| prop | type | default | description |
|
|
49
|
+
|---|---|---|---|
|
|
50
|
+
| `image` | `SkImage` | required | The picture. Load with Skia's `useImage`. |
|
|
51
|
+
| `aspect` | `number` | image ratio | Width divided by height of the frame. |
|
|
52
|
+
| `frameInset` | `number` | `24` | Space around the frame. |
|
|
53
|
+
| `grid` | `'always' \| 'gesture' \| 'never'` | `'gesture'` | Rule-of-thirds lines. |
|
|
54
|
+
| `onChange` | `(state) => void` | | `{ scale, x, y, rotation }` on every change. |
|
|
55
|
+
| `minScaleFactor` | `number` | `1` | Multiplier on the cover scale. |
|
|
56
|
+
| `maxScale` | `number` | `8` | Zoom limit. |
|
|
57
|
+
| `frameRadius` | `number` | `0` | Corner radius of the frame. |
|
|
58
|
+
| `overlayColor` | `string` | `rgba(0,0,0,0.6)` | Dim outside the frame. |
|
|
59
|
+
| `frameColor` | `string` | `#FFFFFF` | Frame and grid lines. |
|
|
60
|
+
|
|
61
|
+
### Ref methods
|
|
62
|
+
|
|
63
|
+
| method | description |
|
|
64
|
+
|---|---|
|
|
65
|
+
| `crop({ width?, height? })` | Resolves `{ image, base64, width, height }`. Omit both for the source resolution of the framed area. |
|
|
66
|
+
| `rotate(90 \| -90)` | Animated quarter turn, then refits to cover the frame. |
|
|
67
|
+
| `reset()` | Back to the initial fit. |
|
|
68
|
+
| `getState()` | Current `{ scale, x, y, rotation }`. |
|
|
69
|
+
|
|
70
|
+
### Helpers
|
|
71
|
+
|
|
72
|
+
`frameFor`, `coverScale`, `clampTranslation`, `frameInImage`, `snapRotation` are exported for custom UIs.
|
|
73
|
+
|
|
74
|
+
## Behaviour notes
|
|
75
|
+
|
|
76
|
+
- The image opens at the scale that covers the frame, centred. Zooming out below that, or dragging a corner away, rubber-bands and springs back on release.
|
|
77
|
+
- Free rotation snaps to the nearest quarter turn when within 10 degrees.
|
|
78
|
+
- Crop maps the frame back into the image through the current transform, draws that region to an offscreen surface, and encodes a PNG.
|
|
79
|
+
|
|
80
|
+
## Example app
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
yarn
|
|
84
|
+
yarn example ios
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Pick a photo or use the built-in scene drawn at runtime. Aspect chips, rotate, reset, crop to 1080 px wide, preview, share.
|
|
88
|
+
|
|
89
|
+
## Credits
|
|
90
|
+
|
|
91
|
+
Inspired by the image cropper demo by Enzo Mangano at reactiive.io. Implemented from scratch for this package.
|
|
92
|
+
|
|
93
|
+
## License
|
|
94
|
+
|
|
95
|
+
MIT © Asad Ali
|
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useState } from 'react';
|
|
4
|
+
import { StyleSheet, View } from 'react-native';
|
|
5
|
+
import { GestureDetector, usePanGesture, usePinchGesture, useRotationGesture, useSimultaneousGestures } from 'react-native-gesture-handler';
|
|
6
|
+
import { Canvas, Group, Image, Line, Path, Rect, RoundedRect, Skia, vec } from '@shopify/react-native-skia';
|
|
7
|
+
import { ReduceMotion, runOnJS, useAnimatedReaction, useDerivedValue, useSharedValue, withSpring, withTiming } from 'react-native-reanimated';
|
|
8
|
+
import { clampTranslation, coverScale, frameFor, frameInImage, rubberBand, snapRotation } from "./utils/geometry.js";
|
|
9
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
const SPRING = {
|
|
11
|
+
damping: 28,
|
|
12
|
+
stiffness: 300,
|
|
13
|
+
mass: 1,
|
|
14
|
+
reduceMotion: ReduceMotion.System
|
|
15
|
+
};
|
|
16
|
+
export const ImageCropper = /*#__PURE__*/forwardRef(function ImageCropper({
|
|
17
|
+
image,
|
|
18
|
+
aspect,
|
|
19
|
+
frameInset = 24,
|
|
20
|
+
grid = 'gesture',
|
|
21
|
+
onChange,
|
|
22
|
+
minScaleFactor = 1,
|
|
23
|
+
maxScale = 8,
|
|
24
|
+
frameRadius = 0,
|
|
25
|
+
overlayColor = 'rgba(0,0,0,0.6)',
|
|
26
|
+
frameColor = '#FFFFFF',
|
|
27
|
+
style,
|
|
28
|
+
accessibilityLabel
|
|
29
|
+
}, ref) {
|
|
30
|
+
const [view, setView] = useState({
|
|
31
|
+
width: 0,
|
|
32
|
+
height: 0
|
|
33
|
+
});
|
|
34
|
+
const imageW = image.width();
|
|
35
|
+
const imageH = image.height();
|
|
36
|
+
const frame = useMemo(() => frameFor(view.width, view.height, aspect, frameInset, imageW / imageH), [view, aspect, frameInset, imageW, imageH]);
|
|
37
|
+
const frameSv = useSharedValue(frame);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
frameSv.value = frame;
|
|
40
|
+
}, [frame, frameSv]);
|
|
41
|
+
const rotation = useSharedValue(0);
|
|
42
|
+
const scale = useSharedValue(1);
|
|
43
|
+
const x = useSharedValue(0);
|
|
44
|
+
const y = useSharedValue(0);
|
|
45
|
+
const gesturing = useSharedValue(0);
|
|
46
|
+
const startScale = useSharedValue(1);
|
|
47
|
+
const startX = useSharedValue(0);
|
|
48
|
+
const startY = useSharedValue(0);
|
|
49
|
+
const startRotation = useSharedValue(0);
|
|
50
|
+
const baseScale = useSharedValue(1);
|
|
51
|
+
const fit = useCallback(animated => {
|
|
52
|
+
'worklet';
|
|
53
|
+
|
|
54
|
+
const f = frameSv.value;
|
|
55
|
+
if (f.width === 0) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const s = coverScale(imageW, imageH, f, rotation.value) * minScaleFactor;
|
|
59
|
+
baseScale.value = s;
|
|
60
|
+
if (animated) {
|
|
61
|
+
scale.value = withSpring(s, SPRING);
|
|
62
|
+
x.value = withSpring(0, SPRING);
|
|
63
|
+
y.value = withSpring(0, SPRING);
|
|
64
|
+
} else {
|
|
65
|
+
scale.value = s;
|
|
66
|
+
x.value = 0;
|
|
67
|
+
y.value = 0;
|
|
68
|
+
}
|
|
69
|
+
}, [frameSv, imageW, imageH, rotation, minScaleFactor, baseScale, scale, x, y]);
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
if (frame.width > 0) {
|
|
72
|
+
const s = coverScale(imageW, imageH, frame, 0) * minScaleFactor;
|
|
73
|
+
baseScale.value = s;
|
|
74
|
+
scale.value = s;
|
|
75
|
+
x.value = 0;
|
|
76
|
+
y.value = 0;
|
|
77
|
+
rotation.value = 0;
|
|
78
|
+
}
|
|
79
|
+
}, [frame, imageW, imageH, minScaleFactor, baseScale, scale, x, y, rotation]);
|
|
80
|
+
const settle = useCallback(() => {
|
|
81
|
+
'worklet';
|
|
82
|
+
|
|
83
|
+
const f = frameSv.value;
|
|
84
|
+
const snapped = snapRotation(rotation.value);
|
|
85
|
+
rotation.value = withSpring(snapped, SPRING);
|
|
86
|
+
const minS = coverScale(imageW, imageH, f, snapped) * minScaleFactor;
|
|
87
|
+
baseScale.value = minS;
|
|
88
|
+
const s = Math.min(maxScale, Math.max(minS, scale.value));
|
|
89
|
+
const clamped = clampTranslation(x.value, y.value, imageW, imageH, s, f, snapped);
|
|
90
|
+
scale.value = withSpring(s, SPRING);
|
|
91
|
+
x.value = withSpring(clamped.x, SPRING);
|
|
92
|
+
y.value = withSpring(clamped.y, SPRING);
|
|
93
|
+
}, [frameSv, rotation, imageW, imageH, minScaleFactor, maxScale, baseScale, scale, x, y]);
|
|
94
|
+
const pan = usePanGesture({
|
|
95
|
+
minPointers: 1,
|
|
96
|
+
maxPointers: 2,
|
|
97
|
+
onBegin: () => {
|
|
98
|
+
'worklet';
|
|
99
|
+
|
|
100
|
+
startX.value = x.value;
|
|
101
|
+
startY.value = y.value;
|
|
102
|
+
gesturing.value = withTiming(1, {
|
|
103
|
+
duration: 120
|
|
104
|
+
});
|
|
105
|
+
},
|
|
106
|
+
onUpdate: e => {
|
|
107
|
+
'worklet';
|
|
108
|
+
|
|
109
|
+
const f = frameSv.value;
|
|
110
|
+
const nx = startX.value + e.translationX;
|
|
111
|
+
const ny = startY.value + e.translationY;
|
|
112
|
+
const c = clampTranslation(nx, ny, imageW, imageH, scale.value, f, rotation.value);
|
|
113
|
+
x.value = c.x + Math.sign(nx - c.x) * rubberBand(Math.abs(nx - c.x), f.width);
|
|
114
|
+
y.value = c.y + Math.sign(ny - c.y) * rubberBand(Math.abs(ny - c.y), f.height);
|
|
115
|
+
},
|
|
116
|
+
onFinalize: () => {
|
|
117
|
+
'worklet';
|
|
118
|
+
|
|
119
|
+
gesturing.value = withTiming(0, {
|
|
120
|
+
duration: 250
|
|
121
|
+
});
|
|
122
|
+
settle();
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
const pinch = usePinchGesture({
|
|
126
|
+
onBegin: () => {
|
|
127
|
+
'worklet';
|
|
128
|
+
|
|
129
|
+
startScale.value = scale.value;
|
|
130
|
+
startX.value = x.value;
|
|
131
|
+
startY.value = y.value;
|
|
132
|
+
},
|
|
133
|
+
onUpdate: e => {
|
|
134
|
+
'worklet';
|
|
135
|
+
|
|
136
|
+
const f = frameSv.value;
|
|
137
|
+
let s = startScale.value * e.scale;
|
|
138
|
+
const minS = baseScale.value;
|
|
139
|
+
if (s < minS) {
|
|
140
|
+
s = minS - rubberBand(minS - s, minS);
|
|
141
|
+
} else if (s > maxScale) {
|
|
142
|
+
s = maxScale + rubberBand(s - maxScale, maxScale);
|
|
143
|
+
}
|
|
144
|
+
// Zoom around the focal point: keep the point under the fingers fixed.
|
|
145
|
+
const fx = e.focalX - (f.x + f.width / 2);
|
|
146
|
+
const fy = e.focalY - (f.y + f.height / 2);
|
|
147
|
+
const k = s / startScale.value;
|
|
148
|
+
x.value = fx - (fx - startX.value) * k;
|
|
149
|
+
y.value = fy - (fy - startY.value) * k;
|
|
150
|
+
scale.value = s;
|
|
151
|
+
},
|
|
152
|
+
onFinalize: () => {
|
|
153
|
+
'worklet';
|
|
154
|
+
|
|
155
|
+
settle();
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
const rotate = useRotationGesture({
|
|
159
|
+
onBegin: () => {
|
|
160
|
+
'worklet';
|
|
161
|
+
|
|
162
|
+
startRotation.value = rotation.value;
|
|
163
|
+
},
|
|
164
|
+
onUpdate: e => {
|
|
165
|
+
'worklet';
|
|
166
|
+
|
|
167
|
+
rotation.value = startRotation.value + e.rotation * 180 / Math.PI;
|
|
168
|
+
},
|
|
169
|
+
onFinalize: () => {
|
|
170
|
+
'worklet';
|
|
171
|
+
|
|
172
|
+
settle();
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
const gesture = useSimultaneousGestures(pan, pinch, rotate);
|
|
176
|
+
const notify = useCallback(state => {
|
|
177
|
+
onChange?.(state);
|
|
178
|
+
}, [onChange]);
|
|
179
|
+
useAnimatedReaction(() => ({
|
|
180
|
+
scale: scale.value,
|
|
181
|
+
x: x.value,
|
|
182
|
+
y: y.value,
|
|
183
|
+
rotation: rotation.value
|
|
184
|
+
}), (current, previous) => {
|
|
185
|
+
if (previous && (current.scale !== previous.scale || current.x !== previous.x || current.y !== previous.y || current.rotation !== previous.rotation)) {
|
|
186
|
+
runOnJS(notify)(current);
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
const imageTransform = useDerivedValue(() => {
|
|
190
|
+
const f = frameSv.value;
|
|
191
|
+
return [{
|
|
192
|
+
translateX: f.x + f.width / 2 + x.value
|
|
193
|
+
}, {
|
|
194
|
+
translateY: f.y + f.height / 2 + y.value
|
|
195
|
+
}, {
|
|
196
|
+
rotate: rotation.value * Math.PI / 180
|
|
197
|
+
}, {
|
|
198
|
+
scale: scale.value
|
|
199
|
+
}, {
|
|
200
|
+
translateX: -imageW / 2
|
|
201
|
+
}, {
|
|
202
|
+
translateY: -imageH / 2
|
|
203
|
+
}];
|
|
204
|
+
});
|
|
205
|
+
const overlayPath = useMemo(() => {
|
|
206
|
+
const b = Skia.PathBuilder.Make();
|
|
207
|
+
b.addRect({
|
|
208
|
+
x: 0,
|
|
209
|
+
y: 0,
|
|
210
|
+
width: view.width,
|
|
211
|
+
height: view.height
|
|
212
|
+
});
|
|
213
|
+
b.addRRect(Skia.RRectXY(frame, frameRadius, frameRadius));
|
|
214
|
+
return b.build();
|
|
215
|
+
}, [view, frame, frameRadius]);
|
|
216
|
+
const gridOpacity = useDerivedValue(() => grid === 'always' ? 1 : grid === 'never' ? 0 : gesturing.value * 0.9);
|
|
217
|
+
useImperativeHandle(ref, () => ({
|
|
218
|
+
getState: () => ({
|
|
219
|
+
scale: scale.value,
|
|
220
|
+
x: x.value,
|
|
221
|
+
y: y.value,
|
|
222
|
+
rotation: rotation.value
|
|
223
|
+
}),
|
|
224
|
+
rotate: degrees => {
|
|
225
|
+
const target = Math.round(rotation.value / 90) * 90 + degrees;
|
|
226
|
+
rotation.value = withSpring(target, SPRING, finished => {
|
|
227
|
+
if (finished) {
|
|
228
|
+
fit(true);
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
},
|
|
232
|
+
reset: () => {
|
|
233
|
+
rotation.value = withSpring(0, SPRING);
|
|
234
|
+
fit(true);
|
|
235
|
+
},
|
|
236
|
+
crop: async options => {
|
|
237
|
+
const region = frameInImage(imageW, imageH, scale.value, x.value, y.value, frame, rotation.value);
|
|
238
|
+
const ratio = frame.width / frame.height;
|
|
239
|
+
const outW = Math.round(options?.width ?? (options?.height ? options.height * ratio : region.width));
|
|
240
|
+
const outH = Math.round(options?.height ?? outW / ratio);
|
|
241
|
+
const surface = Skia.Surface.MakeOffscreen(outW, outH);
|
|
242
|
+
if (!surface) {
|
|
243
|
+
throw new Error('Could not create an offscreen surface.');
|
|
244
|
+
}
|
|
245
|
+
const canvas = surface.getCanvas();
|
|
246
|
+
const r = (Math.round(rotation.value / 90) * 90 % 360 + 360) % 360;
|
|
247
|
+
canvas.save();
|
|
248
|
+
// Rotate the output around its centre, then draw the source region to fill it.
|
|
249
|
+
canvas.translate(outW / 2, outH / 2);
|
|
250
|
+
canvas.rotate(r, 0, 0);
|
|
251
|
+
const drawW = r === 90 || r === 270 ? outH : outW;
|
|
252
|
+
const drawH = r === 90 || r === 270 ? outW : outH;
|
|
253
|
+
canvas.drawImageRect(image, {
|
|
254
|
+
x: region.x,
|
|
255
|
+
y: region.y,
|
|
256
|
+
width: region.width,
|
|
257
|
+
height: region.height
|
|
258
|
+
}, {
|
|
259
|
+
x: -drawW / 2,
|
|
260
|
+
y: -drawH / 2,
|
|
261
|
+
width: drawW,
|
|
262
|
+
height: drawH
|
|
263
|
+
}, Skia.Paint());
|
|
264
|
+
canvas.restore();
|
|
265
|
+
surface.flush();
|
|
266
|
+
const out = surface.makeImageSnapshot();
|
|
267
|
+
const result = {
|
|
268
|
+
image: out,
|
|
269
|
+
base64: out.encodeToBase64(),
|
|
270
|
+
width: outW,
|
|
271
|
+
height: outH
|
|
272
|
+
};
|
|
273
|
+
return result;
|
|
274
|
+
}
|
|
275
|
+
}), [scale, x, y, rotation, fit, imageW, imageH, frame, image]);
|
|
276
|
+
const onLayout = useCallback(e => {
|
|
277
|
+
setView({
|
|
278
|
+
width: Math.round(e.nativeEvent.layout.width),
|
|
279
|
+
height: Math.round(e.nativeEvent.layout.height)
|
|
280
|
+
});
|
|
281
|
+
}, []);
|
|
282
|
+
const thirds = useMemo(() => {
|
|
283
|
+
const lines = [];
|
|
284
|
+
for (let i = 1; i < 3; i++) {
|
|
285
|
+
lines.push({
|
|
286
|
+
p1: {
|
|
287
|
+
x: frame.x + frame.width * i / 3,
|
|
288
|
+
y: frame.y
|
|
289
|
+
},
|
|
290
|
+
p2: {
|
|
291
|
+
x: frame.x + frame.width * i / 3,
|
|
292
|
+
y: frame.y + frame.height
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
lines.push({
|
|
296
|
+
p1: {
|
|
297
|
+
x: frame.x,
|
|
298
|
+
y: frame.y + frame.height * i / 3
|
|
299
|
+
},
|
|
300
|
+
p2: {
|
|
301
|
+
x: frame.x + frame.width,
|
|
302
|
+
y: frame.y + frame.height * i / 3
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
return lines;
|
|
307
|
+
}, [frame]);
|
|
308
|
+
return /*#__PURE__*/_jsx(GestureDetector, {
|
|
309
|
+
gesture: gesture,
|
|
310
|
+
children: /*#__PURE__*/_jsx(View, {
|
|
311
|
+
style: [styles.root, style],
|
|
312
|
+
onLayout: onLayout,
|
|
313
|
+
accessible: true,
|
|
314
|
+
accessibilityLabel: accessibilityLabel ?? 'Image cropper. Pinch to zoom, drag to move, rotate with two fingers.',
|
|
315
|
+
children: view.width > 0 ? /*#__PURE__*/_jsxs(Canvas, {
|
|
316
|
+
style: {
|
|
317
|
+
width: view.width,
|
|
318
|
+
height: view.height
|
|
319
|
+
},
|
|
320
|
+
children: [/*#__PURE__*/_jsx(Group, {
|
|
321
|
+
transform: imageTransform,
|
|
322
|
+
children: /*#__PURE__*/_jsx(Image, {
|
|
323
|
+
image: image,
|
|
324
|
+
x: 0,
|
|
325
|
+
y: 0,
|
|
326
|
+
width: imageW,
|
|
327
|
+
height: imageH,
|
|
328
|
+
fit: "fill"
|
|
329
|
+
})
|
|
330
|
+
}), /*#__PURE__*/_jsx(Path, {
|
|
331
|
+
path: overlayPath,
|
|
332
|
+
color: overlayColor,
|
|
333
|
+
fillType: "evenOdd"
|
|
334
|
+
}), /*#__PURE__*/_jsx(RoundedRect, {
|
|
335
|
+
x: frame.x,
|
|
336
|
+
y: frame.y,
|
|
337
|
+
width: frame.width,
|
|
338
|
+
height: frame.height,
|
|
339
|
+
r: frameRadius,
|
|
340
|
+
color: frameColor,
|
|
341
|
+
style: "stroke",
|
|
342
|
+
strokeWidth: 1.5
|
|
343
|
+
}), /*#__PURE__*/_jsx(Group, {
|
|
344
|
+
opacity: gridOpacity,
|
|
345
|
+
children: thirds.map((l, i) => /*#__PURE__*/_jsx(Line, {
|
|
346
|
+
p1: vec(l.p1.x, l.p1.y),
|
|
347
|
+
p2: vec(l.p2.x, l.p2.y),
|
|
348
|
+
color: frameColor,
|
|
349
|
+
strokeWidth: 0.75,
|
|
350
|
+
opacity: 0.8
|
|
351
|
+
}, i))
|
|
352
|
+
}), /*#__PURE__*/_jsx(Rect, {
|
|
353
|
+
x: 0,
|
|
354
|
+
y: 0,
|
|
355
|
+
width: 0,
|
|
356
|
+
height: 0
|
|
357
|
+
})]
|
|
358
|
+
}) : null
|
|
359
|
+
})
|
|
360
|
+
});
|
|
361
|
+
});
|
|
362
|
+
const styles = StyleSheet.create({
|
|
363
|
+
root: {
|
|
364
|
+
flex: 1,
|
|
365
|
+
overflow: 'hidden',
|
|
366
|
+
backgroundColor: '#000'
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
//# sourceMappingURL=ImageCropper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["forwardRef","useCallback","useEffect","useImperativeHandle","useMemo","useState","StyleSheet","View","GestureDetector","usePanGesture","usePinchGesture","useRotationGesture","useSimultaneousGestures","Canvas","Group","Image","Line","Path","Rect","RoundedRect","Skia","vec","ReduceMotion","runOnJS","useAnimatedReaction","useDerivedValue","useSharedValue","withSpring","withTiming","clampTranslation","coverScale","frameFor","frameInImage","rubberBand","snapRotation","jsx","_jsx","jsxs","_jsxs","SPRING","damping","stiffness","mass","reduceMotion","System","ImageCropper","image","aspect","frameInset","grid","onChange","minScaleFactor","maxScale","frameRadius","overlayColor","frameColor","style","accessibilityLabel","ref","view","setView","width","height","imageW","imageH","frame","frameSv","value","rotation","scale","x","y","gesturing","startScale","startX","startY","startRotation","baseScale","fit","animated","f","s","settle","snapped","minS","Math","min","max","clamped","pan","minPointers","maxPointers","onBegin","duration","onUpdate","e","nx","translationX","ny","translationY","c","sign","abs","onFinalize","pinch","fx","focalX","fy","focalY","k","rotate","PI","gesture","notify","state","current","previous","imageTransform","translateX","translateY","overlayPath","b","PathBuilder","Make","addRect","addRRect","RRectXY","build","gridOpacity","getState","degrees","target","round","finished","reset","crop","options","region","ratio","outW","outH","surface","Surface","MakeOffscreen","Error","canvas","getCanvas","r","save","translate","drawW","drawH","drawImageRect","Paint","restore","flush","out","makeImageSnapshot","result","base64","encodeToBase64","onLayout","nativeEvent","layout","thirds","lines","i","push","p1","p2","children","styles","root","accessible","transform","path","color","fillType","strokeWidth","opacity","map","l","create","flex","overflow","backgroundColor"],"sourceRoot":"../../src","sources":["ImageCropper.tsx"],"mappings":";;AAAA,SACEA,UAAU,EACVC,WAAW,EACXC,SAAS,EACTC,mBAAmB,EACnBC,OAAO,EACPC,QAAQ,QACH,OAAO;AACd,SAASC,UAAU,EAAEC,IAAI,QAAgC,cAAc;AACvE,SACEC,eAAe,EACfC,aAAa,EACbC,eAAe,EACfC,kBAAkB,EAClBC,uBAAuB,QAClB,8BAA8B;AACrC,SACEC,MAAM,EACNC,KAAK,EACLC,KAAK,EACLC,IAAI,EACJC,IAAI,EACJC,IAAI,EACJC,WAAW,EACXC,IAAI,EACJC,GAAG,QACE,4BAA4B;AACnC,SACEC,YAAY,EACZC,OAAO,EACPC,mBAAm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","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ImageCropper","frameFor","coverScale","clampTranslation","frameInImage","snapRotation"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,mBAAgB;AAC7C,SACEC,QAAQ,EACRC,UAAU,EACVC,gBAAgB,EAChBC,YAAY,EACZC,YAAY,QACP,qBAAkB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/** Frame rectangle centred in the viewport, sized by the aspect ratio. */
|
|
4
|
+
export function frameFor(viewW, viewH, aspect, inset, imageAspect) {
|
|
5
|
+
const ratio = aspect ?? imageAspect;
|
|
6
|
+
const maxW = Math.max(0, viewW - inset * 2);
|
|
7
|
+
const maxH = Math.max(0, viewH - inset * 2);
|
|
8
|
+
let width = maxW;
|
|
9
|
+
let height = width / ratio;
|
|
10
|
+
if (height > maxH) {
|
|
11
|
+
height = maxH;
|
|
12
|
+
width = height * ratio;
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
x: (viewW - width) / 2,
|
|
16
|
+
y: (viewH - height) / 2,
|
|
17
|
+
width,
|
|
18
|
+
height
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Scale at which the (rotated) image fully covers the frame. */
|
|
23
|
+
export function coverScale(imageW, imageH, frame, rotation) {
|
|
24
|
+
'worklet';
|
|
25
|
+
|
|
26
|
+
const quarter = Math.round(rotation / 90) % 2 !== 0;
|
|
27
|
+
const w = quarter ? imageH : imageW;
|
|
28
|
+
const h = quarter ? imageW : imageH;
|
|
29
|
+
return Math.max(frame.width / w, frame.height / h);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Clamp a translation so the scaled, 90-degree-rotated image still covers the frame.
|
|
34
|
+
* Translation is the offset of the image centre from the frame centre.
|
|
35
|
+
*/
|
|
36
|
+
export function clampTranslation(x, y, imageW, imageH, scale, frame, rotation) {
|
|
37
|
+
'worklet';
|
|
38
|
+
|
|
39
|
+
const quarter = Math.round(rotation / 90) % 2 !== 0;
|
|
40
|
+
const w = (quarter ? imageH : imageW) * scale;
|
|
41
|
+
const h = (quarter ? imageW : imageH) * scale;
|
|
42
|
+
const maxX = Math.max(0, (w - frame.width) / 2);
|
|
43
|
+
const maxY = Math.max(0, (h - frame.height) / 2);
|
|
44
|
+
return {
|
|
45
|
+
x: Math.min(maxX, Math.max(-maxX, x)),
|
|
46
|
+
y: Math.min(maxY, Math.max(-maxY, y))
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export function rubberBand(distance, dimension, coefficient = 0.55) {
|
|
50
|
+
'worklet';
|
|
51
|
+
|
|
52
|
+
if (distance <= 0 || dimension <= 0) {
|
|
53
|
+
return 0;
|
|
54
|
+
}
|
|
55
|
+
return (1 - 1 / (distance * coefficient / dimension + 1)) * dimension;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Snap to the nearest multiple of 90 when within `tolerance` degrees. */
|
|
59
|
+
export function snapRotation(degrees, tolerance = 10) {
|
|
60
|
+
'worklet';
|
|
61
|
+
|
|
62
|
+
const nearest = Math.round(degrees / 90) * 90 + 0;
|
|
63
|
+
return Math.abs(degrees - nearest) <= tolerance ? nearest || 0 : degrees;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The frame rectangle in image pixel coordinates for a transform.
|
|
68
|
+
* Only 90-degree rotations map to an axis-aligned rectangle; free angles are rounded.
|
|
69
|
+
*/
|
|
70
|
+
export function frameInImage(imageW, imageH, scale, x, y, frame, rotation) {
|
|
71
|
+
const r = (Math.round(rotation / 90) * 90 % 360 + 360) % 360;
|
|
72
|
+
const quarter = r === 90 || r === 270;
|
|
73
|
+
const w = (quarter ? imageH : imageW) * scale;
|
|
74
|
+
const h = (quarter ? imageW : imageH) * scale;
|
|
75
|
+
// Top-left of the drawn (rotated) image in view space, relative to the frame.
|
|
76
|
+
const left = frame.width / 2 + x - w / 2;
|
|
77
|
+
const top = frame.height / 2 + y - h / 2;
|
|
78
|
+
// Frame in rotated-image space (0..w, 0..h).
|
|
79
|
+
const fx = -left;
|
|
80
|
+
const fy = -top;
|
|
81
|
+
const fw = frame.width;
|
|
82
|
+
const fh = frame.height;
|
|
83
|
+
// Undo rotation to get coordinates in the original image.
|
|
84
|
+
let ox = fx / scale;
|
|
85
|
+
let oy = fy / scale;
|
|
86
|
+
let ow = fw / scale;
|
|
87
|
+
let oh = fh / scale;
|
|
88
|
+
if (r === 90) {
|
|
89
|
+
[ox, oy, ow, oh] = [oy, imageH - ox - ow, oh, ow];
|
|
90
|
+
} else if (r === 180) {
|
|
91
|
+
[ox, oy] = [imageW - ox - ow, imageH - oy - oh];
|
|
92
|
+
} else if (r === 270) {
|
|
93
|
+
[ox, oy, ow, oh] = [imageW - oy - oh, ox, oh, ow];
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
x: Math.max(0, Math.min(imageW, ox)),
|
|
97
|
+
y: Math.max(0, Math.min(imageH, oy)),
|
|
98
|
+
width: Math.max(1, Math.min(imageW - Math.max(0, ox), ow)),
|
|
99
|
+
height: Math.max(1, Math.min(imageH - Math.max(0, oy), oh))
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=geometry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["frameFor","viewW","viewH","aspect","inset","imageAspect","ratio","maxW","Math","max","maxH","width","height","x","y","coverScale","imageW","imageH","frame","rotation","quarter","round","w","h","clampTranslation","scale","maxX","maxY","min","rubberBand","distance","dimension","coefficient","snapRotation","degrees","tolerance","nearest","abs","frameInImage","r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CAACC,GAAG,CAAC,CAAC,EAAEsC,EAAE,CAAC,EAAEE,EAAE,CAAC;EAC5D,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImageCropper.d.ts","sourceRoot":"","sources":["../../../src/ImageCropper.tsx"],"names":[],"mappings":"AAoCA,OAAO,KAAK,EAGV,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,YAAS,CAAC;AAiBjB,eAAO,MAAM,YAAY,kHAmaxB,CAAC"}
|