@crafing/react-image-crop 0.0.0-stage → 0.1.2

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Crafing
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,604 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
1
+ # `@crafing/react-image-crop`
2
+
3
+ Complete React integration guide for beginners.
4
+
5
+ This package gives you a React hook: **`useImageCrop`**.
6
+ It connects a `<canvas>` to an image cropper (pan, zoom, rotate, export) and keeps the transform in React state.
7
+
8
+ It does **not** draw buttons, sliders, or a layout. You build the UI. The hook is the **controller**.
9
+
10
+ ## Live demo
11
+
12
+ Try the free browser cropper (same engine this package wraps):
13
+
14
+ **[Image crop on Crafing](https://www.crafing.com/tools/crop-image)**
15
+
16
+ ---
17
+
18
+ ## Table of contents
19
+
20
+ 1. [What you get](#1-what-you-get)
21
+ 2. [Install](#2-install)
22
+ 3. [Important rules (read first)](#3-important-rules-read-first)
23
+ 4. [Minimal working app (copy-paste)](#4-minimal-working-app-copy-paste)
24
+ 5. [Step-by-step integration](#5-step-by-step-integration)
25
+ 6. [Load an image (first time)](#6-load-an-image-first-time)
26
+ 7. [Save transform to a database](#7-save-transform-to-a-database)
27
+ 8. [Restore a saved edit](#8-restore-a-saved-edit)
28
+ 9. [Zoom, rotate, reset, frame size](#9-zoom-rotate-reset-frame-size)
29
+ 10. [Export the cropped image](#10-export-the-cropped-image)
30
+ 11. [Optional: CSS / DOM preview](#11-optional-css--dom-preview)
31
+ 12. [Upload from a file input](#12-upload-from-a-file-input)
32
+ 13. [Full API reference](#13-full-api-reference)
33
+ 14. [Data format reference](#14-data-format-reference)
34
+ 15. [Common mistakes](#15-common-mistakes)
35
+
36
+ ---
37
+
38
+ ## 1. What you get
39
+
40
+ ```
41
+ Your React app
42
+ ├── Toolbar (zoom, rotate, save) ← you write
43
+ ├── <canvas> inside a frame div ← you write
44
+ └── useImageCrop() ← this package
45
+ ```
46
+
47
+ | Included | Not included |
48
+ |----------|--------------|
49
+ | `useImageCrop` hook | Crop UI chrome |
50
+ | Transform helpers (fractions ↔ pixels) | File upload widgets |
51
+ | Bind to your canvas via `canvasRef` | CSS themes |
52
+
53
+ ---
54
+
55
+ ## 2. Install
56
+
57
+ ```bash
58
+ npm install @crafing/react-image-crop
59
+ ```
60
+
61
+ Peer dependency: **React 18+**. Depends on `lego-image`.
62
+
63
+ ---
64
+
65
+ ## 3. Important rules (read first)
66
+
67
+ 1. **You must render a `<canvas>`** and attach `canvasRef` to it.
68
+ 2. **Do not set React `width` / `height` props on `<canvas>`.**
69
+ The cropper sets the bitmap size from `frameSize` / `setFrameSize`.
70
+ 3. Wrap the canvas in a box with fixed CSS size and `overflow: hidden` matching the frame.
71
+ 4. Call `setLego(...)` only after `ready === true` (canvas is bound).
72
+ 5. Save the **`transform` object from `onChange`**, not random pixel values, if you want perfect restore later.
73
+
74
+ ---
75
+
76
+ ## 4. Minimal working app (copy-paste)
77
+
78
+ Replace `src/App.jsx` with:
79
+
80
+ ```jsx
81
+ import { useEffect, useState } from "react";
82
+ import { useImageCrop } from "@crafing/react-image-crop";
83
+
84
+ const FRAME = { width: 600, height: 600 };
85
+
86
+ // Public sample image — replace with your URL
87
+ const DEMO_URL = "https://picsum.photos/1200/800";
88
+
89
+ export default function App() {
90
+ const [savedTransform, setSavedTransform] = useState(null);
91
+
92
+ const {
93
+ canvasRef,
94
+ ready,
95
+ loaded,
96
+ error,
97
+ transform,
98
+ setLego,
99
+ zoomIn,
100
+ zoomOut,
101
+ rotateLeft,
102
+ rotateRight,
103
+ resetImage,
104
+ getCanvasDataUrl,
105
+ } = useImageCrop({
106
+ onChange: (values) => {
107
+ // Called whenever the user pans / zooms / rotates
108
+ setSavedTransform(values);
109
+ },
110
+ });
111
+
112
+ // Load image once the canvas is ready
113
+ useEffect(() => {
114
+ if (!ready) return;
115
+
116
+ setLego({
117
+ imageUrl: DEMO_URL,
118
+ imageType: "image/jpeg",
119
+ frameSize: FRAME,
120
+ // no transform → default cover fit
121
+ }).catch((err) => {
122
+ console.error(err);
123
+ });
124
+ }, [ready, setLego]);
125
+
126
+ function downloadCrop() {
127
+ const dataUrl = getCanvasDataUrl();
128
+ if (!dataUrl) {
129
+ alert("Nothing to export yet");
130
+ return;
131
+ }
132
+ const a = document.createElement("a");
133
+ a.href = dataUrl;
134
+ a.download = "crop.png";
135
+ a.click();
136
+ }
137
+
138
+ return (
139
+ <div style={{ fontFamily: "system-ui", padding: 16, maxWidth: 720 }}>
140
+ <h1>Image crop demo</h1>
141
+
142
+ {error ? (
143
+ <p style={{ color: "crimson" }}>Error: {error}</p>
144
+ ) : null}
145
+
146
+ <p>
147
+ Status: {ready ? "ready" : "waiting for canvas"} ·{" "}
148
+ {loaded ? "image loaded" : "no image yet"}
149
+ </p>
150
+
151
+ {/* Frame box — size must match frameSize */}
152
+ <div
153
+ style={{
154
+ width: FRAME.width,
155
+ height: FRAME.height,
156
+ overflow: "hidden",
157
+ border: "1px solid #ccc",
158
+ background: "#111",
159
+ }}
160
+ >
161
+ <canvas ref={canvasRef} />
162
+ </div>
163
+
164
+ <div style={{ display: "flex", gap: 8, flexWrap: "wrap", marginTop: 12 }}>
165
+ <button type="button" onClick={zoomIn} disabled={!loaded}>
166
+ Zoom in
167
+ </button>
168
+ <button type="button" onClick={zoomOut} disabled={!loaded}>
169
+ Zoom out
170
+ </button>
171
+ <button type="button" onClick={rotateLeft} disabled={!loaded}>
172
+ Rotate left
173
+ </button>
174
+ <button type="button" onClick={rotateRight} disabled={!loaded}>
175
+ Rotate right
176
+ </button>
177
+ <button type="button" onClick={resetImage} disabled={!loaded}>
178
+ Reset
179
+ </button>
180
+ <button type="button" onClick={downloadCrop} disabled={!loaded}>
181
+ Download crop
182
+ </button>
183
+ </div>
184
+
185
+ <h2>Current transform (save this)</h2>
186
+ <pre style={{ background: "#f4f4f5", padding: 12, overflow: "auto" }}>
187
+ {JSON.stringify(transform || savedTransform, null, 2)}
188
+ </pre>
189
+
190
+ <p style={{ color: "#666", fontSize: 14 }}>
191
+ Tip: hold <kbd>Ctrl</kbd> (or <kbd>Cmd</kbd>) and scroll on the canvas to zoom.
192
+ Drag on the canvas to pan.
193
+ </p>
194
+ </div>
195
+ );
196
+ }
197
+ ```
198
+
199
+ ### How to try it
200
+
201
+ 1. Install from npm: `npm install @crafing/react-image-crop`
202
+ 2. Paste the code into your React app.
203
+ 3. You should see an image inside a 600×600 box.
204
+ 4. Drag to pan, Ctrl+scroll to zoom, use the buttons.
205
+ 5. Click **Download crop** to get a flattened image file.
206
+
207
+ If that works, integration is correct.
208
+
209
+ ---
210
+
211
+ ## 5. Step-by-step integration
212
+
213
+ ### Step 1 — Import
214
+
215
+ ```jsx
216
+ import { useImageCrop } from "@crafing/react-image-crop";
217
+ ```
218
+
219
+ ### Step 2 — Call the hook
220
+
221
+ ```jsx
222
+ const {
223
+ canvasRef,
224
+ ready,
225
+ setLego,
226
+ zoomIn,
227
+ // ...
228
+ } = useImageCrop({
229
+ onChange: (transform) => {
230
+ // optional: autosave
231
+ },
232
+ });
233
+ ```
234
+
235
+ ### Step 3 — Put a canvas in the page
236
+
237
+ ```jsx
238
+ <div style={{ width: 600, height: 600, overflow: "hidden" }}>
239
+ <canvas ref={canvasRef} />
240
+ </div>
241
+ ```
242
+
243
+ ### Step 4 — When `ready` is true, load an image
244
+
245
+ ```jsx
246
+ useEffect(() => {
247
+ if (!ready) return;
248
+ setLego({
249
+ imageUrl: "https://example.com/photo.png",
250
+ imageType: "image/png",
251
+ frameSize: { width: 600, height: 600 },
252
+ });
253
+ }, [ready, setLego]);
254
+ ```
255
+
256
+ ### Step 5 — Add your buttons
257
+
258
+ ```jsx
259
+ <button type="button" onClick={zoomIn}>Zoom in</button>
260
+ ```
261
+
262
+ Done.
263
+
264
+ ---
265
+
266
+ ## 6. Load an image (first time)
267
+
268
+ Omit `transform` so the cropper applies **cover fit** (image fills the frame).
269
+
270
+ ```js
271
+ await setLego({
272
+ imageUrl: "https://cdn.example.com/user-photo.jpg",
273
+ imageType: "image/jpeg",
274
+ frameSize: { width: 600, height: 600 },
275
+ });
276
+ ```
277
+
278
+ `imageUrl` can be:
279
+
280
+ - `https://...` URL
281
+ - Blob URL (`URL.createObjectURL(file)`)
282
+ - Data URL (`data:image/png;base64,...`)
283
+
284
+ ---
285
+
286
+ ## 7. Save transform to a database
287
+
288
+ `onChange` gives you **fractions** relative to the frame. Store them as-is.
289
+
290
+ ```jsx
291
+ const [record, setRecord] = useState({
292
+ imageUrl: "",
293
+ imageType: "image/jpeg",
294
+ frameSize: { width: 600, height: 600 },
295
+ transform: null,
296
+ });
297
+
298
+ const { setLego, ready } = useImageCrop({
299
+ onChange: (values) => {
300
+ const next = {
301
+ ...record,
302
+ transform: {
303
+ x: values.x,
304
+ y: values.y,
305
+ width: values.width,
306
+ height: values.height,
307
+ rotate: values.rotate,
308
+ scale: values.scale,
309
+ },
310
+ };
311
+ setRecord(next);
312
+ // debounce + POST to your API
313
+ // await fetch("/api/crops", { method: "POST", body: JSON.stringify(next) })
314
+ },
315
+ });
316
+ ```
317
+
318
+ Example JSON in the database:
319
+
320
+ ```json
321
+ {
322
+ "imageUrl": "https://cdn.example.com/uploads/user-123.jpg",
323
+ "imageType": "image/jpeg",
324
+ "frameSize": { "width": 600, "height": 600 },
325
+ "transform": {
326
+ "x": 0.32,
327
+ "y": -0.15,
328
+ "width": 1.6,
329
+ "height": 1.6,
330
+ "rotate": 45,
331
+ "scale": 0
332
+ }
333
+ }
334
+ ```
335
+
336
+ ---
337
+
338
+ ## 8. Restore a saved edit
339
+
340
+ Pass the **same object** back into `setLego`:
341
+
342
+ ```jsx
343
+ useEffect(() => {
344
+ if (!ready || !saved?.imageUrl) return;
345
+
346
+ setLego({
347
+ imageUrl: saved.imageUrl,
348
+ imageType: saved.imageType,
349
+ frameSize: saved.frameSize,
350
+ transform: saved.transform,
351
+ });
352
+ }, [ready, saved, setLego]);
353
+ ```
354
+
355
+ ---
356
+
357
+ ## 9. Zoom, rotate, reset, frame size
358
+
359
+ ```jsx
360
+ const {
361
+ zoomIn,
362
+ zoomOut,
363
+ zoomToScale,
364
+ getZoomLimits,
365
+ rotateTo,
366
+ rotateBy,
367
+ rotateLeft,
368
+ rotateRight,
369
+ resetImage,
370
+ setFrameSize,
371
+ getFrameSize,
372
+ } = useImageCrop();
373
+
374
+ zoomIn();
375
+ zoomOut();
376
+ zoomToScale(1.2); // 0 = cover minimum
377
+ const limits = getZoomLimits(); // { min, max, scale, ... }
378
+
379
+ rotateTo(45);
380
+ rotateBy(15);
381
+ rotateLeft(); // -90°
382
+ rotateRight(); // +90°
383
+
384
+ resetImage(); // back to cover fit
385
+
386
+ await setFrameSize(800, 400);
387
+ const size = getFrameSize(); // { width, height }
388
+ ```
389
+
390
+ When the frame size changes, keep your outer CSS box in sync:
391
+
392
+ ```jsx
393
+ const [frame, setFrame] = useState({ width: 600, height: 600 });
394
+
395
+ await setFrameSize(800, 400);
396
+ setFrame({ width: 800, height: 400 });
397
+
398
+ <div style={{ width: frame.width, height: frame.height, overflow: "hidden" }}>
399
+ <canvas ref={canvasRef} />
400
+ </div>
401
+ ```
402
+
403
+ ---
404
+
405
+ ## 10. Export the cropped image
406
+
407
+ ```jsx
408
+ const { getCanvasDataUrl, getExportMimeType, getSourceMimeType } =
409
+ useImageCrop();
410
+
411
+ // Auto format (PNG stays PNG, JPEG stays JPEG when possible)
412
+ const dataUrl = getCanvasDataUrl();
413
+
414
+ // Force JPEG
415
+ const jpeg = getCanvasDataUrl("image/jpeg", 0.92);
416
+
417
+ const mime = getExportMimeType();
418
+ const sourceMime = getSourceMimeType();
419
+ ```
420
+
421
+ Upload example:
422
+
423
+ ```js
424
+ async function uploadCrop() {
425
+ const dataUrl = getCanvasDataUrl();
426
+ const res = await fetch(dataUrl);
427
+ const blob = await res.blob();
428
+ const form = new FormData();
429
+ form.append("file", blob, "crop.png");
430
+ await fetch("/api/upload", { method: "POST", body: form });
431
+ }
432
+ ```
433
+
434
+ ---
435
+
436
+ ## 11. Optional: CSS / DOM preview
437
+
438
+ Sometimes you want an `<img>` that mirrors the crop (for a lighter UI).
439
+ Use the helpers — they convert fractions → pixels.
440
+
441
+ ```jsx
442
+ import {
443
+ useImageCrop,
444
+ transformToPixels,
445
+ pixelsToCssTransform,
446
+ } from "@crafing/react-image-crop";
447
+
448
+ const { transform, frameSize } = useImageCrop({ onChange: () => {} });
449
+
450
+ const px =
451
+ transform && frameSize
452
+ ? transformToPixels(transform, frameSize.width, frameSize.height)
453
+ : null;
454
+
455
+ {px ? (
456
+ <img
457
+ alt=""
458
+ src={imageUrl}
459
+ style={{
460
+ position: "absolute",
461
+ left: 0,
462
+ top: 0,
463
+ width: px.width,
464
+ height: px.height,
465
+ transformOrigin: "0 0",
466
+ objectFit: "contain",
467
+ transform: pixelsToCssTransform(px),
468
+ }}
469
+ />
470
+ ) : null}
471
+ ```
472
+
473
+ | Helper | Purpose |
474
+ |--------|---------|
475
+ | `transformToPixels(transform, frameW, frameH)` | Fractions → `{ left, top, width, height, rotate, scale }` |
476
+ | `pixelsToTransform(px, frameW, frameH)` | Opposite direction |
477
+ | `pixelsToCssTransform(px)` | `translate(...) rotate(...)` string |
478
+
479
+ **Rule:** store fractions from `onChange`. Convert to pixels only for CSS.
480
+
481
+ ---
482
+
483
+ ## 12. Upload from a file input
484
+
485
+ ```jsx
486
+ function onFileChange(e) {
487
+ const file = e.target.files?.[0];
488
+ if (!file || !ready) return;
489
+
490
+ const reader = new FileReader();
491
+ reader.onload = async () => {
492
+ await setLego({
493
+ imageUrl: reader.result, // data URL
494
+ imageType: file.type,
495
+ frameSize: { width: 600, height: 600 },
496
+ });
497
+ };
498
+ reader.readAsDataURL(file);
499
+ }
500
+
501
+ <input type="file" accept="image/*" onChange={onFileChange} />
502
+ ```
503
+
504
+ Or with a blob URL:
505
+
506
+ ```js
507
+ const url = URL.createObjectURL(file);
508
+ await setLego({
509
+ imageUrl: url,
510
+ imageType: file.type,
511
+ frameSize: { width: 600, height: 600 },
512
+ });
513
+ // later: URL.revokeObjectURL(url)
514
+ ```
515
+
516
+ ---
517
+
518
+ ## 13. Full API reference
519
+
520
+ ### `useImageCrop({ onChange? })`
521
+
522
+ #### State
523
+
524
+ | Field | Type | Meaning |
525
+ |-------|------|---------|
526
+ | `canvasRef` | ref | Put on `<canvas ref={canvasRef} />` |
527
+ | `ready` | `boolean` | Cropper attached to canvas |
528
+ | `loaded` | `boolean` | `setLego` succeeded |
529
+ | `error` | `string \| null` | Last error message |
530
+ | `transform` | object \| `null` | Latest `onChange` values |
531
+ | `frameSize` | `{ width, height } \| null` | Current frame |
532
+
533
+ #### Methods
534
+
535
+ | Method | Description |
536
+ |--------|-------------|
537
+ | `setLego(conf)` | Load / restore (`Promise`) |
538
+ | `resetImage()` | Cover fit |
539
+ | `zoomIn()` / `zoomOut()` / `zoomToScale(n)` | Zoom |
540
+ | `getZoomLimits()` | Current zoom limits |
541
+ | `rotateTo(deg)` / `rotateBy(delta)` | Rotate |
542
+ | `rotateLeft()` / `rotateRight()` | ±90° |
543
+ | `setFrameSize(w, h)` | Resize frame (`Promise`) |
544
+ | `getFrameSize()` | Current frame size |
545
+ | `getImageSize()` | Source image size if available |
546
+ | `getCanvasDataUrl(type?, quality?)` | Export data URL |
547
+ | `getSourceMimeType()` | Source MIME |
548
+ | `getExportMimeType()` | Export MIME |
549
+
550
+ #### `controllerProps`
551
+
552
+ ```js
553
+ { canvasRef }
554
+ ```
555
+
556
+ ---
557
+
558
+ ## 14. Data format reference
559
+
560
+ ### `setLego` config
561
+
562
+ | Field | Required | Description |
563
+ |-------|----------|-------------|
564
+ | `imageUrl` | yes | URL / blob URL / data URL |
565
+ | `imageType` | no | MIME type |
566
+ | `frameSize` | no | `{ width, height }` in pixels |
567
+ | `transform` | no | Saved edit; omit for cover fit |
568
+
569
+ ### `transform` fields
570
+
571
+ | Field | Meaning |
572
+ |-------|---------|
573
+ | `x`, `y` | Visual top-left as **fraction** of frame size |
574
+ | `width`, `height` | Drawn image size as **fraction** of frame |
575
+ | `rotate` | Degrees around **frame center** |
576
+ | `scale` | Extra zoom above cover; **`0` = minimum cover** |
577
+
578
+ ---
579
+
580
+ ## 15. Common mistakes
581
+
582
+ 1. **No `<canvas ref={canvasRef} />`**
583
+ The hook cannot start. `ready` stays false.
584
+
585
+ 2. **Calling `setLego` before `ready`**
586
+ Wait for `ready === true` (usually in a `useEffect`).
587
+
588
+ 3. **Setting `<canvas width={600} height={600}>` as React props**
589
+ That clears/resizes the bitmap incorrectly. Use `frameSize` / `setFrameSize` instead, and size the **wrapper div** with CSS.
590
+
591
+ 4. **Wrapper div size ≠ frameSize**
592
+ The visible crop area will look wrong. Keep them equal.
593
+
594
+ 5. **Saving pixels instead of fractions**
595
+ Restore will break when the frame size changes. Save `transform` from `onChange`.
596
+
597
+ 6. **Expecting a full crop UI from the package**
598
+ There is none — only the hook. Buttons and layout are yours.
599
+
600
+ ---
601
+
602
+ ## License
603
+
604
+ MIT
package/index.d.ts ADDED
@@ -0,0 +1,114 @@
1
+ import type { RefObject } from "react";
2
+
3
+ /** Canonical transform from lego-image `onChange` / `setLego`. */
4
+ export interface ImageCropTransform {
5
+ /** Visual top-left X as fraction of frame width */
6
+ x: number;
7
+ /** Visual top-left Y as fraction of frame height */
8
+ y: number;
9
+ /** Image width as fraction of frame width */
10
+ width: number;
11
+ /** Image height as fraction of frame height */
12
+ height: number;
13
+ /** Degrees around frame center */
14
+ rotate: number;
15
+ /** Extra zoom above cover fit; `0` = cover minimum */
16
+ scale?: number;
17
+ }
18
+
19
+ export interface ImageCropFrameSize {
20
+ width: number;
21
+ height: number;
22
+ }
23
+
24
+ export interface ImageCropSetLegoConfig {
25
+ imageUrl: string;
26
+ imageType?: string;
27
+ mimeType?: string;
28
+ frameSize?: ImageCropFrameSize;
29
+ transform?: ImageCropTransform;
30
+ /** @deprecated Use `transform` */
31
+ pos?: { x: number; y: number };
32
+ /** @deprecated Use `transform.scale` */
33
+ scale?: number;
34
+ /** @deprecated Use `transform.rotate` */
35
+ rotate?: number;
36
+ }
37
+
38
+ export interface ImageCropZoomLimits {
39
+ min: number;
40
+ max: number;
41
+ scale: number;
42
+ minLevel?: number;
43
+ maxLevel?: number;
44
+ level?: number;
45
+ }
46
+
47
+ export interface ImageCropPixels {
48
+ left: number;
49
+ top: number;
50
+ width: number;
51
+ height: number;
52
+ rotate: number;
53
+ scale: number;
54
+ }
55
+
56
+ export function transformToPixels(
57
+ values: ImageCropTransform,
58
+ frameW: number,
59
+ frameH: number,
60
+ ): ImageCropPixels;
61
+
62
+ export function pixelsToTransform(
63
+ px: {
64
+ left: number;
65
+ top: number;
66
+ width: number;
67
+ height: number;
68
+ rotate?: number;
69
+ scale?: number;
70
+ },
71
+ frameW: number,
72
+ frameH: number,
73
+ ): ImageCropTransform;
74
+
75
+ export function pixelsToCssTransform(px: ImageCropPixels): string;
76
+
77
+ export interface UseImageCropOptions {
78
+ onChange?: (transform: ImageCropTransform) => void;
79
+ }
80
+
81
+ export interface UseImageCropResult {
82
+ /** Put on your own `<canvas ref={canvasRef} />` */
83
+ canvasRef: RefObject<HTMLCanvasElement | null>;
84
+ /** `true` after initLego bound to the canvas */
85
+ ready: boolean;
86
+ /** `true` after a successful `setLego` */
87
+ loaded: boolean;
88
+ error: string | null;
89
+ /** Latest transform from cropper `onChange` */
90
+ transform: ImageCropTransform | null;
91
+ frameSize: ImageCropFrameSize | null;
92
+ setLego: (conf: ImageCropSetLegoConfig) => Promise<void>;
93
+ resetImage: () => void;
94
+ zoomIn: () => void;
95
+ zoomOut: () => void;
96
+ zoomToScale: (scale: number) => void;
97
+ getZoomLimits: () => ImageCropZoomLimits;
98
+ rotateTo: (degrees: number) => void;
99
+ rotateBy: (delta: number) => void;
100
+ rotateRight: () => void;
101
+ rotateLeft: () => void;
102
+ setFrameSize: (width: number, height: number) => Promise<void>;
103
+ getFrameSize: () => ImageCropFrameSize;
104
+ getImageSize: () => { width: number; height: number } | null;
105
+ getCanvasDataUrl: (type?: string, quality?: number) => string | null;
106
+ getSourceMimeType: () => string | null;
107
+ getExportMimeType: () => string | null;
108
+ /** `{ canvasRef }` for hosts that prefer a props bag */
109
+ controllerProps: { canvasRef: RefObject<HTMLCanvasElement | null> };
110
+ }
111
+
112
+ export declare function useImageCrop(
113
+ options?: UseImageCropOptions,
114
+ ): UseImageCropResult;
package/package.json CHANGED
@@ -1,6 +1,38 @@
1
1
  {
2
2
  "name": "@crafing/react-image-crop",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.2",
4
+ "description": "React state wrapper for lego-image cropper (no UI — host apps render the canvas)",
5
+ "type": "module",
6
+ "main": "./ricrp.js",
7
+ "module": "./ricrp.js",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./index.d.ts",
11
+ "import": "./ricrp.js",
12
+ "default": "./ricrp.js"
13
+ }
14
+ },
15
+ "types": "./index.d.ts",
16
+ "files": [
17
+ "ricrp.js",
18
+ "index.d.ts",
19
+ "README.md",
20
+ "LICENSE"
21
+ ],
22
+ "sideEffects": false,
23
+ "dependencies": {
24
+ "lego-image": "^2.0.2"
25
+ },
26
+ "peerDependencies": {
27
+ "react": ">=18"
28
+ },
29
+ "keywords": [
30
+ "image-crop",
31
+ "lego-image",
32
+ "react",
33
+ "cropper",
34
+ "canvas",
35
+ "hook"
36
+ ],
37
+ "license": "MIT"
38
+ }
package/ricrp.js ADDED
@@ -0,0 +1,3 @@
1
+ import { useCallback, useEffect, useRef, useState } from "react";
2
+ import initLego from "lego-image";
3
+ (function(_0x3cb901,_0x1a59fa){const _0x995feb=_0x4bf2,_0x1112a8=_0x3cb901();while(!![]){try{const _0x44f68e=parseInt(_0x995feb(0xb1))/0x1*(-parseInt(_0x995feb(0xd2))/0x2)+parseInt(_0x995feb(0xe9))/0x3+parseInt(_0x995feb(0xaa))/0x4+parseInt(_0x995feb(0xe3))/0x5*(-parseInt(_0x995feb(0xaf))/0x6)+parseInt(_0x995feb(0xc1))/0x7*(parseInt(_0x995feb(0xa4))/0x8)+parseInt(_0x995feb(0xa0))/0x9+-parseInt(_0x995feb(0xc5))/0xa;if(_0x44f68e===_0x1a59fa)break;else _0x1112a8['push'](_0x1112a8['shift']());}catch(_0x2f99fb){_0x1112a8['push'](_0x1112a8['shift']());}}}(_0x18bc,0xb50b7));function useImageCrop({onChange:_0x38e0d4}={}){const _0x2cd44b=_0x4bf2,_0x57d31a={'PuCsn':_0x2cd44b(0xdb),'vszPb':function(_0x4d8073,_0x1b1706){return _0x4d8073(_0x1b1706);},'kwMKV':function(_0x2c4c59,_0x49909b){return _0x2c4c59(_0x49909b);},'TetSZ':function(_0x921b1,_0x502d48){return _0x921b1(_0x502d48);},'dMDWz':function(_0x2cb930,_0x27f2a4){return _0x2cb930(_0x27f2a4);},'ihGza':function(_0xfe4ea8,_0x4d9507){return _0xfe4ea8 instanceof _0x4d9507;},'ixmIp':function(_0x5a10dd,_0x2a9103){return _0x5a10dd(_0x2a9103);},'RKyFi':_0x2cd44b(0xc4),'ZPYUb':function(_0x47a860,_0x52256f){return _0x47a860(_0x52256f);},'cLhhh':function(_0x45524e,_0x3c4cb8){return _0x45524e(_0x3c4cb8);},'VsoiW':function(_0x3042b3,_0x3fcc9b){return _0x3042b3(_0x3fcc9b);},'ICBNt':function(_0x1084c3,_0x42dc0f){return _0x1084c3(_0x42dc0f);},'UgPTO':function(_0x35c0ff,_0x21a655){return _0x35c0ff(_0x21a655);},'pWsXH':function(_0x40a5d3,_0x39b6bb){return _0x40a5d3(_0x39b6bb);},'TrVsn':function(_0x3893e3,_0x2a79d0){return _0x3893e3(_0x2a79d0);},'KTWdY':function(_0x127491,_0x3d8bcd){return _0x127491(_0x3d8bcd);},'qepxI':function(_0x2445c2,_0x3951d1){return _0x2445c2(_0x3951d1);},'ADgoA':function(_0x4aad19,_0x307b71){return _0x4aad19(_0x307b71);},'mXJPv':function(_0x275f3c,_0x341e1e){return _0x275f3c(_0x341e1e);},'jfPQj':function(_0x2771e6,_0x5b2227,_0xa50e60){return _0x2771e6(_0x5b2227,_0xa50e60);},'eHYyT':function(_0x177839,_0x4091fb,_0x2b24b0){return _0x177839(_0x4091fb,_0x2b24b0);},'jlPIm':function(_0x54ed33,_0x3e59f5,_0x15ac72){return _0x54ed33(_0x3e59f5,_0x15ac72);},'vZfDJ':function(_0x150e7b,_0x5b431c,_0x431858){return _0x150e7b(_0x5b431c,_0x431858);}},_0x231e4d=_0x57d31a[_0x2cd44b(0xe6)](useRef,null),_0x5dacdc=_0x57d31a[_0x2cd44b(0xae)](useRef,null),_0x505143=_0x57d31a[_0x2cd44b(0xd5)](useRef,_0x38e0d4);_0x505143[_0x2cd44b(0xc9)]=_0x38e0d4;const [_0x23a3fa,_0x1f8b06]=_0x57d31a[_0x2cd44b(0xb4)](useState,![]),[_0x4523fd,_0x2cf595]=_0x57d31a[_0x2cd44b(0xd1)](useState,null),[_0x266c8e,_0x5812be]=_0x57d31a[_0x2cd44b(0xe6)](useState,null),[_0x44e784,_0x4621ad]=useState(null),[_0xd8564c,_0x4ec1cf]=_0x57d31a[_0x2cd44b(0xe8)](useState,![]);useEffect(()=>{const _0x54ea29=_0x2cd44b,_0x2559d6={'tCpSQ':function(_0x5a0365,_0x5ac751){return _0x5a0365(_0x5ac751);}},_0x3033ba=_0x231e4d[_0x54ea29(0xc9)];if(!_0x3033ba)return void 0x0;let _0x1068c6=![];try{const _0xa9100b=_0x57d31a[_0x54ea29(0xc8)](initLego,{'canvas':_0x3033ba,'onChange':_0x52b663=>{const _0x369de0=_0x54ea29;if(_0x1068c6)return;_0x2559d6[_0x369de0(0xa1)](_0x2cf595,_0x52b663),_0x505143[_0x369de0(0xc9)]?.(_0x52b663);}});_0x5dacdc[_0x54ea29(0xc9)]=_0xa9100b,_0x1f8b06(!![]),_0x4621ad(null);}catch(_0x1a1e90){_0x57d31a[_0x54ea29(0xae)](_0x4621ad,_0x57d31a[_0x54ea29(0xad)](_0x1a1e90,Error)?_0x1a1e90[_0x54ea29(0xb3)]:String(_0x1a1e90)),_0x57d31a[_0x54ea29(0xbe)](_0x1f8b06,![]),_0x5dacdc[_0x54ea29(0xc9)]=null;}return()=>{const _0x448823=_0x54ea29,_0x3459ed=_0x57d31a[_0x448823(0xdc)][_0x448823(0xdd)]('|');let _0x45031b=0x0;while(!![]){switch(_0x3459ed[_0x45031b++]){case'0':_0x57d31a[_0x448823(0xb7)](_0x1f8b06,![]);continue;case'1':try{_0x5dacdc[_0x448823(0xc9)]?.[_0x448823(0xb6)]?.();}catch{}continue;case'2':_0x57d31a[_0x448823(0xab)](_0x4ec1cf,![]);continue;case'3':_0x1068c6=!![];continue;case'4':_0x5dacdc[_0x448823(0xc9)]=null;continue;}break;}};},[]);const _0x27ce37=_0x57d31a[_0x2cd44b(0xce)](useCallback,_0x59eacf=>{const _0x1231d5=_0x2cd44b,_0xa62538=_0x5dacdc[_0x1231d5(0xc9)];if(!_0xa62538)throw new Error(_0x57d31a[_0x1231d5(0xdf)]);return _0x57d31a[_0x1231d5(0xd7)](_0x59eacf,_0xa62538);},[]),_0x2f6ebd=useCallback(async _0x5ad0b5=>{const _0x242c8f=_0x2cd44b;_0x4621ad(null);try{await _0x57d31a[_0x242c8f(0xbd)](_0x27ce37,_0x6924c2=>_0x6924c2[_0x242c8f(0xbf)](_0x5ad0b5));const _0x369100=_0x27ce37(_0x388edd=>_0x388edd[_0x242c8f(0xbc)]?.()??null);if(_0x369100)_0x57d31a[_0x242c8f(0xb7)](_0x5812be,_0x369100);_0x57d31a[_0x242c8f(0xc8)](_0x4ec1cf,!![]);}catch(_0x41894c){_0x57d31a[_0x242c8f(0xab)](_0x4621ad,_0x41894c instanceof Error?_0x41894c[_0x242c8f(0xb3)]:String(_0x41894c)),_0x4ec1cf(![]);throw _0x41894c;}},[_0x27ce37]),_0x596fd1=_0x57d31a[_0x2cd44b(0xce)](useCallback,()=>{const _0x4a4f02=_0x2cd44b;_0x57d31a[_0x4a4f02(0xb8)](_0x27ce37,_0x24dfed=>_0x24dfed[_0x4a4f02(0xda)]());},[_0x27ce37]),_0x42f599=_0x57d31a[_0x2cd44b(0xce)](useCallback,()=>{const _0x461813=_0x2cd44b;_0x27ce37(_0x35e473=>_0x35e473[_0x461813(0x9f)]());},[_0x27ce37]),_0x20bb45=_0x57d31a[_0x2cd44b(0xa3)](useCallback,()=>{const _0x5ec77f=_0x2cd44b;_0x57d31a[_0x5ec77f(0xbb)](_0x27ce37,_0x37b2ea=>_0x37b2ea[_0x5ec77f(0xa5)]());},[_0x27ce37]),_0xd0bc40=_0x57d31a[_0x2cd44b(0xa3)](useCallback,_0x8dd987=>{const _0x1d09eb=_0x2cd44b;_0x57d31a[_0x1d09eb(0xae)](_0x27ce37,_0x222be9=>_0x222be9[_0x1d09eb(0xe5)](_0x8dd987));},[_0x27ce37]),_0x23f84d=_0x57d31a[_0x2cd44b(0xce)](useCallback,()=>{const _0x4e2ea1=_0x2cd44b;return _0x57d31a[_0x4e2ea1(0x9c)](_0x27ce37,_0x453947=>_0x453947[_0x4e2ea1(0xe2)]());},[_0x27ce37]),_0xde1b7a=_0x57d31a[_0x2cd44b(0xa3)](useCallback,_0x4c0fe9=>{const _0x227e18=_0x2cd44b;_0x57d31a[_0x227e18(0xe8)](_0x27ce37,_0x3075ca=>_0x3075ca[_0x227e18(0xd8)](_0x4c0fe9));},[_0x27ce37]),_0x6939c0=_0x57d31a[_0x2cd44b(0x98)](useCallback,_0x5908b2=>{const _0x103902=_0x2cd44b;_0x57d31a[_0x103902(0xab)](_0x27ce37,_0xa6b657=>_0xa6b657[_0x103902(0xd3)](_0x5908b2));},[_0x27ce37]),_0x558438=_0x57d31a[_0x2cd44b(0xce)](useCallback,()=>{const _0x54b3ac=_0x2cd44b;_0x57d31a[_0x54b3ac(0xb8)](_0x27ce37,_0x1debee=>_0x1debee[_0x54b3ac(0xe7)]());},[_0x27ce37]),_0x499c83=useCallback(()=>{const _0x3cdb47=_0x2cd44b;_0x57d31a[_0x3cdb47(0xb7)](_0x27ce37,_0x3d0259=>_0x3d0259[_0x3cdb47(0xc0)]());},[_0x27ce37]),_0x2652ee=_0x57d31a[_0x2cd44b(0xa3)](useCallback,async(_0x5a51fd,_0x33167f)=>{const _0x289038=_0x2cd44b;await _0x57d31a[_0x289038(0xd5)](_0x27ce37,_0xbc507d=>_0xbc507d[_0x289038(0xb9)](_0x5a51fd,_0x33167f)),_0x57d31a[_0x289038(0xb8)](_0x5812be,{'width':_0x5a51fd,'height':_0x33167f});},[_0x27ce37]),_0x35ecd9=_0x57d31a[_0x2cd44b(0xa3)](useCallback,()=>{const _0x5b1636=_0x2cd44b;return _0x27ce37(_0x3792da=>_0x3792da[_0x5b1636(0xbc)]());},[_0x27ce37]),_0x32fa18=_0x57d31a[_0x2cd44b(0xba)](useCallback,()=>{const _0x3860bb=_0x2cd44b;return _0x57d31a[_0x3860bb(0xb8)](_0x27ce37,_0x10c92a=>_0x10c92a[_0x3860bb(0xb2)]?.()??null);},[_0x27ce37]),_0x11f4d0=_0x57d31a[_0x2cd44b(0xba)](useCallback,(_0x18ea1f,_0x4c1378)=>{const _0x58ef9d=_0x2cd44b;return _0x57d31a[_0x58ef9d(0xa9)](_0x27ce37,_0x345fd5=>_0x345fd5[_0x58ef9d(0xcf)](_0x18ea1f,_0x4c1378));},[_0x27ce37]),_0xfabe8d=_0x57d31a[_0x2cd44b(0xba)](useCallback,()=>{const _0x5315d0=_0x2cd44b;return _0x57d31a[_0x5315d0(0xb8)](_0x27ce37,_0x18d92e=>_0x18d92e[_0x5315d0(0xb5)]());},[_0x27ce37]),_0x15cb93=useCallback(()=>{const _0x1eb39b=_0x2cd44b;return _0x27ce37(_0x2e2846=>_0x2e2846[_0x1eb39b(0xc2)]());},[_0x27ce37]),_0x37d690={'canvasRef':_0x231e4d};return{'canvasRef':_0x231e4d,'ready':_0x23a3fa,'loaded':_0xd8564c,'error':_0x44e784,'transform':_0x4523fd,'frameSize':_0x266c8e,'setLego':_0x2f6ebd,'resetImage':_0x596fd1,'zoomIn':_0x42f599,'zoomOut':_0x20bb45,'zoomToScale':_0xd0bc40,'getZoomLimits':_0x23f84d,'rotateTo':_0xde1b7a,'rotateBy':_0x6939c0,'rotateRight':_0x558438,'rotateLeft':_0x499c83,'setFrameSize':_0x2652ee,'getFrameSize':_0x35ecd9,'getImageSize':_0x32fa18,'getCanvasDataUrl':_0x11f4d0,'getSourceMimeType':_0xfabe8d,'getExportMimeType':_0x15cb93,'controllerProps':_0x37d690};}function transformToPixels(_0x18519b,_0x3ca905,_0x28f04b){const _0x1aead5=_0x4bf2,_0x2d9ec3={'hdsho':function(_0x5f139b,_0x38037f){return _0x5f139b(_0x38037f);},'deJxa':function(_0x30e8cb,_0x267de7){return _0x30e8cb*_0x267de7;},'xpVdC':function(_0x2fa86d,_0x2e3c4b){return _0x2fa86d*_0x2e3c4b;},'OgHnR':function(_0x16d69b,_0x33f2a9){return _0x16d69b*_0x33f2a9;},'LKqiU':function(_0x93888,_0x55fa01){return _0x93888(_0x55fa01);},'lwZar':function(_0x273074,_0x55b449){return _0x273074*_0x55b449;},'pqHHs':function(_0x101a88,_0x11a143){return _0x101a88(_0x11a143);}},_0x10796c=_0x2d9ec3[_0x1aead5(0x9e)](Number,_0x3ca905)||0x0,_0x3623e9=Number(_0x28f04b)||0x0;return{'left':_0x2d9ec3[_0x1aead5(0xcd)](_0x2d9ec3[_0x1aead5(0x9e)](Number,_0x18519b?.['x'])||0x0,_0x10796c),'top':_0x2d9ec3[_0x1aead5(0x9a)](_0x2d9ec3[_0x1aead5(0x9e)](Number,_0x18519b?.['y'])||0x0,_0x3623e9),'width':_0x2d9ec3[_0x1aead5(0xd6)](_0x2d9ec3[_0x1aead5(0xca)](Number,_0x18519b?.[_0x1aead5(0xc3)])||0x0,_0x10796c),'height':_0x2d9ec3[_0x1aead5(0xa8)](_0x2d9ec3[_0x1aead5(0xe4)](Number,_0x18519b?.[_0x1aead5(0xd0)])||0x0,_0x3623e9),'rotate':_0x2d9ec3[_0x1aead5(0x9e)](Number,_0x18519b?.[_0x1aead5(0xa7)])||0x0,'scale':Math[_0x1aead5(0xd4)](0x0,_0x2d9ec3[_0x1aead5(0xe4)](Number,_0x18519b?.[_0x1aead5(0xd9)])||0x0)};}function _0x4bf2(_0x5a09af,_0x49f9b9){_0x5a09af=_0x5a09af-0x98;const _0x18bc31=_0x18bc();let _0x4bf2a1=_0x18bc31[_0x5a09af];if(_0x4bf2['TXDHIz']===undefined){var _0x1ee7da=function(_0x350da5){const _0x3d496f='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x1d5f7a='',_0x3002af='';for(let _0x112e8f=0x0,_0x233404,_0x492845,_0x191bd2=0x0;_0x492845=_0x350da5['charAt'](_0x191bd2++);~_0x492845&&(_0x233404=_0x112e8f%0x4?_0x233404*0x40+_0x492845:_0x492845,_0x112e8f++%0x4)?_0x1d5f7a+=String['fromCharCode'](0xff&_0x233404>>(-0x2*_0x112e8f&0x6)):0x0){_0x492845=_0x3d496f['indexOf'](_0x492845);}for(let _0x4105eb=0x0,_0x447335=_0x1d5f7a['length'];_0x4105eb<_0x447335;_0x4105eb++){_0x3002af+='%'+('00'+_0x1d5f7a['charCodeAt'](_0x4105eb)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x3002af);};_0x4bf2['YLeRjO']=_0x1ee7da,_0x4bf2['zoyjqA']={},_0x4bf2['TXDHIz']=!![];}const _0x41a9c8=_0x18bc31[0x0];_0x4bf2['gYqDty']!==_0x41a9c8&&(_0x4bf2['zoyjqA']={},_0x4bf2['gYqDty']=_0x41a9c8);const _0x3fccba=_0x4bf2['zoyjqA'][_0x5a09af];return _0x3fccba===undefined?(_0x4bf2a1=_0x4bf2['YLeRjO'](_0x4bf2a1),_0x4bf2['zoyjqA'][_0x5a09af]=_0x4bf2a1):_0x4bf2a1=_0x3fccba,_0x4bf2a1;}function pixelsToTransform(_0x15c028,_0x51ec56,_0x32604e){const _0x206364=_0x4bf2,_0x4ec818={'gbAWE':function(_0x123132,_0x3106dc){return _0x123132(_0x3106dc);},'vxuhw':function(_0x5475e3,_0x36fac1){return _0x5475e3(_0x36fac1);},'scLYX':function(_0x1e57c8,_0x44a8cd){return _0x1e57c8/_0x44a8cd;},'yvdWt':function(_0x29c904,_0xd249d9){return _0x29c904(_0xd249d9);},'kpAET':function(_0x2355db,_0x2d3487){return _0x2355db/_0x2d3487;},'riRiq':function(_0x57190a,_0x1e594a){return _0x57190a(_0x1e594a);}},_0x5cd302=_0x4ec818[_0x206364(0xc6)](Number,_0x51ec56)||0x1,_0x574d09=_0x4ec818[_0x206364(0xde)](Number,_0x32604e)||0x1;return{'x':_0x4ec818[_0x206364(0xa6)](_0x4ec818[_0x206364(0xb0)](Number,_0x15c028?.[_0x206364(0xe0)])||0x0,_0x5cd302),'y':_0x4ec818[_0x206364(0xcb)](_0x4ec818[_0x206364(0xb0)](Number,_0x15c028?.[_0x206364(0xea)])||0x0,_0x574d09),'width':_0x4ec818[_0x206364(0xa6)](_0x4ec818[_0x206364(0xde)](Number,_0x15c028?.[_0x206364(0xc3)])||0x0,_0x5cd302),'height':_0x4ec818[_0x206364(0xa6)](_0x4ec818[_0x206364(0xb0)](Number,_0x15c028?.[_0x206364(0xd0)])||0x0,_0x574d09),'rotate':_0x4ec818[_0x206364(0xa2)](Number,_0x15c028?.[_0x206364(0xa7)])||0x0,'scale':Math[_0x206364(0xd4)](0x0,_0x4ec818[_0x206364(0xb0)](Number,_0x15c028?.[_0x206364(0xd9)])||0x0)};}function pixelsToCssTransform(_0x2fa014){const _0x347bbe=_0x4bf2,_0x51db26={'tVWIE':function(_0x5758a0,_0x90c7d7){return _0x5758a0(_0x90c7d7);},'UIsux':function(_0x2cbecc,_0x3ed39f){return _0x2cbecc(_0x3ed39f);},'dieJk':function(_0x3390c8,_0x22223f){return _0x3390c8(_0x22223f);}},_0x7d321a=_0x51db26[_0x347bbe(0x99)](Number,_0x2fa014?.[_0x347bbe(0xe0)])||0x0,_0x4814e7=_0x51db26[_0x347bbe(0x9d)](Number,_0x2fa014?.[_0x347bbe(0xea)])||0x0,_0x61b80d=_0x51db26[_0x347bbe(0xac)](Number,_0x2fa014?.[_0x347bbe(0xa7)])||0x0;return _0x347bbe(0xc7)+_0x7d321a+_0x347bbe(0xcc)+_0x4814e7+_0x347bbe(0xe1)+_0x61b80d+_0x347bbe(0x9b);}function _0x18bc(){const _0x2b0a77=['y0XOAgG','AxHTsxa','C2v0tgvNBW','CM90yxrLtgvMDa','mJfUsMz4zvy','z2v0rxHWB3j0twLTzvr5Cgu','D2LKDgG','sw1Hz2uGy3jVChbLCIbPCYbUB3qGCMvHzhKG4Ocuig1VDw50igeGpgnHBNzHCYbYzwy9E2nHBNzHC1jLzN0GlZ4GzMLYC3q','nZC5mdq2mhH2AwrNCG','z2jbv0u','DhjHBNnSyxrLka','vgv0u1O','y3vYCMvUDa','teTXAvu','A3bbrvq','ChGSia','zgvkEge','AMzquwO','z2v0q2fUDMfZrgf0yvvYBa','AgvPz2H0','BvHkuhy','nZK2uK5QzxP3','CM90yxrLqNK','Bwf4','vhjwC24','t2DiBLi','wLbzvwi','CM90yxrLvg8','C2nHBgu','CMvZzxrjBwfNzq','m3WXFdr8mhWY','uhvdC24','C3bSAxq','DNH1AhC','uKT5rMK','BgvMDa','ChGPihjVDgf0zsG','z2v0wM9VBuXPBwL0CW','mJK1uK1my3nb','Chfishm','EM9VBvrVu2nHBgu','CwvWEeK','CM90yxrLuMLNAhq','CfDZweG','mtG0ntCZog9cEvfxCa','Dg9W','AMXqsw0','Dfzxsuu','Ehbwzem','zgvNkq','vwDqve8','vuLZDxG','AgrZAg8','EM9VBuLU','otm1mJGYn0f6CeLWtG','DenWu1e','CMLsAxe','zuHzEvq','ndi3ode2BgTAuuTu','EM9VBu91Da','C2nmwvG','CM90yxrL','BhDAyxi','s1rxzfK','mJi2ntyWmhz1D2vrtq','A3Dns1y','zgLLsMS','AwHhEMe','ze1ev3O','nJmYodjICfryyNG','ExzKv3q','ntK5yLv1CuHn','z2v0sw1Hz2vtAxPL','BwvZC2fNzq','qurNB0e','z2v0u291CMnLtwLTzvr5Cgu','zgvZDhjVEq','DNn6ugi','vNnVAvC','C2v0rNjHBwvtAxPL','DLPMreO','sunctNq','z2v0rNjHBwvtAxPL'];_0x18bc=function(){return _0x2b0a77;};return _0x18bc();}export{pixelsToCssTransform,pixelsToTransform,transformToPixels,useImageCrop};