Coder Social home page Coder Social logo

janak-nirmal / react-native-avatar-crop Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vemarav/react-native-avatar-crop

0.0 1.0 0.0 31.53 MB

Highly customisable <Crop /> component for React Native < ๐Ÿ’… >

Home Page: https://www.npmjs.com/package/react-native-avatar-crop

License: MIT License

JavaScript 3.09% TypeScript 63.70% Starlark 4.64% Objective-C 10.91% Ruby 1.92% Java 15.74%

react-native-avatar-crop's Introduction

react-native-avatar-crop

Supports rect and circle cropping. Use cropArea={{width, height}} for custom aspect ratio.

Download apk to see it in action, click to download


Image Picker Network Image
video video

Installation

npm

npm install react-native-avatar-crop vemarav/react-native-image-editor react-native-image-size @react-native-masked-view/masked-view  @react-native-gesture-handler --save

yarn

yarn add react-native-avatar-crop vemarav/react-native-image-editor react-native-image-size @react-native-masked-view/masked-view  @react-native-gesture-handler

Usage

const component = (props) => {
  const { uri, setUri } = useState("");
  let crop;
  const { width: SCREEN_WIDTH } = Dimensions.get("window");

  const cropImage = async () => {
    // crop accepts quality, default is 1
    // uri will have cropped image cache path
    const { uri, width, height } = await crop(0.9);
    setUri(uri);
  };

  return (
    <View>
      {uri ? (
        <Image
          source={{ uri }}
          style={{
            width: SCREEN_WIDTH,
            height: SCREEN_WIDTH,
            resizeMode: "contain",
          }}
        />
      ) : null}
      <Crop
        source={props.uri}
        cropShape={"circle"} // rect || circle
        width={SCREEN_WIDTH} // default value
        height={SCREEN_WIDTH} // defalt value
        cropArea={{
          width: SCREEN_WIDTH / 1.3, // required
          height: SCREEN_WIDTH / 1.3, // required
        }}
        borderWidth={0} // default 2
        backgroundColor={"#FFFFFF"} // default #FFFFFF, use same format
        opacity={0.7} // between 0 and 1, default is 1
        maxZoom={3} // default 3
        resizeMode={"contain"} // default "cover"
        onCrop={(cropCallback) => (crop = cropCallback)} // returns a function
      />
    </View>
  );
};

see full example here

CONTRIBUTING

  1. Whether you are a novice or experienced software developer, all contributions and suggestions are welcome!

    Clone repo

    git clone https://github.com/vemarav/react-native-avatar-crop.git

  2. Add features or bug fixes

  3. Make a Pull Request

    OR

    Report a bug here

    Feel free to contribute, hosted on โค๏ธ with Github.

TODO

  • Add rotation support

LICENSE

Package published under MIT License

Author

LIKED IT

Please use following button to star the, so it can reach others too

SOCIAL

Twitter Follow

react-native-avatar-crop's People

Contributors

vemarav avatar kamui545 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.