1.0.15 • Published 3 years ago

mobile-image-editor v1.0.15

Weekly downloads
-
License
-
Repository
github
Last release
3 years ago

mobile-image-editor

This is an open source that allows you to edit images on your mobile.

npm version

installing

npm install mobile-image-editor

example

React

import React, { useEffect, useRef, useState } from 'react'
import ImageEditor from 'mobile-image-editor'

const ImageInput = () => {
	const ref = useRef();
	const [open, setOpen] = useState(false);
	const [baseUrl, setBaseUrl] = useState();

	useEffect(() => {
		if (open) {
			new ImageEditor(ref.current, {
				baseImage: baseUrl,
				images: [..."images"],
				events: {
					onFinish: async (blob) => {
            // done button click Listener
						const file = new File([blob], "file.jpg", { type: "image/jpeg" });
						const url = URL.createObjectURL(file);
						const a = document.createElement("a");
						a.download = "file.jpg";
						a.href = url;
						a.click();
						URL.revokeObjectURL(url);
						setOpen(false)
					},
					onCancel: async (blob) => {
            // back button click Listener
						const file = new File([blob], "file.jpg", { type: "image/jpeg" });
						const url = URL.createObjectURL(file);
						const a = document.createElement("a");
						a.download = "file.jpg";
						a.href = url;
						a.click();
						URL.revokeObjectURL(url);
						setOpen(false);
					},
				},
			})
		}
	}, [open, baseUrl]);

	return (
		<>
			<input type="file" onChange={(e) => {
				const url = URL.createObjectURL(e.target.files[0]);

				setBaseUrl(url)
				setOpen(true)

			}} />
			{open && <div ref={ref}></div>}
		</>
	)
}

export default ImageInput;

Demo

https://scd7896.github.io/ImageEditor/examples/

KakaoTalk_Photo_2021-08-20-19-43-26

https://user-images.githubusercontent.com/46440142/130221972-0dac516b-4651-4ea0-b97b-cceaba493ffb.mp4

author

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago