Socket
Book a DemoInstallSign in
Socket

@sdcx/image-crop

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sdcx/image-crop

A React Native ui component for image crop.

latest
Source
npmnpm
Version
0.2.0
Version published
Maintainers
1
Created
Source

ImageCropView

ImageCropView 是一个 React Native 原生 UI 组件,用于头像裁剪以及图片裁剪,同时支持图像主体识别后设置需要裁剪的主体区域。

Installation

yarn add @sdcx/image-crop
# &
pod install

Usage

 <ImageCropView
    ref={imageCropViewRef}
    style={'your style'}
    fileUri={'your file uri'}
    cropStyle={'circular' | 'default'}
    onCropped={(uri: string) => {}}
    objectRect={objectRect}
  />

cropStyle

默认default为裁剪矩形,若需要裁剪圆形头像,则设为circular;

objectRect

objectRect可设置默认的图片裁剪区域,且当cropStyle为default时有效。

objectRect的四个属性分别是(单位都是像素px):

  • left: 裁剪区域离图片左边的距离;
  • top: 裁剪区域离图片上边的距离;
  • width: 裁剪区域的宽度;
  • height: 裁剪区域的高度;

裁剪

imageCropViewRef.crop()

然后裁剪成功后会在onCropped属性中回调裁剪后图片的uri;

Keywords

react-native

FAQs

Package last updated on 17 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts