An open API service indexing awesome lists of open source software.

https://github.com/zentered/solid-image-crop

Solid.js simple image crop tool using Cropper.js
https://github.com/zentered/solid-image-crop

Last synced: 12 months ago
JSON representation

Solid.js simple image crop tool using Cropper.js

Awesome Lists containing this project

README

          



# Solid Image Crop

Solid.js simple image crop tool using
[Cropper.js](https://github.com/fengyuanchen/cropperjs).

## Installation

npm install @zentered/solid-image-crop
# or pnpm i @zentered/solid-image-crop
# or yarn add @zentered/solid-image-crop

## Usage

```jsx
import { createSignal } from 'solid-js'
import ImageUploadDialog from '@zentered/solid-image-crop'

function App() {
const [isOpen, setIsOpen] = createSignal(false)

function closeModal() {
setIsOpen(false)
}

function openModal() {
setIsOpen(true)
}

async function saveImage(file) {
// Upload the image to your server
console.log(file)
}

return (
<>

Open Dialog


>
)
}

export default App
```

### Uploading the cropped image

The `saveImage` function receives a `file` object with the cropped image data
encoded in `base64`. If you need a blob/buffer, check out this
[b64toBlob function](https://stackoverflow.com/a/16245768)

### Special Thanks

- projw-the-lessful, https://codepen.io/projw-the-lessful/pen/bJZKVW