image_cropping 패키지는 사용자 정의 비율과 자유 스케일링을 지원하는 이미지 자르기 기능을 구현할 수 있도록 도와줍니다. 자르기 영역에 대한 정밀한 제어가 가능하여 프로필 사진, 썸네일 또는 이미지 크기 조정 및 자르기가 필요한 모든 용도에 적합합니다. 이 패키지는 Android, iOS, 웹, macOS, Windows, Linux 등 여러 플랫폼에서 호환되며 다양한 환경에서 일관된 동작을 보장합니다. 간단한 API를 통해 기존 앱에 원활하게 통합되어 사용자 경험을 향상시킵니다.
사용 사례
프로필 사진 자르기
미리보기 생성
이미지 편집 도구
사용자 아바타 사용자 정의
콘텐츠 생성 워크플로우
소셜 미디어 이미지 처리
주요 기능
비율 잠금
프리스케일 자르기
크로스 플랫폼 호환성
간단한 통합 API
실시간 미리보기 지원
다중 플랫폼 지원
적합한 대상
모바일 앱 개발자
웹 애플리케이션 제작자
이미지 편집 기능 구현자
소셜 미디어 플랫폼
전자상거래 애플리케이션
사용자 친화적인 사진 업로드 시스템
고려 사항
이미지 입력 검증 필요
완전한 UX를 위해 추가적인 UI 컴포넌트가 필요할 수 있습니다
큰 이미지에 대한 성능 영향
기본적인 자르기 작업에 한정
내장 이미지 필터 없음
고급 기능을 위해 외부 종속성에 의존합니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
image_cropping
This plugin supports cropping and rotating images for multiplatform. It Allow inclusion of background, Rotation of image, changing ratio of selection as per requirements.
Allow inclusion of background.
Rotation of image.
Change ratio of selection.
Installation
If you are targeting web, don't forget to add worker.js in your project's root directory.
You can also add worker.js.deps and worker.js.map but they are optional and only used for development.
These 3 files are generated when running the following command in the example folder:
For more details on the command, check this link.
It converts the dart code to JS, which will then be run in a web worker.
Example
final croppedBytes = awaitImageCropping.cropImage(
context: context,
imageBytes: bytes,
onImageStartLoading: () {
showLoader();
},
onImageEndLoading: () {
hideLoader();
},
onImageDoneListener: (data) {
// You can also use a listener instead of awaiting the functionsetState(() {
imageBytes = data;
});
},
selectedImageRatio: ImageRatio.RATIO_1_1,
visibleOtherAspectRatios: true,
squareBorderWidth: 2,
squareCircleColor: Colors.black,
defaultTextColor: Colors.orange,
selectedTextColor: Colors.black,
colorForWhiteSpace: Colors.grey,
encodingQuality: 80,
outputImageFormat: OutputImageFormat.jpg,
workerPath: 'crop_worker.js',
);
Required parameters
BuildContext:
Context is use to push new screen for image cropping.
_imageBytes:
Image bytes is use to draw image in device and if image not fits in device screen then we manage background color(if you have passed colorForWhiteSpace or else White background) in image cropping screen.
_onImageStartLoading:
This is a callback. you have to override and show dialog or etc when image cropping is in loading state.
_onImageEndLoading:
This is a callback. you have to override and hide dialog or etc when image cropping is ready to show result in cropping screen.
_onImageDoneListener:
This is a callback. you have to override and you will get Uint8List as result.
Optional parameters
ImageRatio:
This property contains ImageRatio value. You can set the initialized aspect ratio when starting the cropper by passing a value of ImageRatio. default value is ImageRatio.FREE
visibleOtherAspectRatios:
This property contains boolean value. If this properties is true then it shows all other aspect ratios in cropping screen. default value is true.
squareBorderWidth:
This property contains double value. You can change square border width by passing this value.
squareCircleColor:
This property contains Color value. You can change square circle color by passing this value.
defaultTextColor:
This property contains Color value. By passing this property you can set aspect ratios color which are unselected.
selectedTextColor:
This property contains Color value. By passing this property you can set aspect ratios color which is selected.
colorForWhiteSpace:
This property contains Color value. By passing this property you can set background color, if screen contains blank space.
encodingQuality
Set the encodingQuality of the cropped image. Defaults to 100 (max).
High quality involves bigger image file size.
outputImageFormat
Output format of cropped image, can be PNG or JPG, default is JPG.
workerPath
You may want to change the worker.js name, especially if you use other web workers and you already have a worker.js file.
Defaults to 'worker.js'.
Note:
For flutter web, copy worker.js from example folder to the project, else it will not work.
The result returns in Uint8List. so it can be lost later, you are responsible for storing it somewhere permanent (if needed).
Guideline for contributors
Contribution towards our repository is always welcome, we request contributors to create a pull request to the develop branch only.
Guideline to report an issue/feature request
It would be great for us if the reporter can share the below things to understand the root cause of the issue.
Library version
Code snippet
Logs if applicable
Device specification like (Manufacturer, OS version, etc)
Screenshot/video with steps to reproduce the issue
We’d be really happy if you send us links to your projects where you use our component. Just send an email to sales@mindinventory.com And do let us know if you have any questions or suggestion regarding our work.